Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions purchase_order_supplierinfo_update/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def create(self, vals_list):

def write(self, vals):
res = super().write(vals)
if vals.get("price_unit") or vals.get("discount"):
sync_fields = self._get_synch_fields_line_to_supplierinfo()
if vals.get("price_unit") or any(key in sync_fields for key in vals.keys()):
self.update_supplierinfo_price()
return res

Expand Down Expand Up @@ -70,5 +71,14 @@ def _update_supplierinfo(self, seller):
# Set price
if new_seller_price != seller.price:
seller.sudo().price = new_seller_price
if self.discount != seller.discount:
seller.sudo().discount = self.discount

sync_fields = self._get_synch_fields_line_to_supplierinfo()
for field in sync_fields:
if field in seller and field in self:
seller.sudo()[field] = self[field]

def _get_synch_fields_line_to_supplierinfo(self):
sync_fields = ["discount"]
if "triple.discount.mixin" in self.env:
sync_fields += ["discount1", "discount2", "discount3"]
return sync_fields
Loading