[FIX] product: same price with different pricelist

- Create a report to show price on each template
--> Issue: The price is the same

closes odoo/odoo#78870

Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
Florent de Labarre
2021-10-28 10:51:57 +00:00
parent aa2d0abb1b
commit d5f855be9e
2 changed files with 30 additions and 0 deletions
@@ -188,6 +188,7 @@ class ProductTemplate(models.Model):
def _compute_cost_currency_id(self):
self.cost_currency_id = self.env.company.currency_id.id
@api.depends_context('pricelist', 'partner', 'quantity', 'uom', 'date', 'company')
def _compute_template_price(self):
prices = self._compute_template_price_no_inverse()
for template in self:
@@ -79,6 +79,10 @@ class TestProductPricelist(TransactionCase):
'name': 'Acoustic Bloc Screens',
'categ_id': self.category_5_id,
})
self.product_multi_price = self.env['product.product'].create({
'name': 'Multi Price',
'categ_id': self.env.ref('product.product_category_1').id,
})
self.uom_unit_id = self.ref('uom.product_uom_unit')
self.list0 = self.ref('product.list0')
@@ -130,6 +134,24 @@ class TestProductPricelist(TransactionCase):
'compute_price': 'formula',
'price_discount': 50,
'base': 'list_price'
}), (0, 0, {
'name': 'Multi Price Customer',
'applied_on': '1_product',
'product_tmpl_id': self.product_multi_price.product_tmpl_id.id,
'compute_price': 'fixed',
'fixed_price': 99,
'base': 'list_price'
})]
})
self.business_pricelist = self.ProductPricelist.create({
'name': 'Business Pricelist',
'item_ids': [(0, 0, {
'name': 'Multi Price Business',
'applied_on': '1_product',
'product_tmpl_id': self.product_multi_price.product_tmpl_id.id,
'compute_price': 'fixed',
'fixed_price': 50,
'base': 'list_price'
})]
})
@@ -201,4 +223,11 @@ class TestProductPricelist(TransactionCase):
float_compare(monitor.price, monitor.lst_price/2, precision_digits=2), 0,
msg)
# Check if the price is different when we change the pricelist
product = self.product_multi_price.product_tmpl_id.with_context(pricelist=self.customer_pricelist.id, quantity=1)
msg = "Wrong price: Multi Product Price. should be 99 instead of %s" % product.price
self.assertEqual(float_compare(product.price, 99, precision_digits=2), 0)
product = self.product_multi_price.product_tmpl_id.with_context(pricelist=self.business_pricelist.id, quantity=1)
msg = "Wrong price: Multi Product Price. should be 50 instead of %s" % product.price
self.assertEqual(float_compare(product.price, 50, precision_digits=2), 0)