From 4fa6d9093de6054840ea30e3b330ee85a1332e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 19 Oct 2024 23:48:53 +0200 Subject: [PATCH] Do not autocomplete postal code nor city with empty value None value prevents to sort the result and empty value does not add information. Closes #13482 --- modules/party/address.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/party/address.py b/modules/party/address.py index 506f64c00e..a663cb021c 100644 --- a/modules/party/address.py +++ b/modules/party/address.py @@ -124,14 +124,20 @@ class Address( @fields.depends('city', methods=['_autocomplete_domain']) def autocomplete_postal_code(self): - domain = self._autocomplete_domain() + domain = [ + self._autocomplete_domain(), + ('postal_code', 'not in', [None, '']), + ] if self.city: domain.append(('city', 'ilike', '%%%s%%' % self.city)) return self._autocomplete_search(domain, 'postal_code') @fields.depends('postal_code', methods=['_autocomplete_domain']) def autocomplete_city(self): - domain = self._autocomplete_domain() + domain = [ + self._autocomplete_domain(), + ('city', 'not in', [None, '']), + ] if self.postal_code: domain.append(('postal_code', 'ilike', '%s%%' % self.postal_code)) return self._autocomplete_search(domain, 'city')