Browse Source

Merge PR #866 into 12.0

Signed-off-by max3903
12.0
OCA-git-bot 5 years ago
parent
commit
380df4c66c
  1. 21
      partner_multi_relation/models/res_partner.py
  2. 24
      partner_multi_relation/views/res_partner.xml

21
partner_multi_relation/models/res_partner.py

@ -171,3 +171,24 @@ class ResPartner(models.Model):
"""
self.ensure_one()
return 'c' if self.is_company else 'p'
@api.multi
def action_view_relations(self):
for contact in self:
relation_model = self.env['res.partner.relation.all']
relation_ids = relation_model.\
search(['|',
('this_partner_id', '=', contact.id),
('other_partner_id', '=', contact.id)])
action = self.env.ref(
'partner_multi_relation.action_res_partner_relation_all'
).read()[0]
action['domain'] = [('id', 'in', relation_ids.ids)]
action['context'].\
update({'search_default_this_partner_id': contact.id,
'default_this_partner_id': contact.id,
'active_model': 'res.partner',
'active_id': contact.id,
'active_ids': [contact.id],
'active_test': False})
return action

24
partner_multi_relation/views/res_partner.xml

@ -21,25 +21,13 @@
<field name="model">res.partner</field>
<field type="xml" name="arch">
<xpath expr="//div[@name='button_box']" position="inside">
<button
class="oe_inline oe_stat_button"
type="action"
context="{
'search_default_this_partner_id': active_id,
'default_this_partner_id': active_id,
'active_model': 'res.partner',
'active_id': id,
'active_ids': [id],
'active_test': False,
}"
name="%(action_res_partner_relation_all)d"
icon="fa-users"
>
<field
string="Relations"
name="relation_count"
<button name="action_view_relations"
type="object"
class="oe_stat_button"
icon="fa-users">
<field name="relation_count"
widget="statinfo"
/>
string="Relations"/>
</button>
</xpath>
</field>

Loading…
Cancel
Save