[IMP] product: factorize contextual price
This commit factorizes contextual price in order to ease further inheritance. task-2382027
This commit is contained in:
@@ -704,12 +704,4 @@ class ProductProduct(models.Model):
|
||||
|
||||
def _get_contextual_price(self):
|
||||
self.ensure_one()
|
||||
# YTI TODO: During website_sale cleaning, we should get rid of those crappy context thing
|
||||
pricelist = self.product_tmpl_id._get_contextual_pricelist()
|
||||
if not pricelist:
|
||||
return 0.0
|
||||
|
||||
quantity = self.env.context.get('quantity', 1.0)
|
||||
uom = self.env['uom.uom'].browse(self.env.context.get('uom'))
|
||||
date = self.env.context.get('date')
|
||||
return pricelist._get_product_price(self, quantity, uom=uom, date=date)
|
||||
return self.product_tmpl_id._get_contextual_price(self)
|
||||
|
||||
@@ -1273,7 +1273,7 @@ class ProductTemplate(models.Model):
|
||||
'template': '/product/static/xls/product_template.xls'
|
||||
}]
|
||||
|
||||
def _get_contextual_price(self):
|
||||
def _get_contextual_price(self, product=None):
|
||||
self.ensure_one()
|
||||
# YTI TODO: During website_sale cleaning, we should get rid of those crappy context thing
|
||||
pricelist = self._get_contextual_pricelist()
|
||||
@@ -1283,7 +1283,7 @@ class ProductTemplate(models.Model):
|
||||
quantity = self.env.context.get('quantity', 1.0)
|
||||
uom = self.env['uom.uom'].browse(self.env.context.get('uom'))
|
||||
date = self.env.context.get('date')
|
||||
return pricelist._get_product_price(self, quantity, uom=uom, date=date)
|
||||
return pricelist._get_product_price(product or self, quantity, uom=uom, date=date)
|
||||
|
||||
def _get_contextual_pricelist(self):
|
||||
""" Get the contextual pricelist
|
||||
|
||||
Reference in New Issue
Block a user