Skip to Content
Menu
This question has been flagged
1 Odpoveď
3410 Zobrazenia

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
Zrušiť
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
Zrušiť
Related Posts Replies Zobrazenia Aktivita
0
júl 17
3502
3
feb 18
5878
2
júl 16
3369
2
sep 23
5226
12
okt 23
36257