Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3515 Lượt xem

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`

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 7 17
3619
3
thg 2 18
5993
2
thg 7 16
3508
2
thg 9 23
5367
12
thg 10 23
36392