# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import markupsafe
from odoo import _, api, fields, models, release
# === TBAI license values ===
L10N_ES_TBAI_LICENSE_DICT = {
'production': {
'license_name': _('Production license'), # all agencies
'license_number': 'TBAIGI5A266A7CCDE1EC',
'license_nif': 'N0251909H',
'software_name': 'Odoo SA',
'software_version': release.version,
},
'araba': {
'license_name': _('Test license (Araba)'),
'license_number': 'TBAIARbjjMClHKH00849',
'license_nif': 'N0251909H',
'software_name': 'Odoo SA',
'software_version': release.version,
},
'bizkaia': {
'license_name': _('Test license (Bizkaia)'),
'license_number': 'TBAIBI00000000PRUEBA',
'license_nif': 'A99800005',
'software_name': 'SOFTWARE GARANTE TICKETBAI PRUEBA',
'software_version': '1.0',
},
'gipuzkoa': {
'license_name': _('Test license (Gipuzkoa)'),
'license_number': 'TBAIGIPRE00000000965',
'license_nif': 'N0251909H',
'software_name': 'Odoo SA',
'software_version': release.version,
},
}
class ResCompany(models.Model):
_inherit = 'res.company'
# === TBAI config ===
l10n_es_tbai_tax_agency = fields.Selection(
string="Tax Agency for TBAI",
selection=[
('araba', "Hacienda Foral de Araba"), # es-vi (region code)
('bizkaia', "Hacienda Foral de Bizkaia"), # es-bi
('gipuzkoa', "Hacienda Foral de Gipuzkoa"), # es-ss
],
)
l10n_es_tbai_license_html = fields.Html(
string="TicketBAI license",
compute='_compute_l10n_es_tbai_license_html',
)
# === TBAI CHAIN HEAD ===
l10n_es_tbai_chain_sequence_id = fields.Many2one(
comodel_name='ir.sequence',
string='TicketBai account.move chain sequence',
readonly=True,
copy=False,
)
@api.depends('country_id', 'l10n_es_edi_test_env', 'l10n_es_tbai_tax_agency')
def _compute_l10n_es_tbai_license_html(self):
for company in self:
license_dict = company._get_l10n_es_tbai_license_dict()
if license_dict:
license_dict.update({
'tr_nif': _('Licence NIF'),
'tr_number': _('Licence number'),
'tr_name': _('Software name'),
'tr_version': _('Software version')
})
company.l10n_es_tbai_license_html = markupsafe.Markup('''
{license_name}
{tr_nif}: {license_nif}
{tr_number}: {license_number}
{tr_name}: {software_name}
{tr_version}: {software_version}