Normalize formatted tax identifiers for ID type
Publicar paquete PyPI / publish (push) Successful in 2m54s
Publicar paquete PyPI / publish (push) Successful in 2m54s
This commit is contained in:
+22
-10
@@ -1109,16 +1109,28 @@ class Invoice(metaclass=PoolMeta):
|
||||
return {'amount_invoiced_goods': amount_invoiced_goods}
|
||||
|
||||
def get_id_type(self, name):
|
||||
if self.party:
|
||||
if not self.party_tax_identifier:
|
||||
return None
|
||||
code_length = len(self.party_tax_identifier.code)
|
||||
if code_length == 9:
|
||||
return 1
|
||||
elif code_length == 11:
|
||||
return 2
|
||||
else:
|
||||
return 3
|
||||
if not self.party or not self.party_tax_identifier:
|
||||
return None
|
||||
|
||||
identifier = self.party_tax_identifier
|
||||
identifier_type = getattr(identifier, 'type', None)
|
||||
if identifier_type in {'do_rnc', 'do_vat'}:
|
||||
return 1
|
||||
if identifier_type == 'do_cedula':
|
||||
return 2
|
||||
|
||||
# Tryton 8.0 stores a formatted display code (for example
|
||||
# ``1-01-01063-2`` or ``001-1391820-5``). Use code_compact when
|
||||
# available and still normalize it for migrated records whose compact
|
||||
# value may retain the old formatting.
|
||||
code = (getattr(identifier, 'code_compact', None)
|
||||
or getattr(identifier, 'code', None) or '')
|
||||
digits = re.sub(r'\D', '', code)
|
||||
if len(digits) == 9:
|
||||
return 1
|
||||
if len(digits) == 11:
|
||||
return 2
|
||||
return 3
|
||||
|
||||
@fields.depends('taxes', 'lines')
|
||||
def on_change_with_itbis_invoiced(self, name=None):
|
||||
|
||||
Reference in New Issue
Block a user