Skip to Content
मेन्यू
This question has been flagged
1 Reply
3319 Views

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`

Avatar
Discard
Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
0
जुल॰ 17
3430
3
फ़र॰ 18
5794
2
जुल॰ 16
3302
2
सित॰ 23
5061
12
अक्तू॰ 23
36132