Skip to content

Commit

Permalink
Merge commit 'refs/pull/110/head' of https://github.com/oca/product-pack
Browse files Browse the repository at this point in the history
 into 13.0-3559
  • Loading branch information
docker-odoo committed Sep 5, 2023
2 parents 7d67b9a + 0f6732f commit 61d7d2f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 59 deletions.
1 change: 0 additions & 1 deletion product_pack/models/__init__.py
@@ -1,6 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import product_pack_line
from . import product_pricelist
from . import product_product
from . import product_template
29 changes: 0 additions & 29 deletions product_pack/models/product_pricelist.py

This file was deleted.

19 changes: 18 additions & 1 deletion product_pack/models/product_product.py
Expand Up @@ -27,7 +27,24 @@ def get_pack_lines(self):
return self.mapped("pack_line_ids")

def split_pack_products(self):
packs = self.filtered(lambda p: p.product_tmpl_id._is_pack_to_be_handled())
"""Split products and the pack in 2 separate recordsets.
:return: [packs, no_packs]
"""
packs = self.filtered(
lambda p: p.pack_ok
and (
(p.pack_type == "detailed" and p.pack_component_price == "totalized")
or p.pack_type == "non_detailed"
)
)
# We could need to check the price of the whole pack (e.g.: e-commerce)
if self.env.context.get("whole_pack_price"):
packs |= self.filtered(
lambda p: p.pack_ok
and p.pack_type == "detailed"
and p.pack_component_price == "detailed"
)
return packs, (self - packs)

def price_compute(self, price_type, uom=False, currency=False, company=False):
Expand Down
28 changes: 0 additions & 28 deletions product_pack/models/product_template.py
Expand Up @@ -80,31 +80,3 @@ def write(self, vals):
self.product_variant_ids.write({"pack_line_ids": vals.get("pack_line_ids")})
_vals.pop("pack_line_ids")
return super().write(_vals)

def _is_pack_to_be_handled(self):
"""Method for getting if a template is a computable pack.
:return: True or False.
"""
self.ensure_one()
is_pack = False
if self.env.context.get("whole_pack_price"):
# We could need to check the price of the whole pack (e.g.: e-commerce)
is_pack = (
self.pack_ok
and self.pack_type == "detailed"
and self.pack_component_price == "detailed"
)
is_pack |= self.pack_ok and (
(self.pack_type == "detailed" and self.pack_component_price == "totalized")
or self.pack_type == "non_detailed"
)
return is_pack

def split_pack_products(self):
"""Split products and the pack in 2 separate recordsets.
:return: [packs, no_packs]
"""
packs = self.filtered(lambda p: p._is_pack_to_be_handled())
return packs, (self - packs)

0 comments on commit 61d7d2f

Please sign in to comment.