Skip to content

Commit

Permalink
Merge PR #198 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Jan 3, 2025
2 parents f9ddffb + 436e424 commit e362bb1
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions product_pack/models/product_pricelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Pricelist(models.Model):
_inherit = "product.pricelist"

def _get_product_price(self, product, quantity, uom=None, date=False, **kwargs):
def _get_product_price(self, product, *args, **kwargs):
"""Compute the pricelist price for the specified pack product, qty & uom.
:returns: unit price of the pack product + components,
Expand All @@ -20,32 +20,24 @@ def _get_product_price(self, product, quantity, uom=None, date=False, **kwargs):
):
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, *args, **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
)
pack_price += line._get_pack_line_price(self, *args, **kwargs)
return pack_price
else:
return super()._get_product_price(
product=product, quantity=quantity, uom=uom, date=date, **kwargs
)
return super()._get_product_price(product, *args, **kwargs)

def _get_products_price(self, products, quantity, uom=None, date=False, **kwargs):
def _get_products_price(self, products, *args, **kwargs):
"""Compute the pricelist price for the specified pack product, qty & uom.
:returns: unit price of the pack product + components,
considering pricelist rules
"""
packs, no_packs = products.split_pack_products()
res = super()._get_products_price(
no_packs, quantity=quantity, uom=uom, date=date, **kwargs
)
res = super()._get_products_price(no_packs, *args, **kwargs)
for pack in packs:
res[pack.id] = self._get_product_price(
product=pack, quantity=quantity, uom=uom, date=date, **kwargs
)
res[pack.id] = self._get_product_price(pack, *args, **kwargs)
return res

0 comments on commit e362bb1

Please sign in to comment.