Browse Source

[FIX] Allow to search on non-stored field "any_partner_id" by adding a search method into the fields' declaration

pull/175/head
Jonathan Nemry (ACSONE) 9 years ago
parent
commit
337b9dd4d1
  1. 8
      partner_relations/model/res_partner_relation.py
  2. 2
      partner_relations/view/res_partner_relation.xml

8
partner_relations/model/res_partner_relation.py

@ -41,6 +41,13 @@ class ResPartnerRelation(models.Model):
_description = 'Partner relation'
_order = 'active desc, date_start desc, date_end desc'
def _search_any_partner_id(self, operator, value):
return [
'|',
('left_partner_id', operator, value),
('right_partner_id', operator, value),
]
def _get_computed_fields(
self, cr, uid, ids, field_names, arg, context=None):
'''Return a dictionary of dictionaries, with for every partner for
@ -101,6 +108,7 @@ class ResPartnerRelation(models.Model):
'res.partner',
string='Partner',
compute='_get_partner_type_any',
search='_search_any_partner_id'
)
left_partner_id = fields.Many2one(

2
partner_relations/view/res_partner_relation.xml

@ -46,7 +46,7 @@
<field name="model">res.partner.relation</field>
<field name="arch" type="xml">
<search string="Search Relations">
<field name="any_partner_id"/>
<field name="any_partner_id" widget="many2one"/>
<field name="left_partner_id"/>
<field name="right_partner_id"/>
<field name="type_id"/>

Loading…
Cancel
Save