Debian Codegraph @

addons/l10n_hu_edi/models/res_partner.py

raw
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
3 from odoo import api, fields, models
4
5
6 class ResPartner(models.Model):
7 _inherit = 'res.partner'
8
9 l10n_hu_group_vat = fields.Char(
10 string='Group Tax ID',
11 size=13,
12 help="If this company belongs to a VAT group, indicate the group's VAT number here.",
13 index=True,
14 )
15
16 @api.model
17 def _commercial_fields(self):
18 return super()._commercial_fields() + [
19 'l10n_hu_group_vat',
20 ]
21
22 @api.model
23 def _run_vies_test(self, vat_number, default_country):
24 """Convert back the hungarian format to EU format: 12345678-1-12 => HU12345678"""
25 if default_country and default_country.code == 'HU' and not vat_number.startswith('HU'):
26 vat_number = f'HU{vat_number[:8]}'
27 return super()._run_vies_test(vat_number, default_country)