Skip to content
Snippets Groups Projects
Commit f1ceae57 authored by Mahdi cheikh rouhou (macr)'s avatar Mahdi cheikh rouhou (macr) Committed by Mahdi Cheikh Rouhou (macr)
Browse files

[FIX] sale : get correct button title invoice email


When we have automatic invoicing enabled , the email sent to the user
when he confirms his payment online will contain a button 'View Journal
Entry'

To reproduce the error :
1- Install accounting, website, ecommerce, sales apps
2- Go to website settings and activate automatic invoice
3- Install test payment method and activate it
4- Log out of the current account
5- Make a purchase of any item and confirm the payment
6- You will receive 2 emails , the second one will have the invoice and
it will contain a button View journal entry

The origin of the problem is not providing model_description when
sending the invoice so it will take the display_name of the model
'account.move' by default which is Journal entry.

opw-3271345

closes odoo/odoo#121525

X-original-commit: 8d791167
Signed-off-by: default avatarVictor Feyens (vfe) <vfe@odoo.com>
Signed-off-by: default avatarMahdi Cheikh Rouhou (macr) <macr@odoo.com>
parent 8e553f06
Branches
Tags
No related merge requests found
......@@ -133,7 +133,8 @@ class PaymentTransaction(models.Model):
)
if not template_id:
return
template_id = int(template_id)
template = self.env['mail.template'].browse(template_id)
for tx in self:
tx = tx.with_company(tx.company_id).with_context(
company_id=tx.company_id.id,
......@@ -142,9 +143,13 @@ class PaymentTransaction(models.Model):
lambda i: not i.is_move_sent and i.state == 'posted' and i._is_ready_to_be_sent()
)
invoice_to_send.is_move_sent = True # Mark invoice as sent
for invoice in invoice_to_send.with_user(SUPERUSER_ID):
invoice.message_post_with_template(
int(template_id),
for invoice in invoice_to_send:
lang = template._render_lang(invoice.ids)[invoice.id]
model_desc = invoice.with_context(lang=lang).type_name
invoice.with_context(model_description=model_desc).with_user(
SUPERUSER_ID
).message_post_with_template(
template_id=template_id,
email_layout_xmlid='mail.mail_notification_layout_with_responsible_signature',
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment