From 9ae944af9fa879be3bf83f703052095e921b5a2d Mon Sep 17 00:00:00 2001 From: Eduard Brahas Date: Tue, 25 Jun 2024 17:22:21 +0200 Subject: [PATCH] [FIX]sale_commission_product_criteria_domain: consider multiple agents --- ...sale_commission_product_criteria_domain.py | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/sale_commission_product_criteria_domain/tests/test_sale_commission_product_criteria_domain.py b/sale_commission_product_criteria_domain/tests/test_sale_commission_product_criteria_domain.py index 958c68030..f14522e32 100644 --- a/sale_commission_product_criteria_domain/tests/test_sale_commission_product_criteria_domain.py +++ b/sale_commission_product_criteria_domain/tests/test_sale_commission_product_criteria_domain.py @@ -92,8 +92,14 @@ def test_commission_domain_demo_cases(self): invoice.recompute_lines_agents() so.order_line.agent_ids._compute_amount() invoice.line_ids.agent_ids._compute_amount() - self.assertEqual(so.order_line.agent_ids.fixed_amount, 20) - self.assertEqual(invoice.line_ids.agent_ids.amount, 20) + + so_fixed_amounts = so.order_line.agent_ids.mapped("fixed_amount") + self.assertEqual(len(so_fixed_amounts), 1) + self.assertEqual(so_fixed_amounts[0], 20) + + inv_amounts = invoice.line_ids.agent_ids.mapped("amount") + self.assertEqual(len(inv_amounts), 1) + self.assertEqual(inv_amounts[0], 20) # Azure Spain Customizable Desk (CONFIG) - Product Template so = self._create_sale_order( @@ -105,8 +111,14 @@ def test_commission_domain_demo_cases(self): invoice.recompute_lines_agents() so.order_line.agent_ids._compute_amount() invoice.line_ids.agent_ids._compute_amount() - self.assertEqual(so.order_line.agent_ids.percent_amount, 5) - self.assertEqual(invoice.line_ids.agent_ids.amount, 50) + + so_percent_amounts = so.order_line.agent_ids.mapped("percent_amount") + self.assertEqual(len(so_percent_amounts), 1) + self.assertEqual(so_percent_amounts[0], 5) + + inv_amounts = invoice.line_ids.agent_ids.mapped("amount") + self.assertEqual(len(inv_amounts), 1) + self.assertEqual(inv_amounts[0], 50) # Azure Spain Variant: Customizable Desk (CONFIG) (Steel, White) - Variant so = self._create_sale_order(self.product_4, self.azure) @@ -190,8 +202,14 @@ def test_commission_domain(self): invoice.recompute_lines_agents() so.order_line.agent_ids._compute_amount() invoice.line_ids.agent_ids._compute_amount() - self.assertEqual(so.order_line.agent_ids.amount, 150) - self.assertEqual(invoice.line_ids.agent_ids.amount, 150) + + so_amounts = so.order_line.agent_ids.mapped("amount") + self.assertEqual(len(so_amounts), 1) + self.assertEqual(so_amounts[0], 150) + + inv_amounts = invoice.line_ids.agent_ids.mapped("amount") + self.assertEqual(len(inv_amounts), 1) + self.assertEqual(inv_amounts[0], 150) # tst_partner = so.partner_id.copy({})