Skip to content

Commit

Permalink
sale_exception_product_sale_manufactured_for: adapt to variant
Browse files Browse the repository at this point in the history
Partner relation has been moved to variant here OCA/product-attribute#1400
  • Loading branch information
simahawk committed Aug 17, 2023
1 parent 45654df commit faedd67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ def exception_partner_can_order_manufactured_for(self):

self.env.cr.execute(
"""
SELECT rel.product_template_id, ARRAY_AGG(rel.res_partner_id)
SELECT rel.product_id, ARRAY_AGG(rel.partner_id)
FROM sale_order_line sol
JOIN product_product pp ON (sol.product_id = pp.id)
JOIN product_template pt ON (pp.product_tmpl_id = pt.id)
JOIN product_template_res_partner_rel rel ON (rel.product_template_id = pt.id)
JOIN product_product prod ON (sol.product_id = prod.id)
JOIN product_product_manuf_for_partner_rel rel ON (rel.product_id = prod.id)
WHERE sol.display_type IS NULL
AND sol.order_id = %s
GROUP BY rel.product_template_id
GROUP BY rel.product_id
""",
(self.id,),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def setUpClass(cls):
partner_order = cls.env.ref("base.res_partner_1")
cls.partner_manufactured_for = cls.env.ref("base.res_partner_3")
cls.product = cls.env.ref("product.product_product_6")
cls.product.product_tmpl_id.manufactured_for_partner_ids |= (
cls.partner_manufactured_for
)
cls.product.manufactured_for_partner_ids |= cls.partner_manufactured_for

cls.sale = cls.env["sale.order"].create(
{
Expand Down Expand Up @@ -53,7 +51,7 @@ def test_commercial_partner_not_valid(self):
def test_commercial_partner_is_valid(self):
self.sale.partner_id.commercial_partner_id = self.sale.order_line[
0
].product_id.product_tmpl_id.manufactured_for_partner_ids[0]
].product_id.manufactured_for_partner_ids[0]
self.sale.action_confirm()
self.assertEqual(self.sale.state, "sale")
self.assertFalse(self.sale.exception_ids)
Expand All @@ -66,14 +64,14 @@ def test_commercial_partner_empty(self):
self.assertEqual(self.sale.exception_ids[0], self.exception)

def test_product_without_limits_partner_with_commercial_entity(self):
self.product.product_tmpl_id.manufactured_for_partner_ids = False
self.product.manufactured_for_partner_ids = False
self.sale.partner_id.commercial_partner_id = self.partner_manufactured_for
self.sale.action_confirm()
self.assertEqual(self.sale.state, "sale")
self.assertFalse(self.sale.exception_ids)

def test_product_without_limits_partner_without_commercial_entity(self):
self.product.product_tmpl_id.manufactured_for_partner_ids = False
self.product.manufactured_for_partner_ids = False
self.sale.partner_id.commercial_partner_id = False
self.sale.action_confirm()
self.assertEqual(self.sale.state, "sale")
Expand Down

0 comments on commit faedd67

Please sign in to comment.