تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
13374 أدوات العرض

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.

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
3
يوليو 15
33120
1
يونيو 22
7342
0
ديسمبر 16
5318
1
يناير 21
16961
5
سبتمبر 20
12804