1
##############################################################################
3
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
4
# Fabien Pinckaers <fp@tiny.Be>
6
# WARNING: This program as such is intended to be used by professional
7
# programmers who take the whole responsability of assessing all potential
8
# consequences resulting from its eventual inadequacies and bugs
9
# End users who are looking for a ready-to-use solution with commercial
10
# garantees and support are strongly adviced to contract a Free Software
13
# This program is Free Software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
##############################################################################
37
def _action_line_create(self, cr, uid, data, context):
38
tw = pooler.get_pool(cr.dbname).get('project.task.work')
39
ids = tw.search(cr, uid, [('user_id','=',uid), ('date','>=',time.strftime('%Y-%m-%d 00:00:00')), ('date','<=',time.strftime('%Y-%m-%d 23:59:59'))])
40
ts = pooler.get_pool(cr.dbname).get('hr.analytic.timesheet')
42
for work in tw.browse(cr, uid, ids, context):
43
if work.task_id.project_id.category_id:
44
unit_id = ts._getEmployeeUnit(cr, uid, context)
45
product_id = ts._getEmployeeUnit(cr, uid, context)
48
'date': time.strftime('%Y-%m-%d'),
49
'unit_amount': work.hours,
50
'product_uom_id': unit_id,
51
'product_id': product_id,
52
'amount': work.hours or 0.0,
53
'account_id': work.task_id.project_id.category_id.id
55
res2 = ts.on_change_unit_amount(cr, uid, False, product_id, work.hours or 0.0,unit_id, context)
57
res.update(res2['value'])
58
id = ts.create(cr, uid, res, context)
60
print 'not found', work.task_id.project_id.name
63
'domain': "[('user_id','=',%d),('date','>=','%s'), ('date','<=','%s')]" % (uid, time.strftime('%Y-%m-%d 00:00:00'), time.strftime('%Y-%m-%d 23:59:59')),
64
'name': 'Create Analytic Line',
66
'view_mode': 'tree,form',
67
'res_model': 'hr.analytic.timesheet',
69
'type': 'ir.actions.act_window'
73
class wiz_hr_timesheet_project(wizard.interface):
77
'result': {'type': 'action', 'action': _action_line_create, 'state':'end'}
80
wiz_hr_timesheet_project('hr_timesheet_project.encode.hour')