diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/l10n_co/models | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/l10n_co/models')
| -rw-r--r-- | addons/l10n_co/models/__init__.py | 5 | ||||
| -rw-r--r-- | addons/l10n_co/models/l10n_latam_identification_type.py | 8 | ||||
| -rw-r--r-- | addons/l10n_co/models/res_partner.py | 20 |
3 files changed, 33 insertions, 0 deletions
diff --git a/addons/l10n_co/models/__init__.py b/addons/l10n_co/models/__init__.py new file mode 100644 index 00000000..5f31f163 --- /dev/null +++ b/addons/l10n_co/models/__init__.py @@ -0,0 +1,5 @@ +# coding: utf-8 +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import l10n_latam_identification_type +from . import res_partner diff --git a/addons/l10n_co/models/l10n_latam_identification_type.py b/addons/l10n_co/models/l10n_latam_identification_type.py new file mode 100644 index 00000000..a860f632 --- /dev/null +++ b/addons/l10n_co/models/l10n_latam_identification_type.py @@ -0,0 +1,8 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from odoo import models, fields + + +class L10nCoDocumentType(models.Model): + _inherit = "l10n_latam.identification.type" + + l10n_co_document_code = fields.Char("Document Code") diff --git a/addons/l10n_co/models/res_partner.py b/addons/l10n_co/models/res_partner.py new file mode 100644 index 00000000..160eacb7 --- /dev/null +++ b/addons/l10n_co/models/res_partner.py @@ -0,0 +1,20 @@ +# coding: utf-8 +# Part of Odoo. See LICENSE file for full copyright and licensing details. +from odoo import models, api + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + @api.constrains('vat', 'country_id', 'l10n_latam_identification_type_id') + def check_vat(self): + # check_vat is implemented by base_vat which this localization + # doesn't directly depend on. It is however automatically + # installed for Colombia. + if self.sudo().env.ref('base.module_base_vat').state == 'installed': + # don't check Colombian partners unless they have RUT (= Colombian VAT) set as document type + self = self.filtered(lambda partner: partner.country_id.code != "CO" or\ + partner.l10n_latam_identification_type_id.l10n_co_document_code == 'rut') + return super(ResPartner, self).check_vat() + else: + return True |
