diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index b74c83d637c..8a539d8c315 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -2363,7 +2363,6 @@ class AccountMove(models.Model): (command, _id, line_vals) for command, _id, line_vals in data['line_ids'] if command == Command.CREATE - and line_vals.get('display_type') not in ('payment_term', 'tax', 'rounding') ] elif move.move_type == 'entry': if 'partner_id' not in data: diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index 31fd9d76390..baf779c2fd4 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -496,7 +496,6 @@ class AccountMoveLine(models.Model): values.append(product.description_purchase) line.name = '\n'.join(values) - @api.depends('display_type', 'company_id') def _compute_account_id(self): term_lines = self.filtered(lambda line: line.display_type == 'payment_term') if term_lines: diff --git a/addons/account/tests/test_account_move_out_invoice.py b/addons/account/tests/test_account_move_out_invoice.py index 88ad7352da5..896df22586e 100644 --- a/addons/account/tests/test_account_move_out_invoice.py +++ b/addons/account/tests/test_account_move_out_invoice.py @@ -3746,3 +3746,28 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): 'credit': 0.0, }, ]) + + def test_keep_receivable(self): + """Duplicating an invoice with a different receivable account should keep the account.""" + receivable_account = self.partner_a.property_account_receivable_id + other_receivable_account = receivable_account.copy() + + invoice = self.env['account.move'].create({ + 'move_type': 'out_invoice', + 'partner_id': self.partner_a.id, + 'invoice_line_ids': [ + Command.create({ + 'name': 'test line', + 'quantity': 1, + 'price_unit': 100, + }) + ], + }) + + invoice.line_ids.filtered(lambda l: l.display_type == 'payment_term').account_id = other_receivable_account + duplicate_invoice = invoice.copy() + + self.assertEqual( + duplicate_invoice.line_ids.filtered(lambda l: l.display_type == 'payment_term').account_id, + other_receivable_account + )