~lepistone/hr-timesheet/7.0-hr-timesheet-lep

« back to all changes in this revision

Viewing changes to timesheet_task/project_task.py

  • Committer: Stéphane Bidoul
  • Date: 2012-10-26 13:01:39 UTC
  • Revision ID: stephane.bidoul@acsone.eu-20121026130139-1t3b9neugmejwn6l
timesheet_task: enforce consistency in timesheets when changing a task's project
(lp:c2c-addons/6.1  rev 117.1.1)

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
                                     help="Percent of tasks closed according to the total of tasks todo.",
88
88
                                     store = {'project.task': (lambda self, cr, uid, ids, c={}: ids, TASK_WATCHERS, 20),
89
89
                                              'account.analytic.line': (_get_analytic_line, AA_WATCHERS, 20)})}
 
90
    
 
91
    def write(self, cr, uid, ids, vals, context=None):
 
92
        res = super(ProjectTask, self).write(cr, uid, ids, vals, context=context)
 
93
        if 'project_id' in vals:
 
94
            ts_obj = self.pool.get('hr.analytic.timesheet')
 
95
            project_obj = self.pool.get('project.project')
 
96
            project = project_obj.browse(cr, uid, vals['project_id'], context)
 
97
            account_id = project.analytic_account_id.id
 
98
            for task in self.browse(cr, uid, ids, context=context):
 
99
                ts_obj.write(cr, uid, [w.id for w in task.work_ids], {'account_id': account_id}, context=context)
 
100
        return res
90
101
 
91
102
ProjectTask()
92
103