diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 14dca823303404899dd028765952d3b4442ea6b2..ebf00cd5230f6a8dea5f26f99a3e29c19c09bd54 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -2217,7 +2217,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 d5121fdb314d7853dcc49a7cd55e6e5837f7ab7b..0422659c35aa49d19c46d2f433c41bd72bce2cb9 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -483,7 +483,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 8df9c23fb9d6d09f85a5f790e68495f87cab9949..df9314e3fd5e5e58ae70a39bcbc2b211786c8783 100644 --- a/addons/account/tests/test_account_move_out_invoice.py +++ b/addons/account/tests/test_account_move_out_invoice.py @@ -3717,3 +3717,28 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): self.assertRecordValues(invoice.line_ids.filtered(lambda l: l.display_type == 'payment_term'), [ {'account_id': receivable_account.id, 'tax_ids': []}, ]) + + 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 + )