Skip to content

Commit f6d1dce

Browse files
committed
[IMP] l10n_es{,edi_sii}: move partner info to l10n_es
Move a function to get partner info from `l10n_es_edi_sii` to `l10n_es`. It will also be needed for Veri*Factu. part of task-3745982 X-original-commit: fb6a169 In 17.0 we also moved the patched http adapter to `l10n_es` But this is not necessary anymore. There is a more general adapter since commit 3037186 . Also `l10n_es_pos` is not `auto_install` anymore since commit 4609634 . X-original-commit: 50dcd60 Part-of: odoo#221431 Signed-off-by: Sven Führ (svfu) <[email protected]>
1 parent 1d328ce commit f6d1dce

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

addons/l10n_es/models/res_partner.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,29 @@ def _l10n_es_is_foreign(self):
88
self.ensure_one()
99

1010
return self.country_id.code not in ('ES', False) or (self.vat or '').startswith("ESN")
11+
12+
def _l10n_es_edi_get_partner_info(self):
13+
self.ensure_one()
14+
eu_country_codes = set(self.env.ref('base.europe').country_ids.mapped('code'))
15+
16+
partner_info = {}
17+
IDOtro_ID = self.vat or 'NO_DISPONIBLE'
18+
19+
if (not self.country_id or self.country_id.code == 'ES') and self.vat:
20+
# ES partner with VAT.
21+
partner_info['NIF'] = self.vat.removeprefix('ES')
22+
if self.env.context.get('error_1117'):
23+
partner_info['IDOtro'] = {'IDType': '07', 'ID': IDOtro_ID}
24+
25+
elif self.country_id.code in eu_country_codes and self.vat:
26+
# European partner.
27+
partner_info['IDOtro'] = {'IDType': '02', 'ID': IDOtro_ID}
28+
else:
29+
partner_info['IDOtro'] = {'ID': IDOtro_ID}
30+
if self.vat:
31+
partner_info['IDOtro']['IDType'] = '04'
32+
else:
33+
partner_info['IDOtro']['IDType'] = '06'
34+
if self.country_id:
35+
partner_info['IDOtro']['CodigoPais'] = self.country_id.code
36+
return partner_info

addons/l10n_es_edi_sii/models/account_edi_format.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -200,29 +200,7 @@ def full_filter_invl_to_apply(invoice_line):
200200
}
201201

202202
def _l10n_es_edi_get_partner_info(self, partner):
203-
eu_country_codes = set(self.env.ref('base.europe').country_ids.mapped('code'))
204-
205-
partner_info = {}
206-
IDOtro_ID = partner.vat or 'NO_DISPONIBLE'
207-
208-
if (not partner.country_id or partner.country_id.code == 'ES') and partner.vat:
209-
# ES partner with VAT.
210-
partner_info['NIF'] = partner.vat[2:] if partner.vat.startswith('ES') else partner.vat
211-
if self.env.context.get('error_1117'):
212-
partner_info['IDOtro'] = {'IDType': '07', 'ID': IDOtro_ID}
213-
214-
elif partner.country_id.code in eu_country_codes and partner.vat:
215-
# European partner.
216-
partner_info['IDOtro'] = {'IDType': '02', 'ID': IDOtro_ID}
217-
else:
218-
partner_info['IDOtro'] = {'ID': IDOtro_ID}
219-
if partner.vat:
220-
partner_info['IDOtro']['IDType'] = '04'
221-
else:
222-
partner_info['IDOtro']['IDType'] = '06'
223-
if partner.country_id:
224-
partner_info['IDOtro']['CodigoPais'] = partner.country_id.code
225-
return partner_info
203+
return partner._l10n_es_edi_get_partner_info()
226204

227205
def _l10n_es_edi_get_invoices_info(self, invoices):
228206
eu_country_codes = set(self.env.ref('base.europe').country_ids.mapped('code'))

0 commit comments

Comments
 (0)