Merge lp:~sbi/c2c-addons/6.1-bug1071199 into lp:c2c-addons/6.1

Proposed by Stéphane Bidoul (Acsone)
Status: Merged
Merged at revision: 118
Proposed branch: lp:~sbi/c2c-addons/6.1-bug1071199
Merge into: lp:c2c-addons/6.1
Diff against target: 20 lines (+11/-0)
1 file modified
timesheet_task/project_task.py (+11/-0)
To merge this branch: bzr merge lp:~sbi/c2c-addons/6.1-bug1071199
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Review via email: mp+131607@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hello,

That seems correct to me, just one detail, we could reduce the number of write on the tasks to one call instead of a call per task.
But that's a very small optimisation as we will probably rarely change the project on a bunch of tasks.

Thanks

review: Approve
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Hi Guewen,

I'd think this optimization is not worth the effort :)

-sbi

On Tue, Oct 30, 2012 at 10:52 AM, Guewen Baconnier @ Camptocamp <
<email address hidden>> wrote:

> Review: Approve
>
> Hello,
>
> That seems correct to me, just one detail, we could reduce the number of
> write on the tasks to one call instead of a call per task.
> But that's a very small optimisation as we will probably rarely change the
> project on a bunch of tasks.
>
> Thanks
> --
> https://code.launchpad.net/~sbi/c2c-addons/6.1-bug1071199/+merge/131607
> You are the owner of lp:~sbi/c2c-addons/6.1-bug1071199.
>

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Your fix is merged in 6.1 and 7.0 branches.

Thanks Stéphane for your involvement.

Guewen

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'timesheet_task/project_task.py'
2--- timesheet_task/project_task.py 2012-10-15 15:22:12 +0000
3+++ timesheet_task/project_task.py 2012-10-26 13:03:29 +0000
4@@ -87,6 +87,17 @@
5 help="Percent of tasks closed according to the total of tasks todo.",
6 store = {'project.task': (lambda self, cr, uid, ids, c={}: ids, TASK_WATCHERS, 20),
7 'account.analytic.line': (_get_analytic_line, AA_WATCHERS, 20)})}
8+
9+ def write(self, cr, uid, ids, vals, context=None):
10+ res = super(ProjectTask, self).write(cr, uid, ids, vals, context=context)
11+ if 'project_id' in vals:
12+ ts_obj = self.pool.get('hr.analytic.timesheet')
13+ project_obj = self.pool.get('project.project')
14+ project = project_obj.browse(cr, uid, vals['project_id'], context)
15+ account_id = project.analytic_account_id.id
16+ for task in self.browse(cr, uid, ids, context=context):
17+ ts_obj.write(cr, uid, [w.id for w in task.work_ids], {'account_id': account_id}, context=context)
18+ return res
19
20 ProjectTask()
21

Subscribers

People subscribed via source and target branches