hr_timesheet_task : can't save new task : "Analytic Account" field is invalid
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
HR - Timesheet Management |
Fix Committed
|
Undecided
|
Unassigned |
Bug Description
I am using an up-to-date OpenERP with OCB 7.0 branches for addons+server+web. Here is the scenario of the bug :
1) Create a new DB with demo data.
2) Install the module "project_timesheet"
3) Go to the menu Project > Project > Projects
4) Click on the project "The Jackson Group's Project" : you will arrive on the kanban vue of tasks
5) Create a new Task and, immediately after, create a new work item (don't do a "save" in between)
6 ) Click on Save => it works well
Now, Install the module hr_timesheet_task from lp:hr-timesheet
Run the same scenario :
3') Go to the menu Project > Project > Projects
4') Click on the project "The Jackson Group's Project" : you will arrive on the kanban vue of tasks
5') Create a new Task and, immediately after, create a new work item (don't do a "save" in between)
6') Click on Save
=> it doesn't work and the following message is displayed to the user in the top right corner : "The following fields are invalid" : "Analytic Account".
Related branches
- Yannick Vaucher @ Camptocamp: Approve (code review, no test)
- Stéphane Bidoul (Acsone) (community): Approve (code review, no test)
- Pedro Manuel Baeza: Approve (code review)
- Alexandre Fayolle - camptocamp: Approve (code review, no test)
-
Diff: 51 lines (+12/-6)2 files modifiedtimesheet_task/project_task.py (+10/-4)
timesheet_task/project_task_view.xml (+2/-2)
Changed in hr-timesheet: | |
status: | New → Fix Committed |
I have fixed the bug in the merge proposal https:/ /code.launchpad .net/~akretion- team/hr- timesheet/ 70-fix- timesheet- task-bug1316456 /+merge/ 218364
A few explainations about the bug and the fix : the field ""Analytic Account" (account_id) is a hidden field in the hr.analytic. timesheet line (=work items). In the scenario which is working, the field account_id is set by the on_change on the field unit_amount, which is the function on_change_ unit_amount. But this on_change only works when the task has been saved. I have made a small modification to this on_change to make it work even when the task is not saved yet, by adding an argument project_id, and reading it via parent.project_id in the view.