[IMP] product: factorize contextual price

This commit factorizes contextual price in order to ease further
inheritance.

task-2382027
This commit is contained in:
Thibault Libioulle
2022-04-14 14:33:22 +02:00
parent 71050fb0fe
commit 7ac5ffa8aa
2 changed files with 3 additions and 11 deletions
+1 -9
View File
@@ -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)
+2 -2
View File
@@ -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