Browse Source

[FIX] Context Errors With Active ID

[IMP] Flake8
12.0
scampbell 5 years ago
parent
commit
3ab9e244bc
  1. 20
      partner_multi_relation/models/res_partner.py
  2. 24
      partner_multi_relation/views/res_partner.xml

20
partner_multi_relation/models/res_partner.py

@ -171,3 +171,23 @@ 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_ids = self.env['res.partner.relation.all'].\
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['context'] = {}
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