def record_objects(self, cr, uid, ids, context=None):
        data = self.read(cr, uid, ids, [], context=context)[0]
        check_date=data['check_date']
        filter=data['filter_cond']
        user=(self.pool.get('res.users').browse(cr,uid,uid)).login
        mod = self.pool.get('ir.module.record')
        mod_obj = self.pool.get('ir.model')
        mod.recording_data = []
        for id in data['objects']:
            obj_name=(mod_obj.browse(cr,uid,id)).model
            obj_pool=self.pool.get(obj_name)
            if filter =='created':
                search_condition =[('create_date', '>', check_date)]
            elif filter =='modified':
                search_condition =[('write_date', '>', check_date)]
            elif filter =='created_modified':
                search_condition =['|',('create_date', '>', check_date), ('write_date', '>', check_date)]
            if '_log_access' in dir(obj_pool):
                  if not (obj_pool._log_access):
                      search_condition=[]
                  if '_auto' in dir(obj_pool):
                      if not obj_pool._auto:
                          continue
            search_ids = obj_pool.search(cr,uid,search_condition)
            for s_id in search_ids:
                 args=(cr.dbname, uid,obj_name, 'copy', s_id,{},context)
                 mod.recording_data.append(('query', args, {}, s_id))
         
        mod_obj = self.pool.get('ir.model.data')
        if len(mod.recording_data):
            if data['info_yaml']:
                mod = self.pool.get('ir.module.record')
                res=base_module_save._create_yaml(self, cr, uid, data, context)
                model_data_ids = mod_obj.search(cr, uid,[('model', '=', 'ir.ui.view'), ('name', '=', 'yml_save_form_view')], context=context)
                resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
                return {
                    'name': _('Message'),
                    'context': {'default_yaml_file': tools.ustr(res['yaml_file'])},
                    'view_type': 'form',
                    'view_mode': 'form',
                    'res_model': 'base.module.record.objects',
                    'views': [(resource_id, 'form')],
                    'type': 'ir.actions.act_window',
                    'target': 'new',
                }
            else:
                model_data_ids = mod_obj.search(cr, uid, [('model', '=', 'ir.ui.view'), ('name', '=', 'info_start_form_view')], context=context)
                resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
                return {
                    'name': _('Message'),
                    'context': context,
                    'view_type': 'form',
                    'view_mode': 'form',
                    'res_model': 'base.module.record.objects',
                    'views': [(resource_id, 'form')],
                    'type': 'ir.actions.act_window',
                    'target': 'new',
                }

        model_data_ids = mod_obj.search(cr, uid, [('model', '=', 'ir.ui.view'), ('name', '=', 'module_recording_message_view')], context=context)
        resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
        return {
            'name': _('Message'),
            'context': context,
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'base.module.record.objects',
            'views': [(resource_id, 'form')],
            'type': 'ir.actions.act_window',
            'target': 'new',
        }      
Пример #2
0
 def record_objects(self):
     data = self.read([])[0]
     check_date = data['check_date']
     filter_cond = data['filter_cond']
     #        user = (self.env['res.users'].browse(self.env.user.id)).login
     #        mod = self.env['ir.module.record']
     mod_obj = self.env['ir.model']
     #        mod.recording_data = []
     cr, uid, context = self.env.args
     context = dict(context)
     context.update({'recording_data': []})
     recording_data = context.get('recording_data')
     self.env.args = cr, uid, frozendict(context)
     for obj_id in data['objects']:
         obj_name = (mod_obj.browse(obj_id)).model
         obj_pool = self.env[obj_name]
         if filter_cond == 'created':
             search_condition = [('create_date', '>', check_date)]
         elif filter_cond == 'modified':
             search_condition = [('write_date', '>', check_date)]
         elif filter_cond == 'created_modified':
             search_condition = [
                 '|', ('create_date', '>', check_date),
                 ('write_date', '>', check_date)
             ]
         if '_log_access' in dir(obj_pool):
             if not (obj_pool._log_access):
                 search_condition = []
             if '_auto' in dir(obj_pool):
                 if not obj_pool._auto:
                     continue
         search_ids = obj_pool.search(search_condition)
         for s_id in search_ids:
             dbname = self.env.cr.dbname
             args = (dbname, self.env.user.id, obj_name, 'copy', s_id.id,
                     {})
             recording_data.append(('query', args, {}, s_id.id))
     mod_obj = self.env['ir.model.data']
     if len(recording_data):
         if data['info_yaml']:
             #                mod = self.env['ir.module.record']
             res = base_module_save._create_yaml(self, data)
             model_data_ids = mod_obj.search([('model', '=', 'ir.ui.view'),
                                              ('name', '=',
                                               'yml_save_form_view')])
             resource_id = model_data_ids.read(['res_id'])[0]['res_id']
             return {
                 'name': _('Module Recording'),
                 'context': {
                     'default_yaml_file': ustr(res['yaml_file']),
                     'default_module_filename': 'demo_yaml.yml',
                 },
                 'view_type': 'form',
                 'view_mode': 'form',
                 'res_model': 'base.module.record.objects',
                 'views': [(resource_id, 'form')],
                 'type': 'ir.actions.act_window',
                 'target': 'new',
             }
         else:
             model_data_ids = mod_obj.search([('model', '=', 'ir.ui.view'),
                                              ('name', '=',
                                               'info_start_form_view')])
             resource_id = model_data_ids.read(['res_id'])[0]['res_id']
             return {
                 'name': _('Module Recording'),
                 'context': context,
                 'view_type': 'form',
                 'view_mode': 'form',
                 'res_model': 'base.module.record.objects',
                 'views': [(resource_id, 'form')],
                 'type': 'ir.actions.act_window',
                 'target': 'new',
             }
     model_data_ids = mod_obj.search([('model', '=', 'ir.ui.view'),
                                      ('name', '=',
                                       'module_recording_message_view')])
     resource_id = model_data_ids.read(['res_id'])[0]['res_id']
     return {
         'name': _('Module Recording'),
         'context': self.env.context,
         'view_type': 'form',
         'view_mode': 'form',
         'res_model': 'base.module.record.objects',
         'views': [(resource_id, 'form')],
         'type': 'ir.actions.act_window',
         'target': 'new',
     }
Пример #3
0
def _create_yaml(self, cr, uid, data, context):
    res = base_module_save._create_yaml(self, cr, uid, data, context)
    return res
    def record_objects(self, cr, uid, ids, context=None):
        data = self.read(cr, uid, ids, [], context=context)[0]
        check_date = data['check_date']
        filter = data['filter_cond']
        user = (self.pool.get('res.users').browse(cr, uid, uid)).login
        mod = self.pool.get('ir.module.record')
        mod_obj = self.pool.get('ir.model')
        mod.recording_data = []
        for id in data['objects']:
            obj_name = (mod_obj.browse(cr, uid, id)).model
            obj_pool = self.pool.get(obj_name)
            if filter == 'created':
                search_condition = [('create_date', '>', check_date)]
            elif filter == 'modified':
                search_condition = [('write_date', '>', check_date)]
            elif filter == 'created_modified':
                search_condition = [
                    '|', ('create_date', '>', check_date),
                    ('write_date', '>', check_date)
                ]
            if '_log_access' in dir(obj_pool):
                if not (obj_pool._log_access):
                    search_condition = []
                if '_auto' in dir(obj_pool):
                    if not obj_pool._auto:
                        continue
            search_ids = obj_pool.search(cr, uid, search_condition)
            for s_id in search_ids:
                args = (cr.dbname, uid, obj_name, 'copy', s_id, {}, context)
                mod.recording_data.append(('query', args, {}, s_id))

        mod_obj = self.pool.get('ir.model.data')
        if len(mod.recording_data):
            if data['info_yaml']:
                mod = self.pool.get('ir.module.record')
                res = base_module_save._create_yaml(self, cr, uid, data,
                                                    context)
                model_data_ids = mod_obj.search(
                    cr,
                    uid, [('model', '=', 'ir.ui.view'),
                          ('name', '=', 'yml_save_form_view')],
                    context=context)
                resource_id = mod_obj.read(cr,
                                           uid,
                                           model_data_ids,
                                           fields=['res_id'],
                                           context=context)[0]['res_id']
                return {
                    'name': _('Message'),
                    'context': {
                        'default_yaml_file': tools.ustr(res['yaml_file'])
                    },
                    'view_type': 'form',
                    'view_mode': 'form',
                    'res_model': 'base.module.record.objects',
                    'views': [(resource_id, 'form')],
                    'type': 'ir.actions.act_window',
                    'target': 'new',
                }
            else:
                model_data_ids = mod_obj.search(
                    cr,
                    uid, [('model', '=', 'ir.ui.view'),
                          ('name', '=', 'info_start_form_view')],
                    context=context)
                resource_id = mod_obj.read(cr,
                                           uid,
                                           model_data_ids,
                                           fields=['res_id'],
                                           context=context)[0]['res_id']
                return {
                    'name': _('Message'),
                    'context': context,
                    'view_type': 'form',
                    'view_mode': 'form',
                    'res_model': 'base.module.record.objects',
                    'views': [(resource_id, 'form')],
                    'type': 'ir.actions.act_window',
                    'target': 'new',
                }

        model_data_ids = mod_obj.search(
            cr,
            uid, [('model', '=', 'ir.ui.view'),
                  ('name', '=', 'module_recording_message_view')],
            context=context)
        resource_id = mod_obj.read(cr,
                                   uid,
                                   model_data_ids,
                                   fields=['res_id'],
                                   context=context)[0]['res_id']
        return {
            'name': _('Message'),
            'context': context,
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'base.module.record.objects',
            'views': [(resource_id, 'form')],
            'type': 'ir.actions.act_window',
            'target': 'new',
        }
    def record_objects(self):
        data = self.read([])[0]
        check_date = data['check_date']
        filter_cond = data['filter_cond']
#        user = (self.env['res.users'].browse(self.env.user.id)).login
#        mod = self.env['ir.module.record']
        mod_obj = self.env['ir.model']
#        mod.recording_data = []
        cr, uid, context = self.env.args
        context = dict(context)
        context.update({'recording_data': []})
        recording_data = context.get('recording_data')
        self.env.args = cr, uid, frozendict(context)
        for obj_id in data['objects']:
            obj_name = (mod_obj.browse(obj_id)).model
            obj_pool = self.env[obj_name]
            if filter_cond == 'created':
                search_condition = [('create_date', '>', check_date)]
            elif filter_cond == 'modified':
                search_condition = [('write_date', '>', check_date)]
            elif filter_cond == 'created_modified':
                search_condition = ['|', ('create_date', '>', check_date), ('write_date', '>', check_date)]
            if '_log_access' in dir(obj_pool):
                if not (obj_pool._log_access):
                    search_condition = []
                if '_auto' in dir(obj_pool):
                    if not obj_pool._auto:
                        continue
            search_ids = obj_pool.search(search_condition)
            for s_id in search_ids:
                dbname = self.env.cr.dbname
                args = (dbname, self.env.user.id, obj_name, 'copy', s_id.id, {})
                recording_data.append(('query', args, {}, s_id.id))
        mod_obj = self.env['ir.model.data']
        if len(recording_data):
            if data['info_yaml']:
#                mod = self.env['ir.module.record']
                res = base_module_save._create_yaml(self, data)
                model_data_ids = mod_obj.search([('model', '=', 'ir.ui.view'), ('name', '=', 'yml_save_form_view')])
                resource_id = model_data_ids.read(['res_id'])[0]['res_id']
                return {
                    'name': _('Module Recording'),
                    'context': {
                        'default_yaml_file': ustr(res['yaml_file']),
                        'default_module_filename': 'demo_yaml.yml',
                    },
                    'view_type': 'form',
                    'view_mode': 'form',
                    'res_model': 'base.module.record.objects',
                    'views': [(resource_id, 'form')],
                    'type': 'ir.actions.act_window',
                    'target': 'new',
                }
            else:
                model_data_ids = mod_obj.search([('model', '=', 'ir.ui.view'), ('name', '=', 'info_start_form_view')])
                resource_id = model_data_ids.read(['res_id'])[0]['res_id']
                return {
                    'name': _('Module Recording'),
                    'context': context,
                    'view_type': 'form',
                    'view_mode': 'form',
                    'res_model': 'base.module.record.objects',
                    'views': [(resource_id, 'form')],
                    'type': 'ir.actions.act_window',
                    'target': 'new',
                }
        model_data_ids = mod_obj.search([('model', '=', 'ir.ui.view'), ('name', '=', 'module_recording_message_view')])
        resource_id = model_data_ids.read(['res_id'])[0]['res_id']
        return {
            'name': _('Module Recording'),
            'context': self.env.context,
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'base.module.record.objects',
            'views': [(resource_id, 'form')],
            'type': 'ir.actions.act_window',
            'target': 'new',
        }
def _create_yaml(self, cr, uid, data, context):
    res = base_module_save._create_yaml(self, cr, uid, data, context)
    return res