Onchange method update virtual field value

I am working on odoo v8 and I am trying to change the representation of permissions in a user form. I want to change the form so that when choosing a role for each category of modules, it calls the onchange method and updates the checkboxes below (technical parameters, usability, etc.). The changes will appear only after saving the form. But I want it to update onfly to check the administrator before saving to the database. But it seems that when I return the dict from the onchange method, the system does not know about the existence of the field (for example, virtual fields such as in_group_1, in_group_2, etc.). Is there any way to do this?

@api.v7
def check_acl(self, cr, uid, ids, my_field, context=None):
  return {'value': {'in_group_1': True}} 
+4
source share
1 answer

You can check it by administrator or not by this function

 def check_user(self, uid=None):
        if uid is None:
            uid = request.uid
        is_admin = request.registry['res.users']._is_admin(request.cr, uid, [uid])
        if not is_admin:
            raise openerp.exceptions.AccessError("Only administrators can upload a module")

and call this function with arguments such as:

uid = request.session.authenticate(request.db, login, password) 
self.check_user(uid)

and you can use this function in your onchange

@api.v7
def check_acl(self, cr, uid, ids, my_field, context=None):
   if self.check_user(uid):
       return {'value': {'in_group_1': True}} 
0
source

All Articles