From ea4e594b289f4b9e22977b718210804fa7e5c7ce Mon Sep 17 00:00:00 2001 From: Nicolas Seinlet Date: Fri, 22 Jan 2021 14:42:29 +0000 Subject: [PATCH] [FIX] account: restricted fields on notes In 13.0, some account.move.line fields (amount_currency, debit, credit and account_id) couldn't have a value when the line is of type 'note'. Skiping them during line copy for notes is not an issue. During 12.0->13.0 migration, we were facing issues with "grouped similar invoice lines in a single move line", because this feature is not available anymore in 13.0. To avoid any "loss of data" during migration, we used lines of type note to create "missing" invoice lines in move lines without altering accounting in any way. As a consequence, we have 13.0 databases with lines of type note having values for fields who couldn't have ones. closes odoo/odoo#64962 X-original-commit: 677edafeaf8d691764178f5e7e9639017b0249a8 Signed-off-by: Quentin De Paoli (qdp) --- addons/account/models/account_move.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index fbafbac8ab2..d726f81c1c2 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -4604,6 +4604,12 @@ class AccountMoveLine(models.Model): # Don't copy the name of a payment term line. if line.move_id.is_invoice() and line.account_id.user_type_id.type in ('receivable', 'payable'): values['name'] = '' + # Don't copy restricted fields of notes + if line.display_type in ('line_section', 'line_note'): + values['amount_currency'] = 0 + values['debit'] = 0 + values['credit'] = 0 + values['account_id'] = False if self._context.get('include_business_fields'): line._copy_data_extend_business_fields(values) return res