-
-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REF] project_timeline: Use dedicated fields for timeline planning
The fields `date_assign` and `date_end` can't be used, as they are automatically rewritten on certain flow events (user assignation and stage changed to finished one), so we need dedicated fields for the planning. A previous change switches `date_assign` to `date_start`, but it didn't change demo data, and better to use a consistent naming, prefixing both fields with `planned_`. This includes the migration scripts for preserving previous data, and automations to fill planned data from the previous fields. It also pre-fills planning information from assignation date/close date as a best effort pre-planning for existing tasks. TT50618 Co-Authored-By: Pedro M. Baeza <[email protected]>
- Loading branch information
1 parent
4ae0a16
commit 66c9f75
Showing
13 changed files
with
177 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from .hooks import populate_date_start | ||
from .hooks import post_init_hook | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
# Copyright 2021 Open Source Integrators - Daniel Reis | ||
# Copyright 2024 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
|
||
def populate_date_start(cr, registry): | ||
""" | ||
The date_start was introduced to be used instead of date_assign. | ||
To keep same behaviour on upgrade, initialize it | ||
to have the same data as before. | ||
""" | ||
def post_init_hook(cr, registry): | ||
"""Pre-fill planned dates with existing data for having a "best effort" planning.""" | ||
cr.execute( | ||
"UPDATE project_task " | ||
"SET date_start = date_assign " | ||
"WHERE date_start IS NULL " | ||
"SET planned_date_start = date_assign " | ||
"WHERE planned_date_start IS NULL " | ||
"AND date_assign IS NOT NULL" | ||
) | ||
cr.execute( | ||
"UPDATE project_task " | ||
"SET planned_date_end = date_end " | ||
"WHERE planned_date_end IS NULL " | ||
"AND date_end IS NOT NULL" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2024 Tecnativa - Juan José Seguí | ||
# Copyright 2024 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.logged_query( | ||
env.cr, | ||
"""UPDATE project_task | ||
SET planned_date_end = date_end | ||
WHERE planned_date_end IS NULL AND date_end IS NOT NULL; | ||
""", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright 2024 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.rename_fields( | ||
env, [("project.task", "project_task", "date_start", "planned_date_start")] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.