From 6c73b6be4e690250f21067e15650480033652105 Mon Sep 17 00:00:00 2001 From: Arnaud Joset Date: Mon, 19 Sep 2022 09:17:43 +0000 Subject: [PATCH] [FIX] sale: use str2bool to make sure the boolean sale.automatic_invoice is correctly used When a boolean ir.config.parameter is set to False, self.env['ir.config_parameter'].sudo().get_param('parzm_key') will return 'False'. As the string is not falsy, the parameter value match as true. This commit fix the behavior for the sale.automatic_invoice to keep coherence with the subscription module closes odoo/odoo#101906 X-original-commit: ade1a1f5ee00baa88347bfd151f028bd17d7f4f1 Related: odoo/enterprise#32173 Signed-off-by: William Braeckman (wbr) Signed-off-by: Yannick Tivisse (yti) Signed-off-by: Arnaud Joset --- addons/sale/models/payment_transaction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sale/models/payment_transaction.py b/addons/sale/models/payment_transaction.py index a37d0ff28e5..f65d3584be7 100644 --- a/addons/sale/models/payment_transaction.py +++ b/addons/sale/models/payment_transaction.py @@ -5,7 +5,7 @@ from datetime import datetime from dateutil import relativedelta from odoo import _, api, Command, fields, models, SUPERUSER_ID -from odoo.tools import format_amount +from odoo.tools import format_amount, str2bool _logger = logging.getLogger(__name__) @@ -117,7 +117,7 @@ class PaymentTransaction(models.Model): confirmed_orders._send_order_confirmation_mail() # invoice the sale orders if needed and send it - if self.env['ir.config_parameter'].sudo().get_param('sale.automatic_invoice'): + if str2bool(self.env['ir.config_parameter'].sudo().get_param('sale.automatic_invoice')): # Invoice the sale orders in self instead of in confirmed_orders to create the invoice # even if only a partial payment was made. self._invoice_sale_orders()