Merge lp:~acsone-openerp/hr-timesheet/improvements into lp:~hr-core-editors/hr-timesheet/7.0

Proposed by Laetitia Gangloff (Acsone)
Status: Merged
Merged at revision: 42
Proposed branch: lp:~acsone-openerp/hr-timesheet/improvements
Merge into: lp:~hr-core-editors/hr-timesheet/7.0
Diff against target: 59 lines (+13/-3)
4 files modified
hr_timesheet_task/hr_analytic_timesheet_view.xml (+1/-1)
hr_timesheet_task/static/src/js/timesheet.js (+1/-1)
timesheet_task/project_task.py (+10/-0)
timesheet_task/project_task_view.xml (+1/-1)
To merge this branch: bzr merge lp:~acsone-openerp/hr-timesheet/improvements
Reviewer Review Type Date Requested Status
Stefan Rijnhart (Opener) Approve
Guewen Baconnier @ Camptocamp code review, no test Approve
Acsone OpenErp Team Pending
Review via email: mp+160632@code.launchpad.net

Description of the change

This branch propose the following improvement:

- in timesheet_task module add a constraint to check if task belongs to project -> in current it is possible to have a task which doesn't belong to the selected project, and this case seems not coherent. This improvement inforce consistency between project and task in timesheet.

- in hr_timesheet_task module update account domain with ('state','=','open') instead of ('state','<>','close') -> in current it is possible to have timesheet on task in 'cancelled' state. This improvement force to have project 'in progress' (correspond to 'open') state to work on it.

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

LGTM

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

Is it good for merging?

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

l.36: unused variable project_obj. Otherwise good!

review: Needs Fixing
46. By Laetitia Gangloff (Acsone)

timesheet_task: remove unused variable project_obj

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

I removed the unused variable project_obj

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks for the change!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hr_timesheet_task/hr_analytic_timesheet_view.xml'
2--- hr_timesheet_task/hr_analytic_timesheet_view.xml 2013-03-28 17:30:55 +0000
3+++ hr_timesheet_task/hr_analytic_timesheet_view.xml 2013-05-13 07:36:22 +0000
4@@ -23,7 +23,7 @@
5 <field name="arch" type="xml">
6 <tree editable="top" string="Timesheet Lines">
7 <field name="date" on_change="on_change_date(date)"/>
8- <field domain="[('type','=','normal')]" name="account_id"/>
9+ <field domain="[('type','=','normal'), ('state','=','open')]" name="account_id"/>
10 <field name="task_id" context="{'account_id' : account_id}"
11 domain="[('state','=','open'), ('project_id.analytic_account_id','=',account_id)]"/>
12 <field name="name"/>
13
14=== modified file 'hr_timesheet_task/static/src/js/timesheet.js'
15--- hr_timesheet_task/static/src/js/timesheet.js 2013-03-26 17:03:10 +0000
16+++ hr_timesheet_task/static/src/js/timesheet.js 2013-05-13 07:36:22 +0000
17@@ -145,7 +145,7 @@
18 type: "many2one",
19 domain: [
20 ['type','in',['normal', 'contract']],
21- ['state', '<>', 'close'],
22+ ['state', '=', 'open'],
23 ['use_timesheets','=',1],
24 ],
25 context: {
26
27=== modified file 'timesheet_task/project_task.py'
28--- timesheet_task/project_task.py 2013-04-03 11:29:21 +0000
29+++ timesheet_task/project_task.py 2013-05-13 07:36:22 +0000
30@@ -125,6 +125,16 @@
31
32 _columns = {'task_id': fields.many2one('project.task', 'Task')}
33
34+ def _check_task_project(self, cr, uid, ids):
35+ for line in self.browse(cr, uid, ids):
36+ if line.task_id and line.account_id:
37+ if line.task_id.project_id.analytic_account_id.id != line.account_id.id:
38+ return False
39+ return True
40+
41+ _constraints = [
42+ (_check_task_project, 'Error! Task must belong to the project.', ['task_id','account_id']),
43+ ]
44
45 def _compute_hours_with_factor(self, cr, uid, hours, factor_id, context=None):
46 if not hours or not factor_id:
47
48=== modified file 'timesheet_task/project_task_view.xml'
49--- timesheet_task/project_task_view.xml 2013-04-03 10:33:30 +0000
50+++ timesheet_task/project_task_view.xml 2013-05-13 07:36:22 +0000
51@@ -73,7 +73,7 @@
52 editable="top">
53 <field name="user_id"
54 on_change="on_change_user_id(user_id)"
55- required="1" invisible="1" />
56+ required="1" invisible="1"/>
57 <field name="name" />
58 <field name="unit_amount"
59 on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id, parent.id, to_invoice)"