[MIG] hr_timesheet: Migration scripts - #944
Conversation
pedrobaeza
commented
Jun 30, 2017
- Checked noupdate=1 records
- Included analysis work file
- Included migration scripts
- Updated documentation
* Checked noupdate=1 records * Included analysis work file * Included migration scripts * Updated documentation
|
|
||
|
|
||
| def fill_analytic_line_project(env): | ||
| """Fill project with the linked one in the related task or issue.""" |
There was a problem hiding this comment.
The migration with project_issue should occur as part of the migration of project_issue module. If a database does not have the column issue_id because that module does not exist, this will break the migration here.
Same with project_task. Does not belong here.
Also, in v9 the account_analytic_line does not have a field task_id defined in hr_timesheet module.
There was a problem hiding this comment.
No in the case of task_id, as hr_timesheet depends on project and it's the one that adds these fields in the account.analytic.line (see https://github.com/odoo/odoo/blob/c61ae3a3ed65b7a40b470076c5dbbd881e791f78/addons/hr_timesheet/hr_timesheet.py#L10). For field issue_id, I have to check.
| @openupgrade.migrate() | ||
| def migrate(env, version): | ||
| migrate_allow_timesheets(env) | ||
| fill_analytic_line_project(env) |
There was a problem hiding this comment.
In my opinion we need to consider that in v9 the analytic lines were linked to analytic account.
The basic migration process should consist of detecting the analytic lines with is_timesheet = True, then look for an existing project associated to the analytic account of the line, and use it. If no project exists, create one.
Because there are companies that used analytic accounts not connected to projects to report time (e.g. Office time), and in v10 this is no longer allowed. But we need to respect the time entered in the past on those analytic accounts.
This is very, very important.
There was a problem hiding this comment.
You are mixing things. This is a complementary data. You always have the analytic account in the line. The only thing is to have also a related project_id.
There was a problem hiding this comment.
But in v10 you can no longer report time on timesheets for analytic accounts. So all the time logged against pure analytic accounts will no longer be accessible on the timesheet.
There was a problem hiding this comment.
What do you propose then?
There was a problem hiding this comment.
we need to make sure that all analytic lines connected to timesheets in v9 are now connected to projects in v10. And wherever a project does not exist, we must create one an connect it to that analytic account.
There was a problem hiding this comment.
OK, anyway both methods are needed: move flag to projects linked to analytic accounts, and create projects from analytic accounts with the flag marked that haven't got a project.
|
The use_timesheets is deprecated in v9, but the field was not removed. So
the script will be still useful
…On Jun 30, 2017 1:13 PM, "Pedro M. Baeza" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In addons/hr_timesheet/migrations/10.0.1.0/post-migration.py
<#944 (comment)>:
> + env.cr,
+ """
+ UPDATE account_analytic_line aal
+ SET project_id = pi.project_id
+ FROM project_issue pi
+ WHERE pi.id = aal.issue_id
+ AND pi.project_id IS NOT NULL
+ AND aal.project_id IS NULL
+ """,
+ )
+
+
***@***.***()
+def migrate(env, version):
+ migrate_allow_timesheets(env)
+ fill_analytic_line_project(env)
OK, anyway both methods are needed: move flag to projects linked to
analytic accounts, and create projects from analytic accounts with the flag
marked that haven't got a project.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#944 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AHU_VjxeeSEYSigfh_mK9FEZLbJCenFLks5sJNhCgaJpZM4OKCBU>
.
|
|
Added the project creation |
|
|
||
| @openupgrade.migrate() | ||
| def migrate(env, version): | ||
| migrate_allow_timesheets(env) |
There was a problem hiding this comment.
the migrate_missing_projects method is missing
Add missing method call
|
@mreficent included method call. |
|
As I have fixed what @mreficent asked and everything is green, I merge as there's other PR pending from this one (hr_timesheet_sheet). |
|
I still have an issue with this module since I do not have project_issue module installed. |
|
Why? Is there any error? Please put an issue or open a PR with the check. |
|
Yes I have an error that model does not exist, I will try to raise a formal issue if you like |
…s_for_other_domains 13.0 ocb mail ignore aliases for other domains