Skip to content

Commit

Permalink
Merge PR #3047 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by rousseldenis
  • Loading branch information
OCA-git-bot committed Sep 17, 2024
2 parents 55a0da2 + e2c492e commit abba2d1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
37 changes: 36 additions & 1 deletion sale_product_multi_add/tests/test_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@ def setUp(self):

self.product_9 = self.env.ref("product.product_product_9")
self.product_11 = self.env.ref("product.product_product_11")
ProductPricelist = self.env["product.pricelist"]
self.product_pricelist_01 = ProductPricelist.create(
{
"name": "Demo Pricelist",
"item_ids": [
(
0,
0,
{
"applied_on": "0_product_variant",
"product_id": self.product_9.id,
"compute_price": "formula",
"base": "standard_price",
"price_discount": 10,
},
0,
0,
{
"applied_on": "0_product_variant",
"product_id": self.product_11.id,
"compute_price": "formula",
"base": "standard_price",
"price_discount": 10,
},
),
],
}
)

def test_import_product(self):
"""Create SO
Expand All @@ -17,7 +45,10 @@ def test_import_product(self):
"""

so = self.env["sale.order"].create(
{"partner_id": self.env.ref("base.res_partner_2").id}
{
"partner_id": self.env.ref("base.res_partner_2").id,
"pricelist_id": self.product_pricelist_01.id,
}
)

wiz_obj = self.env["sale.import.products"]
Expand All @@ -34,6 +65,10 @@ def test_import_product(self):
self.assertEqual(len(so.order_line), 2)

for line in so.order_line:
self.assertEqual(
line.price_unit,
line.product_id.with_context(pricelist=so.pricelist_id.id).price,
)
if line.product_id.id == self.product_9.id:
self.assertEqual(line.product_uom_qty, 4)
else:
Expand Down
4 changes: 3 additions & 1 deletion sale_product_multi_add/wizards/sale_import_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def _get_line_values(self, sale, item):
"product_id": item.product_id.id,
"product_uom_qty": item.quantity,
"product_uom": item.product_id.uom_id.id,
"price_unit": item.product_id.list_price,
"price_unit": item.product_id.with_context(
pricelist=sale.pricelist_id.id
).price,
}
)
line_values = sale_line._convert_to_write(sale_line._cache)
Expand Down

0 comments on commit abba2d1

Please sign in to comment.