[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) <oco@odoo.com> Signed-off-by: Altaf Shaik (alsh) <alsh@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user