Fix when searching for location across different type of order points
This commit is contained in:
1 parent
4da8e3f342
commit
bf4eb6c9ab
1 file changed
+10
-8
+10
-8
@@ -84,11 +84,13 @@ class OrderPoint(OSV):
|
||||
ids = self.search(cursor, user, query)
|
||||
return not bool(ids)
|
||||
|
||||
def check_uniqueness_field(self, type):
|
||||
if type == 'purchase':
|
||||
return 'warehouse_location'
|
||||
elif type == 'internal':
|
||||
return 'storage_location'
|
||||
def type2field(self, type=None):
|
||||
t2f = (('warehouse_location', 'purchase'),
|
||||
('storage_location', 'internal'))
|
||||
if type == None:
|
||||
return t2f
|
||||
else:
|
||||
return dict(t2f)[type]
|
||||
|
||||
def check_uniqueness(self, cursor, user, ids):
|
||||
"""
|
||||
@@ -98,7 +100,7 @@ class OrderPoint(OSV):
|
||||
"""
|
||||
query = ['OR']
|
||||
for op in self.browse(cursor, user, ids):
|
||||
field = self.check_uniqueness_field(op.type)
|
||||
field = self.type2field(op.type)
|
||||
arg = ['AND',
|
||||
(field, '=', op[field].id),
|
||||
('id', '!=', op.id),
|
||||
@@ -135,8 +137,8 @@ class OrderPoint(OSV):
|
||||
|
||||
def search_location(self, cursor, user, name, domain=None, context=None):
|
||||
ids = []
|
||||
for field in ('warehouse_location', 'storage_location'):
|
||||
args = []
|
||||
for field, type in self.type2field():
|
||||
args = [('type', '=', type)]
|
||||
for _, operator, operand in domain:
|
||||
args.append((field, operator, operand))
|
||||
ids.extend(self.search(cursor, user, args, context=context))
|
||||
|
||||
Reference in new issue
Block a user