Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
3368 Vizualizări

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`

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
iul. 17
3474
3
feb. 18
5869
2
iul. 16
3354
2
sept. 23
5196
12
oct. 23
36225