[FIX] fix filtering partner on name and ref and not on email
This commit is contained in:
@@ -60,3 +60,15 @@ class Partner(models.Model):
|
||||
else:
|
||||
name_title = ' '.join([title, name_title])
|
||||
self.name_title = name_title
|
||||
|
||||
@api.model
|
||||
def name_search(self, name, args=None, operator='ilike', limit=100):
|
||||
if args is None:
|
||||
args = []
|
||||
if name:
|
||||
# only filter on name and ref not in email
|
||||
args += [
|
||||
'|', ('display_name', 'ilike', name), ('ref', 'ilike', name)]
|
||||
res = super(Partner, self).name_search(
|
||||
name, args=args, operator=operator, limit=limit)
|
||||
return [(pid, val.replace('\n', ' ')) for pid, val in res]
|
||||
|
||||
@@ -14,10 +14,20 @@
|
||||
<field name="phone" string="Phones"
|
||||
filter_domain="['|', ('phone', 'like', self), ('mobile', 'like', self)]"/>
|
||||
</field>
|
||||
<!-- Display the real field names of the search -->
|
||||
|
||||
<!-- We split the search of name, ref / email in two
|
||||
as searching in email can return a lot of unwanted result
|
||||
for exemple when you sell on marketplace and search for a customer
|
||||
amazon you will have all customer that have bought throught the marketplace -->
|
||||
|
||||
<field name="name" position="attributes">
|
||||
<attribute name="string">Name, Ref, Email</attribute>
|
||||
<attribute name="string">Name, Ref</attribute>
|
||||
<attribute name="filter_domain">['|', ('display_name','ilike',self), ('ref','=',self)]</attribute>
|
||||
</field>
|
||||
<field name="name" position="after">
|
||||
<field name="email"/>
|
||||
</field>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user