From 8f03b342e5d5146ee0035e5adda853e2b9c64356 Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Wed, 13 Jul 2022 09:34:28 +0000 Subject: [PATCH] [FIX] account: allow missing account_id in account.move.line vals When an invoice line has a display_type, account addon is expecting account_id=False in vals. Replacing the normal dict access with a `get` will fix the error when invoicing with note/section lines without explicitly specifying the `account_id` to be false. closes odoo/odoo#95894 Signed-off-by: Masereel Pierre --- addons/account/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 761d39b8cef..ca875fd1283 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -4939,7 +4939,7 @@ class AccountMoveLine(models.Model): and self._context.get('default_move_type') in ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'): # Fill missing 'account_id'. journal = self.env['account.journal'].browse(self._context.get('default_journal_id') or self._context['journal_id']) - if values['partner_id']: + if values.get('partner_id'): # Get most used account of the partner as the default. account_id = self.env['account.account']._order_by_frequency_per_partner( journal.company_id.id, values['partner_id'], self._context.get("default_move_type"), limit=1)[0]