diff options
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 993eaed1..6dd31d89 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -239,8 +239,14 @@ class SaleOrder(models.Model): @api.constrains('fee_third_party', 'delivery_amt', 'biaya_lain_lain') def _check_total_margin_excl_third_party(self): for rec in self: - if rec.fee_third_party == 0: - rec.total_margin_excl_third_party = rec.total_percent_margin + if rec.fee_third_party == 0 and rec.total_margin_excl_third_party != rec.total_percent_margin: + # Gunakan direct SQL atau flag context untuk menghindari rekursi + self.env.cr.execute(""" + UPDATE sale_order + SET total_margin_excl_third_party = %s + WHERE id = %s + """, (rec.total_percent_margin, rec.id)) + self.invalidate_cache() @api.constrains('shipping_option_id') def _check_shipping_option(self): |
