Skip to content

Commit

Permalink
[13.0] [IMP] website_product_pack: For packs line with discount non u…
Browse files Browse the repository at this point in the history
…pdate prices.
  • Loading branch information
nicomacr authored and jjscarafia committed Feb 21, 2021
1 parent 8b1d6d3 commit 6034854
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions website_product_pack/models/sale_order.py
Expand Up @@ -13,11 +13,19 @@ def _cart_update(
self, product_id=None,
line_id=None, add_qty=0, set_qty=0, **kwargs):
sale_order_line = self.env['sale.order.line'].browse(line_id)
# If the line product pack has discount, non update prices fot this line.
pack_line_with_discount = sale_order_line.pack_parent_line_id and \
sale_order_line.pack_parent_line_id.product_id.pack_line_ids.filtered(
lambda x: x.product_id == sale_order_line.product_id and x.sale_discount)
if sale_order_line.pack_parent_line_id and not \
sale_order_line.pack_parent_line_id.product_id.pack_modifiable:
return {
'line_id': line_id,
'quantity': sale_order_line.product_uom_qty}
sale_order_line.pack_parent_line_id.product_id.pack_modifiable or pack_line_with_discount:
quantity = sale_order_line.product_uom_qty
if sale_order_line.pack_parent_line_id.product_id.pack_modifiable:
if set_qty:
quantity = set_qty
elif add_qty is not None:
quantity += (add_qty or 0)
return {'line_id': line_id, 'quantity': quantity}
# we force to remove the packs lines when the partent line is removed from the order.
if not self._context.get('update_pricelist', False) and set_qty == 0 and sale_order_line.pack_child_line_ids:
sale_order_line.pack_child_line_ids.unlink()
Expand Down

0 comments on commit 6034854

Please sign in to comment.