diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py index 255f83e7021..acedf4822ed 100644 --- a/addons/project_timesheet/project_timesheet.py +++ b/addons/project_timesheet/project_timesheet.py @@ -125,6 +125,32 @@ class project_work(osv.osv): project_work() +class task(osv.osv): + _inherit = "project.task" + _description = "Tasks" + + def write(self, cr, uid, ids,vals,context={}): + if (vals.has_key('project_id') and vals['project_id']) or (vals.has_key('name') and vals['name']): + vals_line = {} + hr_anlytic_timesheet = self.pool.get('hr.analytic.timesheet') + task_obj_l = self.browse(cr, uid, ids, context) + if (vals.has_key('project_id') and vals['project_id']): + project_obj = self.pool.get('project.project').browse(cr, uid, vals['project_id']) + acc_id = project_obj.category_id.id + + for task in task_obj_l: + if len(task.work_ids): + for task_work in task.work_ids: + line_id = task_work.hr_analytic_timesheet_id + if (vals.has_key('project_id') and vals['project_id']): + vals_line['account_id'] = acc_id + if (vals.has_key('name') and vals['name']): + vals_line['name'] = '%s: %s' % (tools.ustr(vals['name']), tools.ustr(task_work.name) or '/') + hr_anlytic_timesheet.write(cr, uid, [line_id], vals_line, {}) + return super(osv.osv,self).write(cr, uid, ids, vals, context) + +task() + class project_project(osv.osv): _inherit = "project.project" def name_get(self, cr, user, ids, context=None):