Search party by company in case found some companies

#162919
This commit is contained in:
Raimon Esteve 2023-10-19 14:44:24 +02:00
parent 7960bf0403
commit cc6bbaf009
1 changed files with 2 additions and 2 deletions

View File

@ -197,9 +197,9 @@ class Party(metaclass=PoolMeta):
companies = Company.search([
('party.name', clause[1], clause[2]),
])
if clause[1] == 'ilike' or clause[1] == '=':
if companies and (clause[1] == 'ilike' or clause[1] == '='):
sql_where = party_company.company.in_([c.id for c in companies])
elif clause[1] == 'not ilike' or clause[1] == '!=':
elif companies and (clause[1] == 'not ilike' or clause[1] == '!='):
sql_where = ~party_company.company.in_([c.id for c in companies])
else:
return [('id', 'in', [])]