Lookup parent taxes for unece tax codes.

Child taxes do not respect the setting of the parent 'Override
tmeplate', thus can not be configured for unece codes. It is anyway
better to allow the code definition on the parent tax.
This commit is contained in:
Mathias Behrle 2024-10-15 11:28:00 +02:00
parent 39f282ec93
commit 265599ac61

View file

@ -63,7 +63,8 @@ class Invoice(Invoice):
numtax=len(line.invoice_taxes)))
allowed_cat = ['AE', 'L', 'M', 'E', 'S', 'Z', 'G', 'O', 'K', 'B']
if not line.invoice_taxes[0].tax.unece_category_code in allowed_cat:
unece_category_code = self.get_category_code(line.invoice_taxes[0].tax)
if unece_category_code not in allowed_cat:
raise UserError(gettext(
'edocument_xrechnung.msg_linetax_invalid_catcode',
taxname=line.invoice_taxes[0].tax.rec_name,
@ -99,14 +100,22 @@ class Invoice(Invoice):
uomname=line.unit.rec_name))
return line.unit.unece_code
def get_category_code(self, tax):
while tax:
if tax.unece_category_code:
return tax.unece_category_code
break
tax = tax.parent
def tax_category_code(self, tax):
""" read tax-category, fire exception if missing
"""
if len(tax.unece_category_code or '') == 0:
unece_category_code = self.get_category_code(tax)
if not unece_category_code:
raise UserError(gettext(
'edocument_xrechnung.mds_tax_category_missing',
taxname=tax.rec_name))
return tax.unece_category_code
return unece_category_code
def quote_text(self, text):
""" replace critical chars