From 4d04ac20569d72aac1640a9e9b1453fd2ae306ba Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Thu, 3 Feb 2022 15:12:07 +0000 Subject: [PATCH] [FIX] sale: remove dumb onchange logic Do not update the commitment_date everytime the expected date is modified, otherwise there is no meaning to have two fields... Furthermore, it seems that this onchange causes a performance loss on SO/SOL updates, forcing the whole SOL data to be returned along the SO data during the SO onchange. Therefore removing this onchange improves the performance of SOL updates and consequently the final save of the record by reducing the data wrongly considered modified and given to the create/write call. X-original-commit: 116ca30b2f5f27f8959961c786b88fdcec36338a Part-of: odoo/odoo#84105 --- addons/sale/models/sale_order.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/addons/sale/models/sale_order.py b/addons/sale/models/sale_order.py index a49c06dcecf..4349aaddcf1 100644 --- a/addons/sale/models/sale_order.py +++ b/addons/sale/models/sale_order.py @@ -396,13 +396,6 @@ class SaleOrder(models.Model): tax_totals = account_move._get_tax_totals(order.partner_id, tax_lines_data, order.amount_total, order.amount_untaxed, order.currency_id) order.tax_totals_json = json.dumps(tax_totals) - # YTI TODO: Convert into compute method, however this introduces - # a behavior change that breaks the test test_reservation_method_w_sale - # Note: This should be the case - @api.onchange('expected_date') - def _onchange_expected_date(self): - self.commitment_date = self.expected_date - @api.depends('transaction_ids') def _compute_authorized_transaction_ids(self): for trans in self: @@ -544,7 +537,7 @@ class SaleOrder(models.Model): } } - @api.onchange('commitment_date') + @api.onchange('commitment_date', 'expected_date') def _onchange_commitment_date(self): """ Warn if the commitment dates is sooner than the expected date """ if (self.commitment_date and self.expected_date and self.commitment_date < self.expected_date):