mirror of
https://github.com/bringout/oca-ocb-l10n_europe.git
synced 2026-04-27 17:42:05 +02:00
19.0 vanilla
This commit is contained in:
parent
ff721d030e
commit
7721452493
1826 changed files with 124775 additions and 274114 deletions
37
odoo-bringout-oca-ocb-l10n_es/l10n_es/models/res_partner.py
Normal file
37
odoo-bringout-oca-ocb-l10n_es/l10n_es/models/res_partner.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from odoo import models
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = 'res.partner'
|
||||
|
||||
def _l10n_es_is_foreign(self):
|
||||
self.ensure_one()
|
||||
|
||||
return self.country_id.code not in ('ES', False) or (self.vat or '').startswith("ESN")
|
||||
|
||||
def _l10n_es_edi_get_partner_info(self):
|
||||
""" Used in SII and Veri*factu"""
|
||||
self.ensure_one()
|
||||
eu_country_codes = set(self.env.ref('base.europe').country_ids.mapped('code'))
|
||||
|
||||
partner_info = {}
|
||||
IDOtro_ID = self.vat or 'NO_DISPONIBLE'
|
||||
|
||||
if (not self.country_id or self.country_id.code == 'ES') and self.vat:
|
||||
# ES partner with VAT.
|
||||
partner_info['NIF'] = self.vat.removeprefix('ES')
|
||||
if self.env.context.get('error_1117'):
|
||||
partner_info['IDOtro'] = {'IDType': '07', 'ID': IDOtro_ID}
|
||||
|
||||
elif self.country_id.code in eu_country_codes and self.vat:
|
||||
# European partner.
|
||||
partner_info['IDOtro'] = {'IDType': '02', 'ID': IDOtro_ID}
|
||||
else:
|
||||
partner_info['IDOtro'] = {'ID': IDOtro_ID}
|
||||
if self.vat:
|
||||
partner_info['IDOtro']['IDType'] = '04'
|
||||
else:
|
||||
partner_info['IDOtro']['IDType'] = '06'
|
||||
if self.country_id:
|
||||
partner_info['IDOtro']['CodigoPais'] = self.country_id.code
|
||||
return partner_info
|
||||
Loading…
Add table
Add a link
Reference in a new issue