commit
1dbaf1afed
|
@ -1,7 +1,7 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
|
@ -29,7 +29,7 @@ Add menu to show relevant information for each manager.""",
|
|||
"category" : "Generic Modules/Accounting",
|
||||
"module": "",
|
||||
"website": "http://www.camptocamp.com/",
|
||||
"depends" : ["account","hr_timesheet","hr_timesheet_invoice"],
|
||||
"depends" : ["account","hr_timesheet","hr_timesheet_invoice","project"],
|
||||
"init_xml" : [],
|
||||
"update_xml" : [
|
||||
"security/ir.model.access.csv",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
|
@ -41,7 +41,8 @@ def fnct_call(fnct):
|
|||
if args[4] not in ('default_get','read','fields_view_get','fields_get','search','search_count','name_search','name_get','get','request_get', 'get_sc'):
|
||||
if _old_args is not None:
|
||||
args[5].update(_old_args)
|
||||
mod.recording_data.append(('query', args, argv,res))
|
||||
if args[5]:
|
||||
mod.recording_data.append(('query', args, argv,res))
|
||||
return res
|
||||
return execute
|
||||
|
||||
|
@ -55,7 +56,6 @@ def fnct_call_workflow(fnct):
|
|||
return res
|
||||
return exec_workflow
|
||||
|
||||
|
||||
class base_module_record(osv.osv):
|
||||
_name = "ir.module.record"
|
||||
_columns = {
|
||||
|
@ -93,6 +93,8 @@ class base_module_record(osv.osv):
|
|||
return val
|
||||
|
||||
def _get_id(self, cr, uid, model, id):
|
||||
if type(id)==type(()):
|
||||
id=id[0]
|
||||
if (model,id) in self.ids:
|
||||
return self.ids[(model,id)], False
|
||||
dt = self.pool.get('ir.model.data')
|
||||
|
@ -107,11 +109,11 @@ class base_module_record(osv.osv):
|
|||
record = doc.createElement('record')
|
||||
record.setAttribute("id", record_id)
|
||||
record.setAttribute("model", model)
|
||||
record_list = [record]
|
||||
lids = self.pool.get('ir.model.data').search(cr, uid, [('model','=',model)])
|
||||
res = self.pool.get('ir.model.data').read(cr, uid, lids[:1], ['module'])
|
||||
if res:
|
||||
self.depends[res[0]['module']]=True
|
||||
record_list = [record]
|
||||
fields = self.pool.get(model).fields_get(cr, uid)
|
||||
for key,val in data.items():
|
||||
if not (val or (fields[key]['type']=='boolean')):
|
||||
|
@ -145,7 +147,7 @@ class base_module_record(osv.osv):
|
|||
record.appendChild(field)
|
||||
elif fields[key]['type'] in ('one2many',):
|
||||
for valitem in (val or []):
|
||||
if valitem[0]==0:
|
||||
if valitem[0] in (0,1):
|
||||
if key in self.pool.get(model)._columns:
|
||||
fname = self.pool.get(model)._columns[key]._fields_id
|
||||
else:
|
||||
|
@ -181,11 +183,55 @@ class base_module_record(osv.osv):
|
|||
val = val and ('"""%s"""' % val.replace('\\', '\\\\').replace('"', '\"')) or 'False'
|
||||
if isinstance(val, basestring):
|
||||
val = val.decode('utf8')
|
||||
|
||||
field.setAttribute(u"eval", val)
|
||||
record.appendChild(field)
|
||||
return record_list, noupdate
|
||||
|
||||
def get_copy_data(self, cr, uid,model,id,result):
|
||||
res = []
|
||||
obj=self.pool.get(model)
|
||||
data=obj.read(cr, uid,[id])
|
||||
if type(data)==type([]):
|
||||
del data[0]['id']
|
||||
data=data[0]
|
||||
else:
|
||||
del data['id']
|
||||
|
||||
mod_fields = obj.fields_get(cr, uid)
|
||||
for f in filter(lambda a: isinstance(obj._columns[a], fields.function)\
|
||||
and (not obj._columns[a].store),obj._columns):
|
||||
del data[f]
|
||||
|
||||
for key,val in data.items():
|
||||
if result.has_key(key):
|
||||
continue
|
||||
if mod_fields[key]['type'] == 'many2one':
|
||||
if type(data[key])==type(True) or type(data[key])==type(1):
|
||||
result[key]=data[key]
|
||||
else:
|
||||
result[key]=data[key][0]
|
||||
|
||||
elif mod_fields[key]['type'] in ('one2many',):
|
||||
rel = mod_fields[key]['relation']
|
||||
if len(data[key]):
|
||||
res1=[]
|
||||
for rel_id in data[key]:
|
||||
res=[0,0]
|
||||
res.append(self.get_copy_data(cr, uid,rel,rel_id,{}))
|
||||
res1.append(res)
|
||||
result[key]=res1
|
||||
else:
|
||||
result[key]=data[key]
|
||||
|
||||
elif mod_fields[key]['type'] == 'many2many':
|
||||
result[key]=[(6,0,data[key])]
|
||||
|
||||
else:
|
||||
result[key]=data[key]
|
||||
for k,v in obj._inherits.items():
|
||||
del result[v]
|
||||
return result
|
||||
|
||||
def _generate_object_xml(self, cr, uid, rec, recv, doc, result=None):
|
||||
record_list = []
|
||||
noupdate = False
|
||||
|
@ -198,48 +244,62 @@ class base_module_record(osv.osv):
|
|||
record,update = self._create_record(cr, uid, doc, rec[3], rec[6], id)
|
||||
noupdate = noupdate or update
|
||||
record_list += record
|
||||
|
||||
elif rec[4]=='create':
|
||||
id = self._create_id(cr, uid, rec[3],rec[5])
|
||||
record,noupdate = self._create_record(cr, uid, doc, rec[3], rec[5], id)
|
||||
self.ids[(rec[3],result)] = id
|
||||
record_list += record
|
||||
|
||||
elif rec[4]=='copy':
|
||||
data=self.get_copy_data(cr,uid,rec[3],rec[5],rec[6])
|
||||
copy_rec=(rec[0],rec[1],rec[2],rec[3],rec[4],rec[5],data,rec[7])
|
||||
rec=copy_rec
|
||||
rec_data=[(self.recording_data[0][0],rec,self.recording_data[0][2],self.recording_data[0][3])]
|
||||
self.recording_data=rec_data
|
||||
id = self._create_id(cr, uid, rec[3],rec[6])
|
||||
record,noupdate = self._create_record(cr, uid, doc, rec[3], rec[6], id)
|
||||
self.ids[(rec[3],result)] = id
|
||||
record_list += record
|
||||
|
||||
return record_list,noupdate
|
||||
|
||||
def _generate_assert_xml(self, rec, doc):
|
||||
pass
|
||||
def generate_xml(self, cr, uid):
|
||||
# Create the minidom document
|
||||
self.ids = {}
|
||||
doc = minidom.Document()
|
||||
terp = doc.createElement("openerp")
|
||||
doc.appendChild(terp)
|
||||
for rec in self.recording_data:
|
||||
if rec[0]=='workflow':
|
||||
rec_id,noupdate = self._get_id(cr, uid, rec[1][3], rec[1][5])
|
||||
if not rec_id:
|
||||
continue
|
||||
data = doc.createElement("data")
|
||||
terp.appendChild(data)
|
||||
wkf = doc.createElement('workflow')
|
||||
data.appendChild(wkf)
|
||||
wkf.setAttribute("model", rec[1][3])
|
||||
wkf.setAttribute("action", rec[1][4])
|
||||
if noupdate:
|
||||
data.setAttribute("noupdate", "1")
|
||||
wkf.setAttribute("ref", rec_id)
|
||||
if rec[0]=='query':
|
||||
res_list,noupdate = self._generate_object_xml(cr, uid, rec[1], rec[2], doc, rec[3])
|
||||
data = doc.createElement("data")
|
||||
if noupdate:
|
||||
data.setAttribute("noupdate", "1")
|
||||
if res_list:
|
||||
if len(self.recording_data):
|
||||
self.ids = {}
|
||||
doc = minidom.Document()
|
||||
terp = doc.createElement("openerp")
|
||||
doc.appendChild(terp)
|
||||
for rec in self.recording_data:
|
||||
if rec[0]=='workflow':
|
||||
rec_id,noupdate = self._get_id(cr, uid, rec[1][3], rec[1][5])
|
||||
if not rec_id:
|
||||
continue
|
||||
data = doc.createElement("data")
|
||||
terp.appendChild(data)
|
||||
for res in res_list:
|
||||
data.appendChild(res)
|
||||
elif rec[0]=='assert':
|
||||
pass
|
||||
res = doc.toprettyxml(indent="\t")
|
||||
return doc.toprettyxml(indent="\t").encode('utf8')
|
||||
wkf = doc.createElement('workflow')
|
||||
data.appendChild(wkf)
|
||||
wkf.setAttribute("model", rec[1][3])
|
||||
wkf.setAttribute("action", rec[1][4])
|
||||
if noupdate:
|
||||
data.setAttribute("noupdate", "1")
|
||||
wkf.setAttribute("ref", rec_id)
|
||||
if rec[0]=='query':
|
||||
res_list,noupdate = self._generate_object_xml(cr, uid, rec[1], rec[2], doc, rec[3])
|
||||
data = doc.createElement("data")
|
||||
if noupdate:
|
||||
data.setAttribute("noupdate", "1")
|
||||
if res_list:
|
||||
terp.appendChild(data)
|
||||
for res in res_list:
|
||||
data.appendChild(res)
|
||||
elif rec[0]=='assert':
|
||||
pass
|
||||
res = doc.toprettyxml(indent="\t")
|
||||
return doc.toprettyxml(indent="\t").encode('utf8')
|
||||
base_module_record()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -41,5 +41,18 @@
|
|||
action="wizard_base_module_save"
|
||||
id="menu_wizard_base_module_save"/>
|
||||
|
||||
<wizard
|
||||
id="wizard_base_module_record_objects"
|
||||
string="Record Objects"
|
||||
model="ir.module.module"
|
||||
multi="True"
|
||||
name="base_module_record.module_record_objects"/>
|
||||
<menuitem
|
||||
parent="menu_wizard_base_mod_rec"
|
||||
name="Record Objects of your choice"
|
||||
type="wizard"
|
||||
action="wizard_base_module_record_objects"
|
||||
id="menu_wizard_base_module_record_objects"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
|
@ -22,5 +22,6 @@
|
|||
|
||||
import base_module_record
|
||||
import base_module_save
|
||||
import base_module_record_objects
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
# -*- 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
|
||||
search_ids=obj_pool.search(cr,uid,search_condition)
|
||||
for s_id in search_ids:
|
||||
args=(cr.dbname,uid,user,obj_name,'copy',s_id,{},context)
|
||||
mod.recording_data.append(('query',args, {},s_id))
|
||||
return {}
|
||||
|
||||
def inter_call(self,cr,uid,data,context):
|
||||
res=base_module_save._create_module(self,cr, uid, data, context)
|
||||
return res
|
||||
|
||||
class base_module_record_objects(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_info_default],
|
||||
'result': {
|
||||
'type':'form',
|
||||
'arch':intro_start_form,
|
||||
'fields': intro_start_fields,
|
||||
'state':[
|
||||
('end', 'Cancel', 'gtk-cancel'),
|
||||
('record', 'Record', 'gtk-ok'),
|
||||
]
|
||||
}
|
||||
},
|
||||
'record': {
|
||||
'actions': [],
|
||||
'result': {'type':'action','action':_record_objects,'state':'intro'}
|
||||
},
|
||||
'intro': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
'type':'form',
|
||||
'arch':base_module_save.intro_start_form,
|
||||
'fields':base_module_save.intro_start_fields,
|
||||
'state':[
|
||||
('end', 'Cancel', 'gtk-cancel'),
|
||||
('save', 'Continue', 'gtk-ok'),
|
||||
]
|
||||
},
|
||||
},
|
||||
'save': {
|
||||
'actions': [inter_call],
|
||||
'result': {
|
||||
'type':'form',
|
||||
'arch':base_module_save.intro_save_form,
|
||||
'fields': base_module_save.intro_save_fields,
|
||||
'state':[('end', 'Close', 'gtk-ok'),]
|
||||
},
|
||||
},
|
||||
'end': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':info, 'fields':{}, 'state':[('end','OK')]}
|
||||
},
|
||||
}
|
||||
base_module_record_objects('base_module_record.module_record_objects')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||
# $Id$
|
||||
#
|
||||
|
@ -24,6 +24,11 @@ import wizard
|
|||
import osv
|
||||
import pooler
|
||||
|
||||
info = '''<?xml version="1.0"?>
|
||||
<form string="Module Recording">
|
||||
<label string="Thanks For using Module Recorder" colspan="4" align="0.0"/>
|
||||
</form>'''
|
||||
|
||||
info_start_form = '''<?xml version="1.0"?>
|
||||
<form string="Module Recording">
|
||||
<separator string="Recording Information" colspan="4"/>
|
||||
|
@ -88,6 +93,7 @@ def _info_default(self, cr, uid, data, context):
|
|||
mod = pool.get('ir.module.record')
|
||||
result = {}
|
||||
info = "Details of "+str(len(mod.recording_data))+" Operation(s):\n\n"
|
||||
|
||||
for line in mod.recording_data:
|
||||
result.setdefault(line[0],{})
|
||||
result[line[0]].setdefault(line[1][3], {})
|
||||
|
@ -144,6 +150,13 @@ def _create_module(self, cr, uid, data, context):
|
|||
'module_file': base64.encodestring(s.getvalue()),
|
||||
'module_filename': data['form']['directory_name']+'-'+data['form']['version']+'.zip'
|
||||
}
|
||||
def _check(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
mod = pool.get('ir.module.record')
|
||||
if len(mod.recording_data):
|
||||
return 'info'
|
||||
else:
|
||||
return 'end'
|
||||
|
||||
class base_module_publish(wizard.interface):
|
||||
states = {
|
||||
|
@ -155,10 +168,14 @@ class base_module_publish(wizard.interface):
|
|||
'fields': info_start_fields,
|
||||
'state':[
|
||||
('end', 'Cancel', 'gtk-cancel'),
|
||||
('info', 'Continue', 'gtk-ok'),
|
||||
('check', 'Continue', 'gtk-ok'),
|
||||
]
|
||||
}
|
||||
},
|
||||
'check': {
|
||||
'actions': [],
|
||||
'result': {'type':'choice','next_state':_check}
|
||||
},
|
||||
'info': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
|
@ -181,7 +198,11 @@ class base_module_publish(wizard.interface):
|
|||
('end', 'Close', 'gtk-ok'),
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
'end': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':info, 'fields':{}, 'state':[('end','OK')]}
|
||||
},
|
||||
}
|
||||
base_module_publish('base_module_record.module_save')
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class crm_case_section(osv.osv):
|
|||
_name = "crm.case.section"
|
||||
_description = "Case Section"
|
||||
_columns = {
|
||||
'name': fields.char('Case Section',size=64, required=True),
|
||||
'name': fields.char('Case Section',size=64, required=True, translate=True),
|
||||
'code': fields.char('Section Code',size=8),
|
||||
'active': fields.boolean('Active'),
|
||||
'sequence': fields.integer('Sequence'),
|
||||
|
@ -198,7 +198,7 @@ class crm_case_categ(osv.osv):
|
|||
_name = "crm.case.categ"
|
||||
_description = "Category of case"
|
||||
_columns = {
|
||||
'name': fields.char('Case Category Name', size=64, required=True),
|
||||
'name': fields.char('Case Category Name', size=64, required=True, translate=True),
|
||||
'probability': fields.float('Probability (%)', required=True),
|
||||
'section_id': fields.many2one('crm.case.section', 'Case Section'),
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class hr_timesheet_group(osv.osv):
|
|||
cycle = 0
|
||||
result = []
|
||||
while todo>0:
|
||||
cr.execute('select hour_from,hour_to from hr_timesheet where dayofweek=%d and tgroup_id=%d order by hour_from', (dt_from.day_of_week,id))
|
||||
cr.execute("select hour_from,hour_to from hr_timesheet where dayofweek='%s' and tgroup_id=%d order by hour_from", (dt_from.day_of_week,id))
|
||||
for (hour_from,hour_to) in cr.fetchall():
|
||||
h1,m1 = map(int,hour_from.split(':'))
|
||||
h2,m2 = map(int,hour_to.split(':'))
|
||||
|
|
|
@ -94,14 +94,14 @@ class report_custom(report_rml):
|
|||
inner join (hr_timesheet_group as g inner join hr_timesheet_employee_rel as rel
|
||||
on rel.tgroup_id = g.id and rel.emp_id = %s)
|
||||
on t.tgroup_id = g.id
|
||||
where dayofweek = %s
|
||||
where dayofweek = '%s'
|
||||
and date_from = (select max(date_from)
|
||||
from hr_timesheet inner join (hr_timesheet_employee_rel
|
||||
inner join hr_timesheet_group
|
||||
on hr_timesheet_group.id = hr_timesheet_employee_rel.tgroup_id
|
||||
and hr_timesheet_employee_rel.emp_id = %s)
|
||||
on hr_timesheet.tgroup_id = hr_timesheet_group.id
|
||||
where dayofweek = %s and date_from <= '%s')
|
||||
where dayofweek = '%s' and date_from <= '%s')
|
||||
order by date_from desc
|
||||
'''
|
||||
isPH = False
|
||||
|
|
Loading…
Reference in New Issue