Replace name_get, name_search with get_rec_name and search_rec_name
This commit is contained in:
1 parent
7e5392c1dc
commit
90506469da
1 file changed
+24
-22
+24
-22
@@ -27,18 +27,18 @@ class Country(OSV):
|
||||
]
|
||||
self._order.insert(0, ('code', 'ASC'))
|
||||
|
||||
def name_search(self, cr, user, name='', args=None, operator='ilike',
|
||||
context=None, limit=None):
|
||||
if not args:
|
||||
args=[]
|
||||
ids = False
|
||||
if len(name) <= 2:
|
||||
ids = self.search(cr, user, [('code', '=', name.upper())] + args,
|
||||
limit=limit, context=context)
|
||||
if not ids:
|
||||
ids = self.search(cr, user, [('name', operator, name)] + args,
|
||||
limit=limit, context=context)
|
||||
return self.name_get(cr, user, ids, context)
|
||||
def search_rec_name(self, cursor, user, name, args, context=None):
|
||||
args2 = []
|
||||
i = 0
|
||||
while i < len(args):
|
||||
ids = self.search(cursor, user, [('code', args[i][1], args[i][2])],
|
||||
limit=1, context=context)
|
||||
if len(ids):
|
||||
args2.append(('code', args[i][1], args[i][2]))
|
||||
else:
|
||||
args2.append((self._rec_name, args[i][1], args[i][2]))
|
||||
i += 1
|
||||
return args2
|
||||
|
||||
def create(self, cursor, user, vals, context=None):
|
||||
if 'code' in vals and vals['code']:
|
||||
@@ -157,16 +157,18 @@ class Subdivision(OSV):
|
||||
super(Subdivision, self).__init__()
|
||||
self._order.insert(0, ('code', 'ASC'))
|
||||
|
||||
def name_search(self, cr, user, name='', args=None, operator='ilike',
|
||||
context=None, limit=None):
|
||||
if not args:
|
||||
args=[]
|
||||
ids = self.search(cr, user, [('code', '=', name.upper())] + args,
|
||||
limit=limit, context=context)
|
||||
if not ids:
|
||||
ids = self.search(cr, user, [('name', operator, name)] + args,
|
||||
limit=limit, context=context)
|
||||
return self.name_get(cr, user, ids, context)
|
||||
def search_rec_name(self, cursor, user, name, args, context=None):
|
||||
args2 = []
|
||||
i = 0
|
||||
while i < len(args):
|
||||
ids = self.search(cursor, user, [('code', args[i][1], args[i][2])],
|
||||
limit=1, context=context)
|
||||
if len(ids):
|
||||
args2.append(('code', args[i][1], args[i][2]))
|
||||
else:
|
||||
args2.append((self._rec_name, args[i][1], args[i][2]))
|
||||
i += 1
|
||||
return args2
|
||||
|
||||
def create(self, cursor, user, vals, context=None):
|
||||
if 'code' in vals and vals['code']:
|
||||
|
||||
Reference in new issue
Block a user