Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to apply the domain of the user's selection in OpenERP?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 148
    Comment on it

    In OpenERP first we create the user's in user form. Then the user clicks the selection's icon in the web client, compose a default action for the model in the user's selection and  Return the action that contains all of this and valid for the web client.

    Use this function given below

    def action_usr(self, cr, uid, context=None):
        
            if context is None:
                context = {}
            res = False
    
            selection_id = False
            me = self.pool.get('res.users').read(
                cr, uid, uid, ['saved_selection_id'], context=context)
            if me['saved_selection_id']:
                selection_id = me['saved_selection_id'][0]
                selection = self.read(
                    cr, uid, selection_id, ['model_id', 'ids', 'name'], context)
                model = self.pool.get('ir.model').read(
                    cr, uid, selection['model_id'][0], ['model'], context
                    )['model']
                context['active_id'] = False
                context['active_ids'] = False
                context['active_model'] = model
                res = {
                    'domain': [('id', 'in',
                                selection['ids'] and
                                [int(x) for x in selection['ids'].split(',')] or []
                                )],
                    'name': (_('Saved Selection') + 
                             (selection['name'] and (' %s' % selection['name']) or '') +
                             ' (' + selection['model_id'][1] + ')'),
                    'res_model': model,
                    'views': [(False, view_type) for view_type in 
                              ('list', 'page', 'form')],
                    'type': 'ir.actions.act_window',
                    'target': 'current',
                    'limit': 80,
                    'auto_search': True,
                    'is_saved_selection': True,
                    }
            return res
    

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: