Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
13424 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
3
Jul 15
33160
1
Jun 22
7410
0
Des 16
5356
1
Jan 21
17017
5
Sep 20
12833