def _report_variables(self, line): result = {} if line.report_type == 'pentaho': # attempt to fill the prompt wizard as if we had gone in to it from a menu and then run. promptwizard_obj = self.env['ir.actions.report.promptwizard'] # default_get creates a dictionary of wizard default values values = promptwizard_obj.default_get_external(line.report_id.id) # this hook is provided to allow for selection set values, which are not necessarily installed values.update(self._check_overriding_values(line, values)) if values: # now convert virtual screen values from prompt wizard to values which can be passed to the report action result = { 'output_type': values.get('output_type'), 'variables': {} } parameters = json.loads(values.get('parameters_dictionary')) for index in range(0, len(parameters)): result['variables'][parameters[index][ 'variable']] = promptwizard_obj.decode_wizard_value( parameters, index, values[parameter_resolve_column_name( parameters, index)]) return result
def default_get(self, fields): if not self.env.context.get('active_id'): raise UserError(_('No active id passed.')) screen_wizard = self.env['ir.actions.report.promptwizard'].browse( self.env.context['active_id']) parameters_dictionary = json.loads(screen_wizard.parameters_dictionary) res = super(store_selections_wizard, self).default_get(fields) res.update({ 'existing_selectionset_id': screen_wizard.selectionset_id.id, 'name': screen_wizard.selectionset_id.name, 'report_action_id': screen_wizard.report_action_id.id, 'output_type': screen_wizard.output_type, 'parameters_dictionary': screen_wizard.parameters_dictionary, 'detail_ids': [], 'def_user_ids': [], 'def_group_ids': [], 'passing_wizard_id': screen_wizard.id, }) for index in range(0, len(parameters_dictionary)): res['detail_ids'].append((0, 0, { 'variable': parameters_dictionary[index]['variable'], 'label': parameters_dictionary[index]['label'], 'counter': index, 'type': parameters_dictionary[index]['type'], 'x2m': parameter_can_2m(parameters_dictionary, index), 'display_value': self.env['ir.actions.report.set.detail']. wizard_value_to_display( getattr( screen_wizard, parameter_resolve_column_name(parameters_dictionary, index)), parameters_dictionary, index), 'calc_formula': getattr( screen_wizard, parameter_resolve_formula_column_name( parameters_dictionary, index)), })) if screen_wizard.selectionset_id: res['def_user_ids'] = [ (6, 0, [u.id for u in screen_wizard.selectionset_id.def_user_ids]) ] res['def_group_ids'] = [ (6, 0, [g.id for g in screen_wizard.selectionset_id.def_group_ids]) ] return res
def _report_variables(self, cr, uid, line, context=None): result = {} if line.report_type == 'pentaho': # attempt to fill the prompt wizard as if we had gone in to it from a menu and then run. promptwizard_obj = self.pool.get('ir.actions.report.promptwizard') # default_get creates a dictionary of wizard default values values = promptwizard_obj.default_get_external(cr, uid, line.report_id.id, context=context) # this hook is provided to allow for selection set values, which are not necessarily installed values.update(self._check_overriding_values(cr, uid, line, values, context=context)) if values: # now convert virtual screen values from prompt wizard to values which can be passed to the report action result = {'output_type': values.get('output_type'), 'variables': {}} parameters = json.loads(values.get('parameters_dictionary')) for index in range(0, len(parameters)): result['variables'][parameters[index]['variable']] = promptwizard_obj.decode_wizard_value(cr, uid, parameters, index, values[parameter_resolve_column_name(parameters, index)], context=context) return result
def default_get(self, cr, uid, fields, context=None): if context is None: context = {} if not context.get('active_id'): raise except_orm(_('Error'), _('No active id passed.')) screen_wizard_obj = self.pool.get('ir.actions.report.promptwizard') detail_obj = self.pool.get('ir.actions.report.set.detail') screen_wizard = screen_wizard_obj.browse(cr, uid, context['active_id']) parameters_dictionary = json.loads(screen_wizard.parameters_dictionary) res = super(store_selections_wizard, self).default_get(cr, uid, fields, context=context) res.update({'existing_selectionset_id': screen_wizard.selectionset_id.id, 'name': screen_wizard.selectionset_id and screen_wizard.selectionset_id.name or '', 'report_action_id': screen_wizard.report_action_id.id, 'output_type': screen_wizard.output_type, 'parameters_dictionary': screen_wizard.parameters_dictionary, 'detail_ids': [], 'def_user_ids': [], 'def_group_ids': [], 'passing_wizard_id': screen_wizard.id, }) for index in range(0, len(parameters_dictionary)): res['detail_ids'].append((0, 0, {'variable': parameters_dictionary[index]['variable'], 'label': parameters_dictionary[index]['label'], 'counter': index, 'type': parameters_dictionary[index]['type'], 'x2m': parameter_can_2m(parameters_dictionary, index), 'display_value': detail_obj.wizard_value_to_display(cr, uid, getattr(screen_wizard, parameter_resolve_column_name(parameters_dictionary, index)), parameters_dictionary, index, context=context), 'calc_formula': getattr(screen_wizard, parameter_resolve_formula_column_name(parameters_dictionary, index)), })) if screen_wizard.selectionset_id: res['def_user_ids'] = [(6, 0, [u.id for u in screen_wizard.selectionset_id.def_user_ids])] res['def_group_ids'] = [(6, 0, [g.id for g in screen_wizard.selectionset_id.def_group_ids])] return res
def default_get(self, cr, uid, fields, context=None): if context is None: context = {} if not context.get('active_id'): raise orm.except_orm(_('Error'), _('No active id passed.')) screen_wizard_obj = self.pool.get('ir.actions.report.promptwizard') detail_obj = self.pool.get('ir.actions.report.set.detail') screen_wizard = screen_wizard_obj.browse(cr, uid, context['active_id']) parameters_dictionary = json.loads(screen_wizard.parameters_dictionary) res = super(store_selections_wizard, self).default_get(cr, uid, fields, context=context) res.update({ 'existing_selectionset_id': screen_wizard.selectionset_id.id, 'name': screen_wizard.selectionset_id and screen_wizard.selectionset_id.name or '', 'report_action_id': screen_wizard.report_action_id.id, 'output_type': screen_wizard.output_type, 'parameters_dictionary': screen_wizard.parameters_dictionary, 'detail_ids': [], 'def_user_ids': [], 'def_group_ids': [], 'passing_wizard_id': screen_wizard.id, }) for index in range(0, len(parameters_dictionary)): res['detail_ids'].append((0, 0, { 'variable': parameters_dictionary[index]['variable'], 'label': parameters_dictionary[index]['label'], 'counter': index, 'type': parameters_dictionary[index]['type'], 'x2m': parameter_can_2m(parameters_dictionary, index), 'display_value': detail_obj.wizard_value_to_display( cr, uid, getattr( screen_wizard, parameter_resolve_column_name(parameters_dictionary, index)), parameters_dictionary, index, context=context), 'calc_formula': getattr( screen_wizard, parameter_resolve_formula_column_name( parameters_dictionary, index)), })) if screen_wizard.selectionset_id: res['def_user_ids'] = [ (6, 0, [u.id for u in screen_wizard.selectionset_id.def_user_ids]) ] res['def_group_ids'] = [ (6, 0, [g.id for g in screen_wizard.selectionset_id.def_group_ids]) ] return res