From ffbdea57f5d0e736a45d1e1d63791ae006943f4e Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Wed, 6 Mar 2019 12:49:08 +0000 Subject: [PATCH] [FIX] sale: correctly propagate contexts Commit d139e92c621f88676e5fefa9f2359dabc8b4602c set the force_send to True unless there is an explicit mail_notify_force_send set to False in the context. The _get_eval_context puts mail_notify_force_send to False in the context, but it might be lost before reaching that method call. Launch a cron that starts a transaction, see if it goes through, and rollback if it didn't, then the mails send inbetween will be sent every time the cron restarts. E.g. _cron_post_process_after_done. opw 1921112 opw 1945953 closes odoo/odoo#31605 Signed-off-by: Nans Lefebvre (len) --- addons/sale/models/payment.py | 2 +- addons/sale/models/sale.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sale/models/payment.py b/addons/sale/models/payment.py index c97d93430cd..3d650c647fe 100644 --- a/addons/sale/models/payment.py +++ b/addons/sale/models/payment.py @@ -112,7 +112,7 @@ class PaymentTransaction(models.Model): ctx_company = {'company_id': self.acquirer_id.company_id.id, 'force_company': self.acquirer_id.company_id.id} for trans in self.filtered(lambda t: t.sale_order_ids): - trans = trans.with_context(ctx_company) + trans = trans.with_context(**ctx_company) trans.sale_order_ids._force_lines_to_invoice_policy_order() invoices = trans.sale_order_ids.action_invoice_create() trans.invoice_ids = [(6, 0, invoices)] diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index 1b4fdc9c5ea..5fec16b88a2 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -651,7 +651,7 @@ class SaleOrder(models.Model): if email_act and email_act.get('context'): email_ctx = email_act['context'] email_ctx.update(default_email_from=order.company_id.email) - order.with_context(email_ctx).message_post_with_template(email_ctx.get('default_template_id')) + order.with_context(**email_ctx).message_post_with_template(email_ctx.get('default_template_id')) return True @api.multi