[FIX] l10n_ph: ensure string input in regex substitution

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) <jbw@odoo.com>
Signed-off-by: Séna Serge Nshimiyimana (sesn) <sesn@odoo.com>
This commit is contained in:
sesn-odoo
2024-01-23 07:07:55 +00:00
parent d5822a1f72
commit 3ca0e0c55f
@@ -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