From b3d4085714d5ad0cfbb6a32ab926f11bcaa7dbfb Mon Sep 17 00:00:00 2001 From: mtr Date: Fri, 5 Aug 2011 10:50:25 +0530 Subject: [PATCH] [FIX] account,hr,hr_recruitment,hr_payroll,product:- enforced _sql_constraint to maintain uniqueness lp bug: https://launchpad.net/bugs/789019 fixed bzr revid: mtr@mtr-20110805052025-3w0w7ccnnlrish2b --- addons/account/account.py | 8 +++++++- addons/hr/hr.py | 5 +++++ addons/hr_payroll/hr_payroll.py | 7 +++++++ addons/hr_payroll/hr_payroll_demo.xml | 2 +- addons/hr_recruitment/hr_recruitment.py | 3 +++ addons/product/product.py | 3 +++ 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 72208314ed9..32f220f2a4b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -880,7 +880,10 @@ class account_period(osv.osv): 'state': 'draft', } _order = "date_start, special desc" - + _sql_constraints = [ + ('name_company_uniq', 'unique(name, company_id)', 'The name of the period must be unique per company !'), + ] + def _check_duration(self,cr,uid,ids,context=None): obj_period = self.browse(cr, uid, ids[0], context=context) if obj_period.date_stop < obj_period.date_start: @@ -1762,6 +1765,9 @@ class account_tax(osv.osv): 'type_tax_use': fields.selection([('sale','Sale'),('purchase','Purchase'),('all','All')], 'Tax Application', required=True) } + _sql_constraints = [ + ('name_company_uniq', 'unique(name, company_id)', 'Tax Name must be unique per company!'), + ] def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): """ diff --git a/addons/hr/hr.py b/addons/hr/hr.py index 43b66ac18d6..2990090f2ab 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -97,6 +97,11 @@ class hr_job(osv.osv): 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'hr.job', context=c), 'state': 'open', } + + _sql_constraints = [ + ('name_company_uniq', 'unique(name, company_id)', 'The name of the job position must be unique per company !'), + ] + def on_change_expected_employee(self, cr, uid, ids, no_of_recruitment, no_of_employee, context=None): if context is None: diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index cdf6549fedd..f114a45b664 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -184,6 +184,9 @@ class hr_salary_rule_category(osv.osv): self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id, } + _sql_constraints = [ + ('code_uniq', 'unique(code)', 'The code of salary rule category must be unique!'), + ] hr_salary_rule_category() @@ -816,6 +819,10 @@ result = rules.NET > categories.NET * 0.10''', 'amount_percentage': 0.0, 'quantity': '1.0', } + + _sql_constraints = [ + ('code_uniq', 'unique(code)', 'The code of salary rule must be unique!'), + ] def _recursive_search_of_rules(self, cr, uid, rule_ids, context=None): """ diff --git a/addons/hr_payroll/hr_payroll_demo.xml b/addons/hr_payroll/hr_payroll_demo.xml index bcbecd63ffd..be1da066e22 100644 --- a/addons/hr_payroll/hr_payroll_demo.xml +++ b/addons/hr_payroll/hr_payroll_demo.xml @@ -66,7 +66,7 @@ fix - CA + CAQP Conveyance Allowance For Paolino diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 5e738fc6f48..d468eace9fd 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -73,6 +73,9 @@ class hr_recruitment_degree(osv.osv): _defaults = { 'sequence': 1, } + _sql_constraints = [ + ('name_uniq', 'unique (name)', 'The name of the Degree of Recruitment must be unique!') + ] hr_recruitment_degree() class hr_applicant(crm.crm_case, osv.osv): diff --git a/addons/product/product.py b/addons/product/product.py index 9deaf3398b1..85af9ef31d7 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -365,6 +365,9 @@ class product_template(osv.osv): _constraints = [ (_check_uom, 'Error: The default UOM and the purchase UOM must be in the same category.', ['uom_id']), ] + _sql_constraints = [ + ('name_ref_uniq', 'unique(name, company_id)', 'The name of the product must be unique per company!'), + ] def name_get(self, cr, user, ids, context=None): if context is None: