[IMP][REF]CRM Action : for ation view, now see parent and all childs in domain

This commit is contained in:
Fabien BOURGEOIS 2017-11-29 05:27:29 +01:00
parent 2c9d7cd506
commit 9377e6fe65
2 changed files with 8 additions and 9 deletions

View File

@ -18,7 +18,7 @@
{ {
'name': 'CRM Actions', 'name': 'CRM Actions',
'summary': 'Action management, instead of new activity, in CRM', 'summary': 'Action management, instead of new activity, in CRM',
'version': '10.0.1.3.0', 'version': '10.0.1.3.1',
'category': 'Sales', 'category': 'Sales',
'author': 'Fabien BOURGEOIS - Yaltik', 'author': 'Fabien BOURGEOIS - Yaltik',
'license': 'AGPL-3', 'license': 'AGPL-3',

View File

@ -47,16 +47,15 @@ class ResPartner(models.Model):
@api.model @api.model
def partner_actions(self): def partner_actions(self):
""" Return action for active partner and its parent """ """ Return action for active partner and its parent and childs """
active_id = self._context.get('active_id') active_id = self._context.get('active_id')
partner = self.env['res.partner'].browse(active_id) partner = self.env['res.partner'].browse(active_id)
domain = [('partner_id', '=', partner.id)] if partner.parent_id:
if partner.parent_id or partner.child_ids: partner_ids = [partner.parent_id.id] + partner.parent_id.child_ids.ids
domain.insert(0, '|') domain = [('partner_id', 'in', partner_ids)]
if partner.parent_id: elif partner.child_ids:
domain.append(('partner_id', '=', partner.parent_id.id)) partner_ids = [partner.id] + partner.child_ids.ids
elif partner.child_ids: domain = [('partner_id', 'in', partner_ids)]
domain.append(('partner_id', 'in', partner.child_ids.ids))
return {'type': 'ir.actions.act_window', return {'type': 'ir.actions.act_window',
'name': _('Actions'), 'name': _('Actions'),