From d1391314d9fde8d04c5bf2ab0b26d910800cde22 Mon Sep 17 00:00:00 2001 From: william Date: Wed, 22 Jul 2020 15:12:47 +0000 Subject: [PATCH] [FIX] account: name of invoices sent by mail The name set by the mail gateway was the title of the mail. The name should be set with the journal sequence when posting instead. This behavior was broken by 5d24244f417cb8f221f8d418663f4544adcd5613 closes odoo/odoo#56065 Related: odoo/enterprise#12492 Signed-off-by: Laurent Smet Signed-off-by: wan --- addons/account/models/account_move.py | 2 ++ addons/account/tests/test_account_incoming_supplier_invoice.py | 1 + 2 files changed, 3 insertions(+) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 1cefc707687..369667cc0a4 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -2240,11 +2240,13 @@ class AccountMove(models.Model): # Create the invoice. values = { + 'name': '/', # we have to give the name otherwise it will be set to the mail's subject 'invoice_source_email': from_mail_addresses[0], 'partner_id': partners and partners[0].id or False, } move_ctx = self.with_context(default_move_type=custom_values['move_type'], default_journal_id=custom_values['journal_id']) move = super(AccountMove, move_ctx).message_new(msg_dict, custom_values=values) + move._compute_name() # because the name is given, we need to recompute in case it is the first invoice of the journal # Assign followers. all_followers_ids = set(partner.id for partner in followers + senders + partners if is_internal_partner(partner)) diff --git a/addons/account/tests/test_account_incoming_supplier_invoice.py b/addons/account/tests/test_account_incoming_supplier_invoice.py index f845676a34b..373fcbab346 100644 --- a/addons/account/tests/test_account_incoming_supplier_invoice.py +++ b/addons/account/tests/test_account_incoming_supplier_invoice.py @@ -57,6 +57,7 @@ class TestAccountIncomingSupplierInvoice(AccountTestInvoicingCommon): following_partners = invoice.message_follower_ids.mapped('partner_id') self.assertEqual(following_partners, self.env.user.partner_id) + self.assertRegex(invoice.name, 'BILL/\d{4}/\d{2}/0001') def test_supplier_invoice_forwarded_by_internal_user_without_supplier(self): """ In this test, the bill was forwarded by an employee,