Skip to content

[MIG] hr_timesheet: Migration scripts - #944

Merged
pedrobaeza merged 4 commits into
OCA:10.0from
Tecnativa:10.0-hr_timesheet
Aug 3, 2017
Merged

[MIG] hr_timesheet: Migration scripts#944
pedrobaeza merged 4 commits into
OCA:10.0from
Tecnativa:10.0-hr_timesheet

Conversation

@pedrobaeza

Copy link
Copy Markdown
Member
  • 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."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you propose then?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JordiBForgeFlow

JordiBForgeFlow commented Jun 30, 2017 via email

Copy link
Copy Markdown
Member

@pedrobaeza

Copy link
Copy Markdown
Member Author

Added the project creation


@openupgrade.migrate()
def migrate(env, version):
migrate_allow_timesheets(env)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the migrate_missing_projects method is missing

Add missing method call
@pedrobaeza

Copy link
Copy Markdown
Member Author

@mreficent included method call.

@pedrobaeza pedrobaeza closed this Aug 3, 2017
@pedrobaeza pedrobaeza reopened this Aug 3, 2017
@pedrobaeza

Copy link
Copy Markdown
Member Author

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).

@pedrobaeza
pedrobaeza merged commit 2d340d5 into OCA:10.0 Aug 3, 2017
@pedrobaeza
pedrobaeza deleted the 10.0-hr_timesheet branch August 3, 2017 11:09
@remi-filament

Copy link
Copy Markdown

I still have an issue with this module since I do not have project_issue module installed.
A check whether project_issue is installed should be performed before running the lines updating account_analytic_line from project_issue table.

@pedrobaeza

Copy link
Copy Markdown
Member Author

Why? Is there any error? Please put an issue or open a PR with the check.

@remi-filament

Copy link
Copy Markdown

Yes I have an error that model does not exist, I will try to raise a formal issue if you like

achrafbannour pushed a commit to whitecapetech/OpenUpgrade that referenced this pull request Oct 6, 2021
…s_for_other_domains

13.0 ocb mail ignore aliases for other domains
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants