Skip to content

Commit

Permalink
Merge pull request #61 from acsone/7.0-product_pricelist_fixed_price-lga
Browse files Browse the repository at this point in the history
product_pricelist_fixed_price : allow to write only one id
  • Loading branch information
pedrobaeza committed Apr 9, 2015
2 parents f473d14 + 2a6e847 commit 2b7302d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
5 changes: 3 additions & 2 deletions product_pricelist_fixed_price/__openerp__.py
Expand Up @@ -3,7 +3,7 @@
#
# OpenERP, Open Source Management Solution
# Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
Expand All @@ -23,7 +23,8 @@
{
"name": "Fixed price in pricelists",
"version": "2.0",
"author": "Serv. Tecnol. Avanzados - Pedro M. Baeza,Odoo Community Association (OCA)",
"author": "Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Odoo Community Association (OCA)",
"category": "Sales Management",
"description": """
Fixed price on pricelist rule
Expand Down
1 change: 0 additions & 1 deletion product_pricelist_fixed_price/model/__init__.py
Expand Up @@ -16,4 +16,3 @@
#
##############################################################################
from . import product_pricelist_item

20 changes: 10 additions & 10 deletions product_pricelist_fixed_price/model/product_pricelist_item.py
Expand Up @@ -27,15 +27,17 @@

FIXED_PRICE_TYPE = -3


class ProductPrice(orm.Model):

'''Inherit existing model to add functionality for fixed prices'''
_inherit = 'product.pricelist.item'

def _price_field_get_ext(self, cr, uid, context=None):
'''Added fixed price to pricetypes'''
result = super(
ProductPrice, self)._price_field_get(
cr, uid, context=context)
cr, uid, context=context)
result.append((FIXED_PRICE_TYPE, _('Fixed Price')))
return result

Expand Down Expand Up @@ -133,19 +135,17 @@ def write(self, cr, uid, ids, vals, context=None):
'''override write to get computed values.
We need the loop, because computed values might depend on existing
values.'''
for object_id in ids:
browse_records = self.browse(
cr, uid, [object_id], context=context)
browse_obj = browse_records[0]
self._modify_vals(
cr, uid, vals, browse_obj=browse_obj, context=context)
super(ProductPrice, self).write(
cr, uid, [object_id], vals, context=context)
if isinstance(ids, (int, long)):
ids = [ids]
for browse_obj in self.browse(cr, uid, ids, context=context):
self._modify_vals(cr, uid, vals, browse_obj=browse_obj,
context=context)
super(ProductPrice, self).write(cr, uid, browse_obj.id,
vals, context=context)
return True

def onchange_base_ext(self, cr, uid, ids, base_ext, context=None):
'''Make sure values for base and base_ext keep in sync in the UI'''
vals = {'base_ext': base_ext}
self._modify_vals(cr, uid, vals, context=context)
return {'value': vals}

0 comments on commit 2b7302d

Please sign in to comment.