summaryrefslogtreecommitdiff
path: root/addons/l10n_co
diff options
context:
space:
mode:
authorJoren Van Onder <jov@odoo.com>2018-01-26 16:23:27 -0800
committerJoren Van Onder <jov@odoo.com>2018-02-05 16:19:48 -0800
commit4b74cea41346e190ad696370139274530f4fe48e (patch)
treee1b59f3f89eac5c1385c0f231d01b849b6758296 /addons/l10n_co
parentb44f559fe7577afdaa83511bdf0b6ca47ffeb8b7 (diff)
[FIX] l10n_co: only validate VAT for RUT document types
In Colombia customers can legally identify themselves with various codes, one of which is the RUT. This is the traditional TIN and adheres to the rules implement by base_vat. The other types however don't and so shouldn't be checked by base_vat. opw-781247
Diffstat (limited to 'addons/l10n_co')
-rw-r--r--addons/l10n_co/models/res_partner.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/addons/l10n_co/models/res_partner.py b/addons/l10n_co/models/res_partner.py
index cf6763b6d2d..b2a23a08f9d 100644
--- a/addons/l10n_co/models/res_partner.py
+++ b/addons/l10n_co/models/res_partner.py
@@ -40,3 +40,16 @@ class ResPartner(models.Model):
partner.l10n_co_verification_code = 11 - number
except ValueError:
partner.l10n_co_verification_code = False
+
+ @api.constrains('vat', 'commercial_partner_country_id', 'l10n_co_document_type')
+ 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 != self.env.ref('base.co') or\
+ partner.l10n_co_document_type == 'rut')
+ return super(ResPartner, self).check_vat()
+ else:
+ return True