Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
13416 Zobrazení

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šit
Nejlepší odpověď

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šit
Related Posts Odpovědi Zobrazení Aktivita
3
čvc 15
33155
1
čvn 22
7402
0
pro 16
5352
1
led 21
17012
5
zář 20
12831