Improve search_vat_code

- Use where clause to ensure to test code and type of the same record
- Add party without code for clause that match with None

issue5679
review28441002
This commit is contained in:
Cédric Krier committed 2016-07-11 18:26:02 +02:00
1 parent 589bd2cd49
commit e538f73d4f
1 file changed
+17 -3
+17 -3
View File
@@ -136,10 +136,24 @@ class Party(ModelSQL, ModelView):
@classmethod
def search_vat_code(cls, name, clause):
return [
('identifiers.code',) + tuple(clause[1:]),
('identifiers.type', 'in', cls._vat_types()),
_, operator, value = clause
domain = [
('identifiers', 'where', [
('code', operator, value),
('type', 'in', cls._vat_types()),
]),
]
# Add party without vat code
if ((operator == '=' and value is None)
or (operator == 'in' and None in value)):
domain = ['OR',
domain, [
('identifiers', 'not where', [
('type', 'in', cls._vat_types()),
]),
],
]
return domain
def get_full_name(self, name):
return self.name