Skip to content

Commit

Permalink
[FIX] bug: _get_product_price uses wrong pricelist on batches
Browse files Browse the repository at this point in the history
  • Loading branch information
jbchouinard committed Aug 8, 2017
1 parent 6303f21 commit 4a66e5f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions contract_isp/contract.py
Expand Up @@ -128,16 +128,21 @@ class contract_service(orm.Model):
_name = 'contract.service'

def _get_product_price(self, cr, uid, ids, field_name, arg, context=None):
# WARNING: This method is called on contract.service lines
# belonging to different contracts. We cannot assume that all the
# line have the same partner or pricelist. - Jerome 2017/08
product_pricelist_obj = self.pool.get('product.pricelist')
partner_id = self.browse(
cr, uid, ids[0],
context=context).account_id.partner_id.id
pricelist_id = self.browse(
cr, uid, ids[0],
context=context
).account_id.partner_id.property_product_pricelist.id
ret = {}
for line in self.browse(cr, uid, ids, context=context):
# Possible optimization: group lines by contract so we don't have
# to lookup partner and pricelist for each individual line.
partner_id = self.browse(
cr, uid, line.id,
context=context).account_id.partner_id.id
pricelist_id = self.browse(
cr, uid, line.id,
context=context
).account_id.partner_id.property_product_pricelist.id
if line.product_id:
ret[line.id] = product_pricelist_obj.price_get(
cr, uid, [pricelist_id],
Expand Down

0 comments on commit 4a66e5f

Please sign in to comment.