Skip to content

[18.0][ADD] project_task_stage_auto_state#1668

Open
Shide wants to merge 1 commit intoOCA:18.0from
moduon:18.0-project_task_stage_auto_done
Open

[18.0][ADD] project_task_stage_auto_state#1668
Shide wants to merge 1 commit intoOCA:18.0from
moduon:18.0-project_task_stage_auto_done

Conversation

@Shide
Copy link
Contributor

@Shide Shide commented Feb 16, 2026

Automatically change task state (done or canceled) after they remain in a stage for a
configured number of days.

Key features:

  • Configure auto-done days per stage with desired states to trigger
  • Configure auto-cancel days per stage with desired states to trigger
  • Automatic message posted in task chatter
  • Daily scheduled action to process tasks
  • Only open tasks are processed (closed states are ignored)

Images:
image

image

MT-13537 @moduon @Gelojr @rafaelbn @fcvalgar please review if you want 😄

@Shide Shide force-pushed the 18.0-project_task_stage_auto_done branch from 99a2b00 to 4726758 Compare February 16, 2026 12:26
@Shide Shide marked this pull request as draft February 16, 2026 12:32
@Shide Shide force-pushed the 18.0-project_task_stage_auto_done branch from 4726758 to 4367a80 Compare February 16, 2026 12:53
@Shide Shide changed the title [18.0][ADD] project_task_stage_auto_done [18.0][ADD] project_task_stage_auto_state Feb 16, 2026
@Shide Shide marked this pull request as ready for review February 16, 2026 12:57
Copy link

@luisDIXMIT luisDIXMIT left a comment

Choose a reason for hiding this comment

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

Code review, LGTM!

Copy link
Contributor

@EmilioPascual EmilioPascual left a comment

Choose a reason for hiding this comment

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

Good job @Shide. Just minor change, although the module works fine anyway.

@rafaelbn rafaelbn requested a review from Gelojr February 21, 2026 04:45
@rafaelbn rafaelbn added this to the 18.0 milestone Feb 21, 2026
Copy link

@Gelojr Gelojr left a comment

Choose a reason for hiding this comment

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

Congrats on the work @Shide
The following tests have been performed (limited to the basic scenario only, because it’s not possible to manually modify the “Last Stage Update” field in the UI).
Test 1: Basic auto-state change by stage (cron runs and updates tasks) — OK

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@Shide Shide force-pushed the 18.0-project_task_stage_auto_done branch 3 times, most recently from c2d0653 to 5665406 Compare February 24, 2026 10:05
@Shide
Copy link
Contributor Author

Shide commented Feb 24, 2026

Now you MUST select states that will trigger the auto-done/cancel when the days has been reached. See description

Copy link
Contributor

@alexey-pelykh alexey-pelykh left a comment

Choose a reason for hiding this comment

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

Thanks for this module @Shide -- nice concept and clean implementation overall. A few things to address before merging:

Bug: wrong state value for "Waiting"

The _get_auto_x_allowed_states method appends "04_waiting" but the actual Odoo 18 task state is "04_waiting_normal". This means enabling "Allow Done/Cancel from Waiting" will silently never match any task. Should be "04_waiting_normal".

Unused import

logging and _logger are imported in project_task.py but never used. Remove them to keep linting clean.

CI note

The test failures are from sale_project_task_selection, unrelated to this module.

Minor: performance consideration

The cron iterates stages and calls self.search() per stage, then task.write() + task.message_post() per task. Fine for typical volumes, but if you want to future-proof it, batching the write (single tasks.write(...) per stage) would reduce DB round-trips. The message_post still needs per-task, so this is purely optional.

Copy link
Contributor

@alexey-pelykh alexey-pelykh left a comment

Choose a reason for hiding this comment

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

Supplementary review -- a few additional observations beyond my earlier CHANGES_REQUESTED review.

Negative days values

auto_done_days and auto_cancel_days are fields.Integer with no constraint preventing negative values. A negative value would produce a threshold_date in the future, meaning the cron would never match anything (harmless) but the configuration would be silently misleading. Consider adding @api.constrains to enforce >= 0, or switching to a field with a built-in minimum.

Missing test coverage for non-in_progress states

All current tests only exercise the in_progress -> done/cancel path. There is no test for changes_requested, approved, or waiting transitions. A test for the waiting state specifically would have caught the "04_waiting" vs "04_waiting_normal" bug flagged in my earlier review. I would recommend adding at least one test per allowed state to ensure the state mapping is correct end-to-end.

freezegun not declared as external dependency

freezegun is used in tests but is not listed in __manifest__.py under external_dependencies. While it is commonly available in OCA CI environments, declaring it is cleaner:

"external_dependencies": {
    "python": ["freezegun"],
},

Everything else looks solid

  • Module structure follows OCA conventions (manifest, readme fragments, i18n, tests).
  • Cron definition with noupdate="1" is correct.
  • Validation constraints on stages (requiring at least one allowed state) are well implemented.
  • Spanish translations are complete and accurate.
  • View inheritance using xpath is clean and follows Odoo best practices.
  • The message_post with subtype_xmlid="mail.mt_note" is the right choice for internal notifications.

Review posted via CorporateHub OCA review campaign

@Shide Shide force-pushed the 18.0-project_task_stage_auto_done branch from 5665406 to 21ad3a7 Compare March 4, 2026 10:01
@rafaelbn rafaelbn requested a review from alexey-pelykh March 20, 2026 15:34
Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

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

Tested in prod 👍🏼

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.

7 participants