Add missing unique keys
authorNimesh (Open ERP) <nco@tinyerp.com>
Tue, 26 Jul 2011 13:21:37 +0000 (18:51 +0530)
committerNimesh (Open ERP) <nco@tinyerp.com>
Tue, 26 Jul 2011 13:21:37 +0000 (18:51 +0530)
lp bug: https://launchpad.net/bugs/789019 fixed

bzr revid: nco@tinyerp.com-20110726132137-h8go2l62xkn8pdme

openerp/addons/base/ir/ir_model.py
openerp/addons/base/res/partner/partner.py
openerp/addons/base/res/res_company.py
openerp/addons/base/res/res_currency.py

index d3dfd98..add19f6 100644 (file)
@@ -97,7 +97,9 @@ class ir_model(osv.osv):
         'modules': fields.function(_in_modules, method=True, type='char', size=128, string='In modules', help='List of modules in which the object is defined or inherited'),
         'view_ids': fields.function(_view_ids, method=True, type='one2many', obj='ir.ui.view', string='Views'),
     }
-    
+    _sql_constraints = [
+        ('obj_name_uniq', 'unique (name)', 'The object name must be unique !'),
+    ]
     _defaults = {
         'model': lambda *a: 'x_',
         'state': lambda self,cr,uid,ctx=None: (ctx and ctx.get('manual',False)) and 'manual' or 'base',
index 091927f..0eed895 100644 (file)
@@ -434,7 +434,7 @@ class res_partner_bank(osv.osv):
         'state_id': lambda obj, cursor, user, context: obj._default_value(
             cursor, user, 'state_id', context=context),
     }
-
+    
     def fields_get(self, cr, uid, fields=None, context=None):
         res = super(res_partner_bank, self).fields_get(cr, uid, fields, context)
         bank_type_obj = self.pool.get('res.partner.bank.type')
index 14ef531..3e31401 100644 (file)
@@ -127,6 +127,9 @@ class res_company(osv.osv):
         'email': fields.function(_get_address_data, fnct_inv=_set_address_data, size=64, type='char', string="Email", multi='address'), 
         'phone': fields.function(_get_address_data, fnct_inv=_set_address_data, size=64, type='char', string="Phone", multi='address'), 
     }
+    _sql_constraints = [
+        ('com_name_uniq', 'unique (name)', 'The company name must be unique !')
+    ]
 
     def _search(self, cr, uid, args, offset=0, limit=None, order=None,
             context=None, count=False, access_rights_uid=None):
index d81248a..6005ea8 100644 (file)
@@ -65,6 +65,9 @@ class res_currency(osv.osv):
         'active': lambda *a: 1,
         'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'res.currency', context=c)
     }
+    _sql_constraints = [
+        ('currency_name_uniq', 'unique (name, company_id)', 'The currency code must be unique !'),
+    ]
     _order = "name"
 
     def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):