Skip to Content
Menu
This question has been flagged
1 Odpoveď
13358 Zobrazenia

Hi,

As known the customer can have multiple contacts. The contacts are created by the different users. I would like to make a filter that works in the following way logged-in user can see all the customers but not all the contacts of that particular customer (shown in kanban view down in the customer view). He can only see the contacts created by him. So I applied domain filter in the child_ids(type = one2many) field.

I tried the below possibilities but not succeeded yet.

Try 1: XML

<field name="child_ids" domain="[('create_uid', '=', context.get('uid'))]" context="{'default_parent_id': active_id}" mode="kanban">

Try 2: Python

'child_ids': fields.one2many('res.partner', 'parent_id', 'Contacts', domain="[('create_uid', '=', context.get('uid'))]"),

Try 3: Fields_view_get method

def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
    if (not view_id) and (view_type=='form') and context and context.get('force_email', False):
        view_id = self.pool.get('ir.model.data').get_object_reference(cr, user, 'base', 'view_partner_simple_form')[1]
    res = super(res_partner,self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)

    if view_type == 'form':
        res['arch'] = self.fields_view_get_address(cr, user, res['arch'], context=context)
    eview = etree.fromstring(res['arch'])
    if view_type:
        for node in eview.xpath("//field[@name='child_ids']"):
            user_filter =  "[('create_uid', '='," + str(user) + " )]"
            node.set('domain',user_filter)
    res['arch'] = etree.tostring(eview)
    return res

Kindly clarify me with this regard. Thanks a lot for your time.

Avatar
Zrušiť
Best Answer

You may try this: Create a record rules Object: res.partner Use this Rule definition (Domain Filter): ['|', ('parent_id', '=', False ), ('create_uid', '=', user.id)] In the "Acces Rights" section: check all

Best Regards

Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
3
júl 15
33103
1
jún 22
7322
0
dec 16
5307
1
jan 21
16935
5
sep 20
12778