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-5402
  • Loading branch information
docker-odoo committed Jan 30, 2024
2 parents cef4438 + 0f6732f commit 586ca88
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 586ca88

Please sign in to comment.