From 8ad431e0d24e52a983ba9e8c76ca2a7be984cd68 Mon Sep 17 00:00:00 2001 From: "Abdelouahab (abla)" Date: Tue, 22 Aug 2023 13:25:40 +0200 Subject: [PATCH] [FIX] purchase: no recomputing date when autocomplete To reproduce ============ - create a purchase order and confirm it - create a Bill, set its Bill date and Accounting date to different dates to today - save it, then choose the created PO in autocomplete field the Accounting day will be changed to today Problem ======= when calling the autocomplete, some values will be updated on the record, where `move_type` is one of them, and updating this field will trigger the compute of accounting date. Solution ======== if the value of `move_type` on the record is the same as the one of the update, it should not be taken into account which will avoid uneeded recompute. opw-3381530 closes odoo/odoo#136559 X-original-commit: 6abcac2025522e5e023d51c02f14c49044658b70 Signed-off-by: William Henrotin (whe) Signed-off-by: Abdelouahab Laaroussi (abla) --- addons/purchase/models/account_invoice.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index 316160042e0..b9f1c12bd32 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -55,6 +55,8 @@ class AccountMove(models.Model): new_currency_id = self.invoice_line_ids and self.currency_id or invoice_vals.get('currency_id') del invoice_vals['ref'] del invoice_vals['company_id'] # avoid recomputing the currency + if self.move_type == invoice_vals['move_type']: + del invoice_vals['move_type'] # no need to be updated if it's same value, to avoid recomputes self.update(invoice_vals) self.currency_id = new_currency_id