[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 <smetl@users.noreply.github.com>
Signed-off-by: wan <william-andre@users.noreply.github.com>
This commit is contained in:
william
2020-08-25 08:54:11 +00:00
committed by wan
parent 3f97f8ee5b
commit d1391314d9
2 changed files with 3 additions and 0 deletions
+2
View File
@@ -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))
@@ -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,