From e9266ad1c01c9d51b499fe210dbb3bcd3908e258 Mon Sep 17 00:00:00 2001 From: althaf shaik Date: Mon, 14 Aug 2023 17:54:34 +0530 Subject: [PATCH] [FIX] sale: make payment when journal type is not sale This traceback arises when a user tries to make a payment on the website. To reproduce this issue: 1) Install 'website_sale' 2) open invoicing/configuration/journals 3) Change the journal type if it is 'sales' 4) Install and enable 'Wire Transfer' payment provider in invocing/configuration/Payment Providers 5) Now open 'website/shop' add any product to cart and proceed to checkout 6) Make a payment with 'Wire Transfer' Error: 'ValueError Expected singleton: account.journal()' On '_compute_sale_order_reference' method, 'invoice_journal' variable is getting values with the reference of 'type=sale'. See:- https://github.com/odoo/odoo/blob/ebc4ed6c4fb11b01be28cf417b27de83d5361cef/addons/sale/models/payment_transaction.py#L20-L30 Because of user changed the type of journal, 'invoice_journal' value will be empty recordset and it is referenced to call '_process_reference_for_sale_order' method. In '_process_reference_for_sale_order' method ensure_one() is used, which leads to above traceback. sentry-4392496618 closes odoo/odoo#134083 X-original-commit: c880a295d0f7feff48b08fd00723a41b8d564d2d Signed-off-by: Olivier Colson (oco) Signed-off-by: Altaf Shaik (alsh) --- addons/sale/models/payment_transaction.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sale/models/payment_transaction.py b/addons/sale/models/payment_transaction.py index 93ac1caf059..3922d0d6f2a 100644 --- a/addons/sale/models/payment_transaction.py +++ b/addons/sale/models/payment_transaction.py @@ -24,7 +24,8 @@ class PaymentTransaction(models.Model): order_reference = '%s/%s' % ('CUST', str(identification_number % 97).rjust(2, '0')) invoice_journal = self.env['account.journal'].search([('type', '=', 'sale'), ('company_id', '=', self.env.company.id)], limit=1) - order_reference = invoice_journal._process_reference_for_sale_order(order_reference) + if invoice_journal: + order_reference = invoice_journal._process_reference_for_sale_order(order_reference) return order_reference