From c57f2bc513ebcebd6377ac2aa4970dac6f5eab5c Mon Sep 17 00:00:00 2001 From: PicchiSeba Date: Fri, 28 Jun 2024 12:39:42 +0200 Subject: [PATCH] [IMP]l10n_it_fatturapa_in: copy changing values only --- .../wizard/wizard_import_fatturapa.py | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py b/l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py index bdacd4b0e4fb..eb35e567b0b0 100644 --- a/l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py +++ b/l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py @@ -1183,6 +1183,27 @@ def _prepare_invoice_values(self, fatt, fatturapa_attachment, FatturaBody, partn self.set_e_invoice_lines(FatturaBody, invoice_data) return invoice_data + @api.model + def _new_write_vals(self, invoice): + """ + Update changing values only + """ + to_return = invoice._convert_to_write(invoice._cache) + to_remove = set() + for field, val in to_return.items(): + is_multi_field = invoice._fields[field].type in ["many2many", "one2many"] + if ( + is_multi_field + and ( + (val[0][0] == 6 and val[0][2] == invoice[field].ids) + or (val[0][0] == 5 and not invoice[field]) + ) + ) or invoice[field] == val: + to_remove.add(field) + for field in to_remove: + del to_return[field] + return to_return + def invoiceCreate(self, fatt, fatturapa_attachment, FatturaBody, partner_id): partner_model = self.env["res.partner"] partner = partner_model.browse(partner_id) @@ -1227,7 +1248,8 @@ def invoiceCreate(self, fatt, fatturapa_attachment, FatturaBody, partner_id): invoice._onchange_invoice_line_wt_ids() invoice._recompute_dynamic_lines() - invoice.write(invoice._convert_to_write(invoice._cache)) + write_vals = self._new_write_vals(invoice) + invoice.write(write_vals) rel_docs_dict = { # 2.1.2