From 3ca0e0c55ff1ef6ca7c554b06d511f9660f5b074 Mon Sep 17 00:00:00 2001 From: sesn-odoo Date: Mon, 22 Jan 2024 14:58:27 +0100 Subject: [PATCH] [FIX] l10n_ph: ensure string input in regex substitution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce ------------------ * install `l10n_ph` * switch to a Filipino company * create a vendor bill with a line with no product and a tax that has a "Philippines ATC" defined (ex: 5% WI010 - Prof Fees) * attempt to generate the `BIR 2307 Report` through the action menu You should be met with a traceback. opw-3683037 closes odoo/odoo#150566 X-original-commit: c1ab55fd1e0eecb9848392995f91d994ad6d4d4c Signed-off-by: de Wouters de Bouchout Jean-Benoît (jbw) Signed-off-by: Séna Serge Nshimiyimana (sesn) --- addons/l10n_ph/wizard/generate_2307_wizard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/l10n_ph/wizard/generate_2307_wizard.py b/addons/l10n_ph/wizard/generate_2307_wizard.py index 264ec0bf86d..225e3efe4c8 100644 --- a/addons/l10n_ph/wizard/generate_2307_wizard.py +++ b/addons/l10n_ph/wizard/generate_2307_wizard.py @@ -57,7 +57,8 @@ class Generate2307Wizard(models.TransientModel): } for invoice_line in move.invoice_line_ids.filtered(lambda l: l.display_type not in ('line_note', 'line_section')): for tax in invoice_line.tax_ids.filtered(lambda x: x.l10n_ph_atc): - values['product_name'] = re.sub(r'[\(\)]', '', invoice_line.product_id.name) + product_name = invoice_line.product_id.name or invoice_line.name + values['product_name'] = re.sub(r'[\(\)]', '', product_name) if product_name else "" values['atc'] = tax.l10n_ph_atc values['price_subtotal'] = invoice_line.price_subtotal values['amount'] = tax.amount