From 5f9682c35304af14a58b9160ec15ccfd44c96c67 Mon Sep 17 00:00:00 2001 From: Fekete Mihai Date: Fri, 12 Sep 2014 16:04:22 +0200 Subject: [PATCH] [FIX] l10n_ro: backport of fix done in res_partner.py from aa76885 PR #720 --- addons/l10n_ro/res_partner.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/addons/l10n_ro/res_partner.py b/addons/l10n_ro/res_partner.py index 4835f75bb40..103a5d616d0 100644 --- a/addons/l10n_ro/res_partner.py +++ b/addons/l10n_ro/res_partner.py @@ -28,26 +28,15 @@ class res_partner(osv.osv): 'nrc' : fields.char('NRC', size=16, help='Registration number at the Registry of Commerce'), } - # The SQL constraints are no-ops but present only to display the right error message to the - # user when the partial unique indexes defined below raise errors/ - # The real constraints need to be implemented with PARTIAL UNIQUE INDEXES (see auto_init), - # due to the way accounting data is delegated by contacts to their companies in OpenERP 7.0. - _sql_constraints = [ - ('vat_uniq', 'unique (id)', 'The vat of the partner must be unique !'), - ('nrc_uniq', 'unique (id)', 'The code of the partner must be unique !') - ] - def _auto_init(self, cr, context=None): result = super(res_partner, self)._auto_init(cr, context=context) - # Real implementation of the vat/nrc constraints: only "commercial entities" need to have - # unique numbers, and the condition for being a commercial entity is "is_company or parent_id IS NULL". - # Contacts inside a company automatically have a copy of the company's commercial fields - # (see _commercial_fields()), so they are automatically consistent. + # Remove constrains for vat, nrc on "commercial entities" because is not mandatory by legislation + # Even that VAT numbers are unique, the NRC field is not unique, and there are certain entities that + # doesn't have a NRC number plus the formatting was changed few times, so we cannot have a base rule for + # checking if available and emmited by the Ministry of Finance, only online on their website. cr.execute(""" DROP INDEX IF EXISTS res_partner_vat_uniq_for_companies; DROP INDEX IF EXISTS res_partner_nrc_uniq_for_companies; - CREATE UNIQUE INDEX res_partner_vat_uniq_for_companies ON res_partner (vat) WHERE is_company OR parent_id IS NULL; - CREATE UNIQUE INDEX res_partner_nrc_uniq_for_companies ON res_partner (nrc) WHERE is_company OR parent_id IS NULL; """) return result