mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX]14.0-pms_l10n_es: update vat code country constrain uses document country instead of country
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
<field name="name">DNI</field>
|
||||
<field name="code">D</field>
|
||||
<field name="country_ids" eval="[(6, 0, [ref('base.es')])]"/>
|
||||
<field name="priority">10</field>
|
||||
<field name="validation_code">
|
||||
letters = {
|
||||
0: "T",
|
||||
@@ -43,6 +44,24 @@ else:
|
||||
<!-- <field name="has_unique_numbers">True</field>-->
|
||||
</record>
|
||||
|
||||
<record id="document_type_spanish_residence" model="res.partner.id_category">
|
||||
<field name="name">Spanish Residence permit</field>
|
||||
<field name="code">N</field>
|
||||
<field name="priority">30</field>
|
||||
<field name="country_ids" eval="[(6, 0, [ref('base.es')])]"/>
|
||||
<field name="validation_code">
|
||||
permit_first_letter=id_number.name[0:1]
|
||||
permit_last_letter = id_number.name[
|
||||
len(id_number.name) - 1 : len(id_number.name)
|
||||
]
|
||||
if (permit_first_letter.upper() in ['X','Y']) and id_number.name[1:8].isdigit() and not permit_last_letter.isdigit():
|
||||
failed = False
|
||||
else:
|
||||
failed = True
|
||||
</field>
|
||||
<!-- <field name="has_unique_numbers">True</field>-->
|
||||
</record>
|
||||
|
||||
<!-- aeat document type mapped -->
|
||||
<!-- disabled because this is an override of an existe record in this file -->
|
||||
<!-- pylint: disable=redundant-modulename-xml -->
|
||||
@@ -51,9 +70,9 @@ else:
|
||||
<field name="aeat_identification_type">02</field>
|
||||
</record>
|
||||
<record
|
||||
id="pms.document_type_spanish_residence"
|
||||
model="res.partner.id_category"
|
||||
>
|
||||
id="pms_l10n_es.document_type_spanish_residence"
|
||||
model="res.partner.id_category"
|
||||
>
|
||||
<field name="aeat_identification_type">05</field>
|
||||
</record>
|
||||
<record
|
||||
|
||||
@@ -134,16 +134,17 @@ class ResPartner(models.Model):
|
||||
return True
|
||||
return False
|
||||
|
||||
@api.constrains("country_id", "vat")
|
||||
@api.constrains("id_numbers", "vat")
|
||||
def update_vat_code_country(self):
|
||||
if self.env.context.get("ignore_vat_update"):
|
||||
return
|
||||
for record in self:
|
||||
country_id = record.country_id.id
|
||||
vat = record.vat
|
||||
if vat and country_id:
|
||||
vat_with_code = record.fix_eu_vat_number(country_id, vat)
|
||||
if country_id and vat != vat_with_code:
|
||||
record.with_context({"ignore_vat_update": True}).write(
|
||||
{"vat": vat_with_code}
|
||||
)
|
||||
if record.id_numbers:
|
||||
country_id = record.id_numbers[0].country_id.id
|
||||
vat = record.vat
|
||||
if vat and country_id:
|
||||
vat_with_code = record.fix_eu_vat_number(country_id, vat)
|
||||
if country_id and vat != vat_with_code:
|
||||
record.with_context({"ignore_vat_update": True}).write(
|
||||
{"vat": vat_with_code}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user