Skip to content

Commit

Permalink
[FIX] purchase_discount: Prevent price_unit recursion error since odo…
Browse files Browse the repository at this point in the history
  • Loading branch information
victoralmau committed Aug 1, 2022
1 parent 874c7d7 commit 5c054ff
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions purchase_discount/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ def _get_stock_move_price_unit(self):
HACK: This is needed while https://github.com/odoo/odoo/pull/29983
is not merged.
"""
bypass_price_unit = self.env.context.get("bypass_override_price_unit")
price_unit = False
price = self._get_discounted_price_unit()
if price != self.price_unit:
if price != self.price_unit and not bypass_price_unit:
# Only change value if it's different
price_unit = self.price_unit
self.price_unit = price
self.with_context(bypass_override_price_unit=True).price_unit = price
price = super()._get_stock_move_price_unit()
if price_unit:
self.price_unit = price_unit
if price_unit and not bypass_price_unit:
self.with_context(bypass_override_price_unit=True).price_unit = price_unit
return price

@api.onchange("product_qty", "product_uom")
Expand Down

0 comments on commit 5c054ff

Please sign in to comment.