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

There are 2 applications, Application A and Application B. Application A is supported by Group A and Application B is supported by Group B. If tickets are created for Application A, only Group A can see those tickets. The same case that if tickets are created for Application B only Group B can see those tickets and if a user is a member of both groups then that user can see tickets for applications A and B.

    

    So how to create groups for this problem in odoo 8.0

    

    Code is shown below:

    

    python code:-

    

    def _get_groups_application(self, cr, uid, context=None):

            groups_obj = self.pool.get('res.groups')

            users_obj = self.pool.get('res.users')

            groups_ids = []

            admin_groups_ids1 = groups_obj.search(cr, uid, [('name', '=', 'Helpdesk/ApplicationA')])

            admin_groups_ids2 = groups_obj.search(cr, uid, [('name', '=', 'Helpdesk/ApplicationB')])

            users = users_obj.browse(cr, uid, uid, context=context)

            for group in users.groups_id:

                groups_ids.append(group.id)

            try:

                if (admin_groups_ids1[0] in groups_ids):

                    groups = 'ApplicationA'

                if (admin_groups_ids2[0] in groups_ids):

                    groups = 'ApplicationB'

                if (admin_groups_ids1[0] in groups_ids) or (admin_groups_ids2[0] in groups_ids):

                    groups = 'Both'

                else:

                    groups = 'None'

            except Exception, e:

                print "Group Exception", e

                groups = 'None'

            print "groups:", groups

            return groups

     

   def _check_group(self, cr, uid, ids, field_name, arg, context):

        res = {}

        for i in ids:

            if not i:

                continue

            groups = self._get_groups(cr, uid, context=None)

            # print ids, groups

            res[i] = groups

        return res

                # print ids, groups

                res[i] = groups

            return res

     

    _columns = {

            'application': fields.function(_check_group_application, method=True, string='Application', type='char')

    }

    

    XML Code:-

    <field name="application"/>`enter code here`

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

To restrict you need to create record rule, so the user can see own group records only. You can refer sales "Own Lead" rule.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
يوليو 17
3638
3
فبراير 18
6023
2
يوليو 16
3532
2
سبتمبر 23
5382
12
أكتوبر 23
36416