| 1 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 2 |
|
| 3 |
from odoo import fields, models, api |
| 4 |
|
| 5 |
|
| 6 |
class ResConfigSettings(models.TransientModel): |
| 7 |
_inherit = 'res.config.settings' |
| 8 |
|
| 9 |
l10n_hu_tax_regime = fields.Selection( |
| 10 |
related='company_id.l10n_hu_tax_regime', |
| 11 |
readonly=False, |
| 12 |
) |
| 13 |
l10n_hu_edi_server_mode = fields.Selection( |
| 14 |
related='company_id.l10n_hu_edi_server_mode', |
| 15 |
readonly=False, |
| 16 |
) |
| 17 |
l10n_hu_edi_username = fields.Char( |
| 18 |
related='company_id.l10n_hu_edi_username', |
| 19 |
readonly=False, |
| 20 |
) |
| 21 |
l10n_hu_edi_password = fields.Char( |
| 22 |
related='company_id.l10n_hu_edi_password', |
| 23 |
readonly=False, |
| 24 |
) |
| 25 |
l10n_hu_edi_signature_key = fields.Char( |
| 26 |
related='company_id.l10n_hu_edi_signature_key', |
| 27 |
readonly=False, |
| 28 |
) |
| 29 |
l10n_hu_edi_replacement_key = fields.Char( |
| 30 |
related='company_id.l10n_hu_edi_replacement_key', |
| 31 |
readonly=False, |
| 32 |
) |
| 33 |
# Technical field to control display of the "Authentication with NAV 3.0 successful" banner |
| 34 |
l10n_hu_edi_is_active = fields.Boolean( |
| 35 |
compute='_compute_l10n_hu_edi_is_active', |
| 36 |
) |
| 37 |
|
| 38 |
@api.depends('company_id.l10n_hu_edi_server_mode') |
| 39 |
def _compute_l10n_hu_edi_is_active(self): |
| 40 |
for record in self: |
| 41 |
record.l10n_hu_edi_is_active = record.company_id.l10n_hu_edi_server_mode in ['production', 'test'] |
| 42 |
|
| 43 |
@api.model_create_multi |
| 44 |
def create(self, vals_list): |
| 45 |
records = super().create(vals_list) |
| 46 |
for record in records: |
| 47 |
if record.company_id.l10n_hu_edi_server_mode in ['production', 'test']: |
| 48 |
record.company_id._l10n_hu_edi_test_credentials() |
| 49 |
return records |