Skip to content

Commit

Permalink
[MIG] product_pack: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ALopez-Adhoc committed Dec 5, 2024
1 parent 6f321f0 commit 20e728f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 47 deletions.
4 changes: 2 additions & 2 deletions product_pack/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion product_pack/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Product Pack",
"version": "17.0.2.0.0",
"version": "18.0.1.0.0",
"category": "Product",
"summary": "This module allows you to set a product as a Pack",
"website": "https://github.com/OCA/product-pack",
Expand Down
1 change: 0 additions & 1 deletion product_pack/models/product_pack_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def _pack_line_price_compute(
# If the component is a pack
for pack in packs:
pack_prices[pack.id] = pack.lst_price

Check warning on line 77 in product_pack/models/product_pack_line.py

View check run for this annotation

Codecov / codecov/patch

product_pack/models/product_pack_line.py#L77

Added line #L77 was not covered by tests

# else
no_pack_prices = no_packs._price_compute(
price_type, uom, currency, company, date
Expand Down
15 changes: 3 additions & 12 deletions product_pack/models/product_pricelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 1 addition & 11 deletions product_pack/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,7 @@ def _compute_product_lst_price(self):
if uom:
uom = self.env["uom.uom"].browse([uom])

Check warning on line 42 in product_pack/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

product_pack/models/product_product.py#L42

Added line #L42 was not covered by tests
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
Expand Down
4 changes: 2 additions & 2 deletions product_pack/readme/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 3 additions & 3 deletions product_pack/tests/test_product_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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)
8 changes: 4 additions & 4 deletions product_pack/views/product_pack_line_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
</form>
</field>
</record>
<record id="product_pack_line_tree" model="ir.ui.view">
<field name="name">product.pack.line.tree</field>
<record id="product_pack_line_list" model="ir.ui.view">
<field name="name">product.pack.line.list</field>
<field name="model">product.pack.line</field>
<field name="arch" type="xml">
<tree editable="bottom">
<list editable="bottom">
<field name="product_id" />
<field name="quantity" />
</tree>
</list>
</field>
</record>
</odoo>
17 changes: 6 additions & 11 deletions product_pack/views/product_template_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,13 @@
name="invisible"
>product_variant_count &gt; 1 or not pack_ok</attribute>
</page>
<group name="group_pack">
<group string="Pack Products" colspan="4">
<field name="id" invisible="1" />
<p invisible="id">You must save first to add pack lines</p>
</group>
<field
name="pack_line_ids"
nolabel="1"
colspan="4"
readonly="not id"
/>
<group name="group_pack">
<group string="Pack Products" colspan="4">
<field name="id" invisible="1" />
<p invisible="id">You must save first to add pack lines</p>
</group>
<field name="pack_line_ids" nolabel="1" colspan="4" readonly="not id" />
</group>
</field>
</record>
</odoo>

0 comments on commit 20e728f

Please sign in to comment.