I'm porting odoo 11, python 2.7 to python 3. I have been edited an addon which has belongs to odoo, python code.
The code is:
vat = invoice.partner_id.vat or ''
vat = list(filter(lambda x: x.isnumeric(), vat[:2])) + vat[2:]
Error is:
TypeError: can only concatenate list (not "str") to list
How can I fix that, what is wrong with this code? Please help me.
list(filter(lambda x: x.isnumeric(), vat[:2]))
This operation above always returns the list.
vat = invoice.partner_id.vat or ''
or ''
).If you expect that your type(vat)==list
, you should use
vat = invoice.partner_id.vat or []
If you expect type(vat)==str
, you should convert your filtered list to str
, for example
"".join(list(filter(lambda x: x.isnumeric(), vat[:2]))) + vat[2:]