Skip to content
Snippets Groups Projects
Commit 29762514 authored by Toufik Ben Jaa's avatar Toufik Ben Jaa
Browse files

[FIX] sale: singleton error when validating payments


- When validating a payment an "expected singleton" exception is
raised due to the fact that we are using a recordset with multiple
record instead of a recordset with a single record.

OPW-1981632

closes odoo/odoo#33767

Signed-off-by: default avatarChristophe Simonis <chs@odoo.com>
parent d92acc60
No related branches found
No related tags found
No related merge requests found
......@@ -96,11 +96,11 @@ class PaymentTransaction(models.Model):
if self.env['ir.config_parameter'].sudo().get_param('sale.automatic_invoice'):
default_template = self.env['ir.config_parameter'].sudo().get_param('sale.default_email_template')
if default_template:
ctx_company = {'company_id': self.acquirer_id.company_id.id,
'force_company': self.acquirer_id.company_id.id,
'mark_invoice_as_sent': True,
}
for trans in self.filtered(lambda t: t.sale_order_ids):
ctx_company = {'company_id': trans.acquirer_id.company_id.id,
'force_company': trans.acquirer_id.company_id.id,
'mark_invoice_as_sent': True,
}
trans = trans.with_context(ctx_company)
for invoice in trans.invoice_ids:
invoice.message_post_with_template(int(default_template), notif_layout="mail.mail_notification_paynow")
......@@ -109,9 +109,9 @@ class PaymentTransaction(models.Model):
@api.multi
def _invoice_sale_orders(self):
if self.env['ir.config_parameter'].sudo().get_param('sale.automatic_invoice'):
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):
ctx_company = {'company_id': trans.acquirer_id.company_id.id,
'force_company': trans.acquirer_id.company_id.id}
trans = trans.with_context(**ctx_company)
trans.sale_order_ids._force_lines_to_invoice_policy_order()
invoices = trans.sale_order_ids.action_invoice_create()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment