[17.0][MIG] project_task_recurring_activity: Migration to 17.0#1671
[17.0][MIG] project_task_recurring_activity: Migration to 17.0#1671CristianoMafraJunior wants to merge 12 commits intoOCA:17.0from
Conversation
This module allow users to add activities to the recurring tasks and have them automatically duplicated within recurring tasks at set intervals. Added form the model and add a button to call a private method
alexey-pelykh
left a comment
There was a problem hiding this comment.
Thanks for working on this! A few things I noticed: the next_recurrence_date field has string="next_date" which looks like an internal reference rather than a user-visible label — should be something like "Next Recurrence Date". Also, project_task_recurrence.py and recurring_activity.py are missing license headers (other files have them). codecov/patch is failing which suggests some paths aren't covered by tests.
| days_after_task_creation_date = fields.Integer() | ||
| next_recurrence_date = fields.Date( | ||
| string="next_date", compute="_compute_next_recurrence_date", store=True | ||
| ) |
There was a problem hiding this comment.
string="next_date" looks like an internal name. Consider a proper label like "Next Recurrence Date".
alexey-pelykh
left a comment
There was a problem hiding this comment.
Thank you for the migration work on project_task_recurring_activity to 17.0. The overall approach of adapting to V17's _create_next_occurrence flow looks reasonable. However, there are several issues that need to be addressed before this can be merged.
Critical / Blocking
-
Missing license headers (
project_task_recurrence.py,recurring_activity.py): OCA modules require AGPL-3 license headers on every Python source file. Two model files are missing them. -
Security: Access rules too permissive (
ir.model.access.csv): Therecurring.activitymodel grants read/write/create/unlink to ALL users (emptygroup_id:idcolumn). This should be restricted to at minimumproject.group_project_userorproject.group_project_recurring_tasks. -
Mutable default on field (
project_task_recurrence.py:7):fields.Date(default=fields.Date.today())evaluatestoday()at class definition time (module load), so every record will get the date the server started, not the date of creation. Usedefault=fields.Date.today(without parentheses) ordefault=lambda self: fields.Date.today(). -
_cron_create_recurring_tasksscans all recurrences (project_task_recurrence.py:17):self.search([]).filtered("task_ids")loads every recurrence record into memory. This is an unbounded query that will degrade as the database grows. Use a domain filter, e.g.,self.search([('task_ids', '!=', False)]). -
f-string inside
_()translation function (recurring_activity.py:84-87): Using an f-string inside_()breaks Odoo's translation extraction. The_()function requires a static string at extraction time. Use%formatting or.format()with_()containing only a static template string.
Moderate
-
next_recurrence_datefield string (recurring_activity.py:44-46):string="next_date"looks like an internal identifier, not a user-facing label. Should be something like"Next Recurrence Date". -
Translation files are stale (
i18n/es.po,i18n/it.po): The.pofiles referenceProject-Id-Version: Odoo Server 14.0and contain entries for fields like__last_updatewhich was removed in V16+. The.potfile referencesOdoo Server 16.0. These should be regenerated for 17.0, and stale field references removed. -
_get_next_datelogic is confusing (recurring_activity.py:53-58): The conditionaldays + 1 if days == 0 else daysmeans that setting 0 days actually results in 1 day offset, which is non-obvious. Consider documenting this behavior or using a minimum constraint on the field instead. -
custom_activity_idsas stored computed Many2many (project_task.py:12-14): This field iscompute="_compute_activity_ids", store=True, copy=Truebut it simply mirrorsrecurring_activity_ids.ids. A stored computed field that is also copyable is unusual -- when a task is copied, does the compute fire and overwrite the copy? This interaction should be verified. -
createoverride usesself._forming_activity_data(item, item.custom_activity_ids)(project_task.py:60-65): Butcustom_activity_idson the newly created task is a computed field that mirrorsrecurring_activity_ids. If the task was just created as a recurrence copy, this may re-create activities that were already copied. Verify there is no duplication ofrecurring_activity_idson recurrence creation. -
Inconsistent XML indentation (
data/recurring_activity.xml): The cron record uses mixed indentation (8 spaces for<record>children, then 12 spaces for<field name="nextcall">). Follow consistent indentation.
Minor / Suggestions
-
recurring_activity.xmlform view:readonly="0"attributes onuser_id,summary, anddescriptionfields in the form view may be unnecessary if the fields are not readonly by default at the model level (they arestore=True, readonly=Falsealready). -
Test assertion messages: Some assertion messages are generic (
"Must be equal to 0","Must be equal to 1"). More descriptive messages would help debugging test failures. -
Unused import in tests (
test_project_recurrence.py:5):from odoo import _, fields-- the_import is used insideassertRaisesRegex, which is fine, but note that this makes the test dependent on the exact translated string. Consider matching on a substring instead. -
delta_timemethod (recurring_activity.py:98-99): This is a trivial(new - old).dayswrapper that is only used in tests. Consider whether it needs to be on the model at all, or can be a test helper. -
Usage documentation (
readme/USAGE.md): Still references "In tab Recurrence" but per the PR description, the V17 migration moved the fields out of the old recurrence page. The documentation should reflect the actual V17 location.
Review posted via CorporateHub OCA review campaign
project_task_recurring_activity/models/project_task_recurrence.py
Outdated
Show resolved
Hide resolved
9e522ea to
3aa418c
Compare
3aa418c to
439d07d
Compare
| groups="project.group_project_recurring_tasks" | ||
| invisible="not recurring_task" | ||
| /> | ||
| <field |

@Escodoo MIGOCA-50
Migrated
project_task_recurring_activityto Odoo 17 compatibility, removing legacy recurrence API dependencies (next_recurrence_date, _get_recurring_fields, planned_hours, etc.).Updated
project_task.xmlfor V17: recurring activities are no longer inserted in the old recurrence page (V16), but injected into the current task form layout.Refactored
models/project_task.py:Refactored
models/project_task_recurrence.py:_get_recurring_fields overridewith_get_recurring_fields_to_copy;Refactored
models/recurring_activity.py:Updated
tests/test_project_recurrence.py: