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:
parent
41da51562c
commit
cc4dcd73db
1 changed files with 12 additions and 3 deletions
15
edocument.py
15
edocument.py
|
@ -63,7 +63,8 @@ class Invoice(Invoice):
|
||||||
numtax=len(line.invoice_taxes)))
|
numtax=len(line.invoice_taxes)))
|
||||||
|
|
||||||
allowed_cat = ['AE', 'L', 'M', 'E', 'S', 'Z', 'G', 'O', 'K', 'B']
|
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(
|
raise UserError(gettext(
|
||||||
'edocument_xrechnung.msg_linetax_invalid_catcode',
|
'edocument_xrechnung.msg_linetax_invalid_catcode',
|
||||||
taxname=line.invoice_taxes[0].tax.rec_name,
|
taxname=line.invoice_taxes[0].tax.rec_name,
|
||||||
|
@ -99,14 +100,22 @@ class Invoice(Invoice):
|
||||||
uomname=line.unit.rec_name))
|
uomname=line.unit.rec_name))
|
||||||
return line.unit.unece_code
|
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):
|
def tax_category_code(self, tax):
|
||||||
""" read tax-category, fire exception if missing
|
""" 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(
|
raise UserError(gettext(
|
||||||
'edocument_xrechnung.mds_tax_category_missing',
|
'edocument_xrechnung.mds_tax_category_missing',
|
||||||
taxname=tax.rec_name))
|
taxname=tax.rec_name))
|
||||||
return tax.unece_category_code
|
return unece_category_code
|
||||||
|
|
||||||
def quote_text(self, text):
|
def quote_text(self, text):
|
||||||
""" replace critical chars
|
""" replace critical chars
|
||||||
|
|
Loading…
Reference in a new issue