Merge lp:~laetitia-gangloff/hr-timesheet/migrationV7 into lp:~hr-core-editors/hr-timesheet/7.0

Proposed by Laetitia Gangloff (Acsone)
Status: Rejected
Rejected by: Guewen Baconnier @ Camptocamp
Proposed branch: lp:~laetitia-gangloff/hr-timesheet/migrationV7
Merge into: lp:~hr-core-editors/hr-timesheet/7.0
Diff against target: 67 lines (+7/-9)
3 files modified
timesheet_task/__openerp__.py (+1/-1)
timesheet_task/project_task.py (+4/-3)
timesheet_task/project_task_view.xml (+2/-5)
To merge this branch: bzr merge lp:~laetitia-gangloff/hr-timesheet/migrationV7
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp nitpicking Approve
Nicolas Bessi - Camptocamp (community) Needs Fixing
Review via email: mp+148260@code.launchpad.net

Description of the change

I tried to migrate the module timesheet_task to work with the V7.

To post a comment you must log in.
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Hello,

Thanks for the merge proposal.

Please do not rename work_ids to aa_ids we keep the name for compatibility reason and to avoid to redefine some view. It will also be harder to migrate the module.

I think we have also done some work internally to migrate this add-on. If it is the case I will ask my colleague join his work with yours if you do not mind.

Regards

review: Needs Fixing
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Hello,

You commit make me realize that the goal of the module is not clear. We do want to replace work_ids to timesheet line. It was done intentionally. I will provide a MP with a better __openerp__.py with a better description.

Regards

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

Hello,

thank you for your answer.

It seems not possible to replace work_ids with another relation.

In the project module, work_ids field is a relation with project.task.work. In the view project.view_task_form2 some fields of project.task.work are used, but the model is project.task. With this relation, the view has no problem to find all components.
But, if I overload work_ids with another relation, then the view, can't be loaded. Even, if it is replaced by the new view. This is du to the ir_ui_view._check_render_view method that check that all components for the view are valid.

Regards

Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Hello,

This mean we have to override view_task_form2 because it define tree view internally:

                            <field name="work_ids" groups="project.group_tasks_work_on_tasks">
                                <tree string="Task Work" editable="top">
                                    <field name="name"/>
                                    <field name="hours" widget="float_time" sum="Spent Hours"/>
                                    <field name="date"/>
                                    <field name="user_id"/>
                                </tree>
                            </field>

The best solution is probably to remove the tree definition of view in order to use the raw timesheet line view.

Regards

Nicolas

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

Hello,

actually, this module inherits view_task_form2 by replacing the part work_ids.

I quickly tried, to define a specific view for this internal tree, and to use work_ids, it worked. But I did that in the module project and I don't see how to do that in this module.

Thank you

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

@Nicolas, you have a look on this when coming back please ? Thanks.

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

Nicolas, can you give your view?

For my part, I approve from a nitpicking point of view, but I don't know if it is correct regarding the goal of the module.

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

This MP is superseeded by
https://code.launchpad.net/~acsone-openerp/hr-timesheet/migration_hr_timesheet_taskV7/+merge/154433 which includes migration of hr_timesheet_task

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Hello, could you please, change the status of the branch linked to this MP as 'abandonned' to make it clearer?

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

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'timesheet_task/__openerp__.py'
2--- timesheet_task/__openerp__.py 2012-12-13 12:20:12 +0000
3+++ timesheet_task/__openerp__.py 2013-02-13 17:55:25 +0000
4@@ -32,7 +32,7 @@
5 'update_xml': ['project_task_view.xml'],
6 'demo_xml': [],
7 'tests': [],
8- 'installable': False,
9+ 'installable': True,
10 'images' : [],
11 'auto_install': False,
12 'license': 'AGPL-3',
13
14=== modified file 'timesheet_task/project_task.py'
15--- timesheet_task/project_task.py 2012-10-26 13:01:39 +0000
16+++ timesheet_task/project_task.py 2013-02-13 17:55:25 +0000
17@@ -29,7 +29,7 @@
18
19 from osv import osv, fields
20
21-TASK_WATCHERS = ['work_ids', 'remaining_hours', 'planned_hours']
22+TASK_WATCHERS = ['aa_ids', 'remaining_hours', 'planned_hours']
23 AA_WATCHERS = ['unit_amount', 'product_uom_id', 'account_id', 'to_invoice', 'task_id']
24
25 class ProjectTask(osv.osv):
26@@ -66,7 +66,8 @@
27 return result
28
29
30- _columns = {'work_ids': fields.one2many('hr.analytic.timesheet', 'task_id', 'Work done'),
31+ _columns = {'aa_ids': fields.one2many('hr.analytic.timesheet', 'task_id', 'Work done'),
32+
33
34 'effective_hours': fields.function(_progress_rate, multi="progress", method=True, string='Time Spent',
35 help="Sum of spent hours of all tasks related to this project and its child projects.",
36@@ -96,7 +97,7 @@
37 project = project_obj.browse(cr, uid, vals['project_id'], context)
38 account_id = project.analytic_account_id.id
39 for task in self.browse(cr, uid, ids, context=context):
40- ts_obj.write(cr, uid, [w.id for w in task.work_ids], {'account_id': account_id}, context=context)
41+ ts_obj.write(cr, uid, [w.id for w in task.aa_ids], {'account_id': account_id}, context=context)
42 return res
43
44 ProjectTask()
45
46=== modified file 'timesheet_task/project_task_view.xml'
47--- timesheet_task/project_task_view.xml 2012-06-06 13:14:12 +0000
48+++ timesheet_task/project_task_view.xml 2013-02-13 17:55:25 +0000
49@@ -1,16 +1,13 @@
50 <openerp>
51 <data>
52- #---------------------------------------------------------------------------------------------------------
53- # Adapt task views
54- #---------------------------------------------------------------------------------------------------------
55 <record id="view_task_form2" model="ir.ui.view">
56 <field name="name">project.task.form</field>
57 <field name="model">project.task</field>
58 <field name="inherit_id" ref="project.view_task_form2"/>
59 <field name="type">form</field>
60 <field name="arch" type="xml">
61- <xpath expr="/form/notebook/page/field[@name='work_ids']" position="replace">
62- <field colspan="4" name="work_ids" nolabel="1" attrs="{'invisible':[('state','in',['draft'])],'readonly':[('state','=','done')]}">
63+ <xpath expr="/form/sheet/notebook/page/field[@name='work_ids']" position="replace">
64+ <field colspan="4" name="aa_ids" nolabel="1" attrs="{'invisible':[('state','in',['draft'])],'readonly':[('state','=','done')]}">
65 <tree string="Task Work" editable="top">
66 <field name="user_id" on_change="on_change_user_id(user_id)" required="1" invisible="1"/>
67 <field name="name"/>