Skip to content

Commit 89a8a53

Browse files
committed
[MIG] product_variant_sale_price: Migration to 16.0
1 parent 1523ac8 commit 89a8a53

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

product_variant_sale_price/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"name": "Product Variant Sale Price",
77
"summary": "Allows to write fixed prices in product variants",
8-
"version": "15.0.1.0.0",
8+
"version": "16.0.1.0.0",
99
"category": "Product Management",
1010
"website": "https://github.com/OCA/product-variant",
1111
"author": "Tecnativa, " "Odoo Community Association (OCA)",

product_variant_sale_price/models/product_product.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,25 @@ def _compute_lst_price(self):
3434
uom_model = self.env["uom.uom"]
3535
for product in self:
3636
price = product.fix_price or product.list_price
37-
if "uom" in self.env.context:
38-
price = product.uom_id._compute_price(
39-
price, uom_model.browse(self.env.context["uom"])
40-
)
37+
if self.env.context.get("uom"):
38+
context_uom = uom_model.browse(self.env.context["uom"])
39+
price = product.uom_id._compute_price(price, context_uom)
4140
product.lst_price = price
4241

4342
def _compute_list_price(self):
4443
uom_model = self.env["uom.uom"]
4544
for product in self:
4645
price = product.fix_price or product.product_tmpl_id.list_price
47-
if "uom" in self.env.context:
48-
price = product.uom_id._compute_price(
49-
price, uom_model.browse(self.env.context["uom"])
50-
)
46+
if self.env.context.get("uom"):
47+
context_uom = uom_model.browse(self.env.context["uom"])
48+
price = product.uom_id._compute_price(price, context_uom)
5149
product.list_price = price
5250

5351
def _inverse_product_lst_price(self):
5452
uom_model = self.env["uom.uom"]
5553
for product in self:
5654
vals = {}
57-
if "uom" in self.env.context:
55+
if self.env.context.get("uom"):
5856
vals["fix_price"] = product.uom_id._compute_price(
5957
product.lst_price, uom_model.browse(self.env.context["uom"])
6058
)

product_variant_sale_price/tests/test_product_product.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ def test_post_init_hook(self):
6767
)
6868

6969
# Flush the records to DB before direct SQL
70-
self.product_blue.flush()
71-
self.product_red.flush()
70+
self.product_blue.flush_model()
71+
self.product_red.flush_model()
7272

7373
set_sale_price_on_variant(self.cr, None, self.product_template.id)
74-
self.product_template.product_variant_ids.invalidate_cache()
74+
self.env.invalidate_all()
7575
self.assertEqual(
7676
self.product_template.list_price + 100.00, self.product_blue.lst_price
7777
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../product_variant_sale_price
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

0 commit comments

Comments
 (0)