<commit_before># -*- encoding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
#    $Id$
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

import wizard
import osv
import pooler
import time
import base_module_save
info = '''<?xml version="1.0"?>
<form string="Module Recording">
    <label string="Thanks For using Module Recorder" colspan="4" align="0.0"/>
</form>'''

intro_start_form = '''<?xml version="1.0"?>
<form string="Objects Recording">
    <field name="check_date"/>
    <newline/>
    <field name="filter_cond"/>
    <separator string="Choose objects to record" colspan="4"/>
    <field name="objects" colspan="4" nolabel="1"/>

</form>'''

intro_start_fields = {
    'check_date':  {'string':"Record from Date",'type':'datetime','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S')},
    'objects':{'string': 'Objects', 'type': 'many2many', 'relation': 'ir.model', 'help': 'List of objects to be recorded'},
    'filter_cond':{'string':'Records only', 'type':'selection','selection':[('created','Created'),('modified','Modified'),('created_modified','Created & Modified')], 'required':True, 'default': lambda *args:'created'},

}

def _info_default(self, cr, uid, data, context):
     pool = pooler.get_pool(cr.dbname)
     mod = pool.get('ir.model')
     list=('ir.ui.view','ir.ui.menu','ir.model','ir.model.fields','ir.model.access',\
        'res.partner','res.partner.address','res.partner.category','workflow',\
        'workflow.activity','workflow.transition','ir.actions.server','ir.server.object.lines')
     data['form']['objects']=mod.search(cr,uid,[('model','in',list)])
     cr.execute('select max(create_date) from ir_model_data')
     c=(((cr.fetchone())[0]).partition('.'))[0]
     c = time.strptime(c,"%Y-%m-%d %H:%M:%S")
     sec=c.tm_sec + 1
     c=(c[0],c[1],c[2],c[3],c[4],sec,c[6],c[7],c[8])
     data['form']['check_date']=time.strftime("%Y-%m-%d %H:%M:%S",c)
     return data['form']

def _record_objects(self, cr, uid, data, context):
    check_date=data['form']['check_date']
    filter=data['form']['filter_cond']
    pool = pooler.get_pool(cr.dbname)
    user=(pool.get('res.users').browse(cr,uid,uid)).login
    mod = pool.get('ir.module.record')
    mod_obj = pool.get('ir.model')

    for id in data['form']['objects'][0][2]:
        obj_name=(mod_obj.browse(cr,uid,id)).model
        obj_pool=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<commit_msg>bugfix<commit_after># -*- encoding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
#    $Id$
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

import wizard
import osv
import pooler
import time
import base_module_save
info = '''<?xml version="1.0"?>
<form string="Module Recording">
    <label string="Thanks For using Module Recorder" colspan="4" align="0.0"/>
</form>'''

intro_start_form = '''<?xml version="1.0"?>
<form string="Objects Recording">
    <field name="check_date"/>
    <newline/>
    <field name="filter_cond"/>
    <separator string="Choose objects to record" colspan="4"/>
    <field name="objects" colspan="4" nolabel="1"/>

</form>'''

intro_start_fields = {
    'check_date':  {'string':"Record from Date",'type':'datetime','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S')},
    'objects':{'string': 'Objects', 'type': 'many2many', 'relation': 'ir.model', 'help': 'List of objects to be recorded'},
    'filter_cond':{'string':'Records only', 'type':'selection','selection':[('created','Created'),('modified','Modified'),('created_modified','Created & Modified')], 'required':True, 'default': lambda *args:'created'},

}

def _info_default(self, cr, uid, data, context):
     pool = pooler.get_pool(cr.dbname)
     mod = pool.get('ir.model')
     list=('ir.ui.view','ir.ui.menu','ir.model','ir.model.fields','ir.model.access',\
        'res.partner','res.partner.address','res.partner.category','workflow',\
        'workflow.activity','workflow.transition','ir.actions.server','ir.server.object.lines')
     data['form']['objects']=mod.search(cr,uid,[('model','in',list)])
     cr.execute('select max(create_date) from ir_model_data')
     c=(cr.fetchone())[0].split('.')[0]
     c = time.strptime(c,"%Y-%m-%d %H:%M:%S")
     sec=c.tm_sec + 1
     c=(c[0],c[1],c[2],c[3],c[4],sec,c[6],c[7],c[8])
     data['form']['check_date']=time.strftime("%Y-%m-%d %H:%M:%S",c)
     return data['form']

def _record_objects(self, cr, uid, data, context):
    check_date=data['form']['check_date']
    filter=data['form']['filter_cond']
    pool = pooler.get_pool(cr.dbname)
    user=(pool.get('res.users').browse(cr,uid,uid)).login
    mod = pool.get('ir.module.record')
    mod_obj = pool.get('ir.model')

    for id in data['form']['objects'][0][2]:
        obj_name=(mod_obj.browse(cr,uid,id)).model
        obj_pool=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
{'fraction_non_alphanumeric': 0.21680429938392975, 'fraction_numerical': 0.008913356927513435, 'mean_word_length': 4.036303630363037, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 4, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4042942', 'n_tokens_mistral': 2416, 'n_tokens_neox': 2337, 'n_words': 551}