Commit ead2b499 authored by Cédric Krier's avatar Cédric Krier
Browse files

Support None as search value of composite rec_name

parent 38c0a7d9d64b
......@@ -690,11 +690,18 @@
@classmethod
def search_rec_name(cls, name, clause):
names = clause[2].split(' - ', 1)
res = [('number', clause[1], names[0])]
if len(names) != 1 and names[1]:
res.append(('product', clause[1], names[1]))
return res
domain = []
_, operator, value = clause
if value is not None:
names = value.split(' - ', 1)
domain.append(('number', operator, value))
if len(names) != 1 and names[1]:
domain.append(('product', operator, value))
if operator.startswith('!') or operator.startswith('not'):
domain.insert(0, 'OR')
elif not operator.startswith('!') and not operator.startswith('not'):
domain.append(('id', '<', 0))
return domain
@classmethod
def copy(cls, assets, default=None):
......
......@@ -200,14 +200,22 @@
@classmethod
def search_rec_name(cls, name, clause):
res = []
names = clause[2].split('@', 1)
res.append(('product.template.name', clause[1], names[0]))
if len(names) != 1 and names[1]:
res.append(('warehouse', clause[1], names[1]))
return ['OR', res,
('description',) + tuple(clause[1:]),
]
_, operator, value = clause
if operator.startswith('!') or operator.startswith('not'):
bool_op = 'AND'
else:
bool_op = 'OR'
domain = [bool_op]
if value is not None:
names = value.split('@', 1)
sub_domain = [('product.template.name', operator, names[0])]
if len(names) != 1 and names[1]:
sub_domain.append(('warehouse', operator, names[1]))
if bool_op == 'AND':
sub_domain.insert(0, 'OR')
domain.append(sub_domain)
domain.append(('description', *clause[1:]))
return domain
@staticmethod
def default_company():
......
......@@ -388,11 +388,18 @@
@classmethod
def search_rec_name(cls, name, clause):
names = clause[2].split(' - ', 1)
res = [('quotation', clause[1], names[0])]
if len(names) != 1 and names[1]:
res.append(('supplier', clause[1], names[1]))
return res
domain = []
_, operator, value = clause
if value is not None:
names = clause[2].split(' - ', 1)
domain.append(('quotation', operator, names[0]))
if len(names) != 1 and names[1]:
domain.append(('supplier', operator, names[1]))
if operator.startswith('!') or operator.startswith('not'):
domain.insert(0, 'OR')
elif not operator.startswith('!') and not operator.startswith('not'):
domain.append(('id', '<', 0))
return domain
@classmethod
def delete(cls, quotationlines):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment