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,