From 16af8692ab0b9fe07584ba57f4e3744e1a65c430 Mon Sep 17 00:00:00 2001 From: Alexis Lopez Date: Tue, 26 Nov 2024 12:30:31 -0300 Subject: [PATCH] [FIX] product_pack: include product pack price --- product_pack/README.rst | 4 ++-- product_pack/models/product_pricelist.py | 15 +++------------ product_pack/models/product_product.py | 12 +----------- product_pack/readme/USAGE.rst | 4 ++-- product_pack/tests/test_product_pack.py | 6 +++--- 5 files changed, 11 insertions(+), 30 deletions(-) diff --git a/product_pack/README.rst b/product_pack/README.rst index 3741ea30..563f48aa 100644 --- a/product_pack/README.rst +++ b/product_pack/README.rst @@ -76,11 +76,11 @@ The options of this field are the followings: | **Detailed per components** | Yes, with their prices | Components + Pack | Applies to the price of the pack and | Yes, configurable | | | | | the components | | +-----------------------------+-----------------------------+---------------------------------+-----------------------------------------+----------------------+ -| **Detailed - Totalized** | Yes, with their prices at 0 | Components | Applies to the total (pack + components)| No | +| **Detailed - Totalized** | Yes, with their prices at 0 | Components + Pack | Applies to the total (pack + components)| No | +-----------------------------+-----------------------------+---------------------------------+-----------------------------------------+----------------------+ | **Detailed - Ignored** | Yes, with their prices at 0 | Only Pack | Applies to the pack | No | +-----------------------------+-----------------------------+---------------------------------+-----------------------------------------+----------------------+ -| **No detailed** | No | Components | Applies to the total (pack + components)| No | +| **No detailed** | No | Components + Pack | Applies to the total (pack + components)| No | +-----------------------------+-----------------------------+---------------------------------+-----------------------------------------+----------------------+ **Note:** If pricelist enabled, Odoo will display the price according to the corresponding pricelist. In the case of a pricelist with discount policy "Show public price & discount to the customer" keep in mind that the "Non Detailed" and "Detailed - Totalized in main product" packs do not display the discount. diff --git a/product_pack/models/product_pricelist.py b/product_pack/models/product_pricelist.py index 8a42cf6b..bb77059b 100644 --- a/product_pack/models/product_pricelist.py +++ b/product_pack/models/product_pricelist.py @@ -12,18 +12,9 @@ def _get_product_price(self, product, quantity, uom=None, date=False, **kwargs): """ self and self.ensure_one() if product._is_pack_to_be_handled(): - # NOTE: This exception is to avoid adding the list price of the packs - # "totalized" and "non detailed". Should be removed to solve the issue #169. - if ( - product.pack_type == "non_detailed" - or product.pack_component_price == "totalized" - ): - pack_price = 0 - else: - pack_price = self._compute_price_rule( - product, quantity, uom=uom, date=date, **kwargs - )[product.id][0] - + pack_price = self._compute_price_rule( + product, quantity, uom=uom, date=date, **kwargs + )[product.id][0] for line in product.sudo().pack_line_ids: pack_price += line._get_pack_line_price( self, quantity, uom=uom, date=date, **kwargs diff --git a/product_pack/models/product_product.py b/product_pack/models/product_product.py index f2edebb6..240a9023 100644 --- a/product_pack/models/product_product.py +++ b/product_pack/models/product_product.py @@ -41,17 +41,7 @@ def _compute_product_lst_price(self): if uom: uom = self.env["uom.uom"].browse([uom]) for product in packs: - # NOTE: This exception is to avoid adding the list price of the packs - # "totalized" and "non detailed". Should be removed to solve the issue #169. - if ( - product.pack_type == "non_detailed" - or product.pack_component_price == "totalized" - ): - list_price = 0 - else: - list_price = product._price_compute("list_price", uom=uom).get( - product.id - ) + list_price = product._price_compute("list_price", uom=uom).get(product.id) list_price += sum( product.pack_line_ids._pack_line_price_compute( "list_price", uom=uom diff --git a/product_pack/readme/USAGE.rst b/product_pack/readme/USAGE.rst index ce7f542c..ba57a21c 100644 --- a/product_pack/readme/USAGE.rst +++ b/product_pack/readme/USAGE.rst @@ -35,11 +35,11 @@ The options of this field are the followings: | **Detailed per components** | Yes, with their prices | Components + Pack | Applies to the price of the pack and | Yes, configurable | | | | | the components | | +-----------------------------+-----------------------------+---------------------------------+-----------------------------------------+----------------------+ -| **Detailed - Totalized** | Yes, with their prices at 0 | Components | Applies to the total (pack + components)| No | +| **Detailed - Totalized** | Yes, with their prices at 0 | Components + Pack | Applies to the total (pack + components)| No | +-----------------------------+-----------------------------+---------------------------------+-----------------------------------------+----------------------+ | **Detailed - Ignored** | Yes, with their prices at 0 | Only Pack | Applies to the pack | No | +-----------------------------+-----------------------------+---------------------------------+-----------------------------------------+----------------------+ -| **No detailed** | No | Components | Applies to the total (pack + components)| No | +| **No detailed** | No | Components + Pack | Applies to the total (pack + components)| No | +-----------------------------+-----------------------------+---------------------------------+-----------------------------------------+----------------------+ **Note:** If pricelist enabled, Odoo will display the price according to the corresponding pricelist. In the case of a pricelist with discount policy "Show public price & discount to the customer" keep in mind that the "Non Detailed" and "Detailed - Totalized in main product" packs do not display the discount. diff --git a/product_pack/tests/test_product_pack.py b/product_pack/tests/test_product_pack.py index 4a80af34..cb290bae 100644 --- a/product_pack/tests/test_product_pack.py +++ b/product_pack/tests/test_product_pack.py @@ -75,7 +75,7 @@ def test_get_pack_lst_price(self): component_2.product_id.list_price = 15.0 component_3 = self.env.ref("product_pack.pack_cpu_detailed_components_4") component_3.product_id.list_price = 5.0 - self.assertEqual(50.0, pack.lst_price) + self.assertEqual(80.75, pack.lst_price) def test_pack_company(self): # Try to assign pack lines with product that do not belong to pack @@ -133,7 +133,7 @@ def test_pack_price_with_pricelist_context(self): price = pack.with_context( pricelist=self.discount_pricelist.id )._get_contextual_price() - self.assertEqual(price, 2574.0) + self.assertEqual(price, 2601.675) # Pack Ignored pack = self.env.ref("product_pack.product_pack_cpu_detailed_ignored") @@ -147,4 +147,4 @@ def test_pack_price_with_pricelist_context(self): price = pack.with_context( pricelist=self.discount_pricelist.id )._get_contextual_price() - self.assertEqual(price, 2574.0) + self.assertEqual(price, 2601.675)