Skip to content

[MIG][19.0] crm_project_task: Migration to 19.0#741

Open
ljmnoonan wants to merge 10 commits into
OCA:19.0from
Pyxiris:19.0-mig-crm_project_task
Open

[MIG][19.0] crm_project_task: Migration to 19.0#741
ljmnoonan wants to merge 10 commits into
OCA:19.0from
Pyxiris:19.0-mig-crm_project_task

Conversation

@ljmnoonan
Copy link
Copy Markdown
Member

This is a migration + a pretty heavy handed rewrite of the of the security behavior. Previously, a user with no access to the project.task model could still create a task via a transient model, but it was a bit of a shot in the dark, because if he wanted to correct something, he would immediately get an access error. To fix this, I gave sales_team.group_sale_salesman access to project.task, but restricted them to tasks with a lead_id pointing to a lead accessible by the user.

Notes:

  • In order to successfully run the default_get method in project.task we need to use sudo, as our user may not have access to such models as project.project. However, sudo strips all default_ context here, which appears to be a decision related to mail (odoo/odoo@7700bd1). In order to solve this, I use _get_sudo_env_with_context which reinjects the default_ values. The other approach would be to simply give sales_team.group_sale_salesman read access to project.project and restrict to the crm_default_project_id project, but this seems brittle. What if another model adds fields with defaults that we don't have access to? It's a little far-fetched, but better be prepared.
  • It is possible to set res.company.crm_default_project_id for Company1 to a project in Company2. This will cause users from Company1 without access to Comany2 to get access errors when attempting to create a related task from a lead.
    While I can Imagine a situation in which this kind of cross company compatibility might be useful, I also think it violates the design intent of odoo in general.
  • The tests here are written by AI (I'm lazy). They seem a bit excessive, but also seem to work. If you would like me to test anything in particular or would like to tell me to grow a pair and write my own tests, please do so :)

@ljmnoonan ljmnoonan changed the title [MIG][19.0] crm project task: Migration to 19.0 [MIG][19.0] crm_project_task: Migration to 19.0 Apr 28, 2026
@ljmnoonan ljmnoonan mentioned this pull request Apr 28, 2026
23 tasks
@ljmnoonan
Copy link
Copy Markdown
Member Author

@EmilioPascual and @rafaelbn it looks like the bot forgot to notify you. I would love your input when you get some time. Thanks!

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

@ljmnoonan thank you for the migration but I’m afraid you haven't done a migration; this is a new module that works differently from version 18.0.
This module was designed specifically so that a salesman who doesn’t have access to tasks can still create a task linked to a sales project.
Over time, we’ve found that giving salesman more access isn’t the best option.
Only users with the appropriate permissions will be able to view, edit, delete or create tasks.

@moduon MT-14675

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

Hello @ljmnoonan thank you for the migration work!

I’m afraid this PR changes the intended security behavior of the module, so I don’t think we should include that change as part of the migration from 18.0.

The module was intentionally designed to allow a sales user without Project permissions to create a task from a lead/opportunity, but not to view, edit, or delete the task afterwards. Those tasks may contain internal information intended only for project users.

If a salesperson needs access to those tasks, the correct approach is to grant that user the appropriate Project permissions, not to extend project.task access to all sales users through this module.

Could you please adjust the PR to preserve the 18.0 behavior?

Thanks again for your work on this. 😄 🙏🏼

@rafaelbn
Copy link
Copy Markdown
Member

/ocabot migration crm_project_task

@OCA-git-bot OCA-git-bot added this to the 19.0 milestone May 11, 2026
EmilioPascual and others added 8 commits May 15, 2026 04:20
@ljmnoonan ljmnoonan force-pushed the 19.0-mig-crm_project_task branch 2 times, most recently from 3640e4d to c6e2865 Compare May 15, 2026 05:57
@ljmnoonan
Copy link
Copy Markdown
Member Author

@rafaelbn @EmilioPascual Thank you for the feedback!

I understand what you are saying about separation of roles, so I brought back the previous behavior specifically for the case of the salesman who should not be able to mess with tasks. However, I did change what happens when he hits "Create Task" in the wizard view: instead of being redirected to the task form view, where he can edit nothing and will get an annoying access error if he even clicks in the HTML editor, he now stays on the lead page; the wizard closes and the task is created in the background. He can click the oe_stat_button and see the task he has created, but he cannot open it.

On the subject of oe_stat_buttons, I added sudo to the counter, so that the salesman can see that there are already tasks created even if he he can't see them in the kanban. This also means that the "Create Task" button goes away as soon as anyone has created a linked task. A salesman cannot make a duplicate.

Also, for users looking at the task, there is now an oe_stat_button linking them to the parent lead instead of the brittle link in chatter. This is especially important considering that leads can be merged. I have added the task_ids field to the list of fields to be merged, so linked tasks will now "stick" to the new, merged lead.

Finally, users with project.group_project_user do not use the wizard anymore. Instead, the "Create Task" button sends them straight to form view. They are also not limited to using the "Create Task" button, as now they can add tasks via the kanban, list, and calendar views with identical results. Context remains the same no mater what method you use.

Please let me know what you think!

@ljmnoonan ljmnoonan requested a review from EmilioPascual May 16, 2026 20:45
Copy link
Copy Markdown
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.

@ljmnoonan thank you for the changes.

A minor change in readme.

Comment thread crm_project_task/readme/USAGE.md
@ljmnoonan ljmnoonan force-pushed the 19.0-mig-crm_project_task branch from c6e2865 to 0226cd4 Compare May 19, 2026 06:05
@ljmnoonan
Copy link
Copy Markdown
Member Author

Fixed the docs and added some edge case type stuff. Now the decision to use the wizard or not is determined not only by the permissions group, but also by whether the user has read access to the default project the new task is being created in. This allows certain cases like:

  • Your salesman is also a user of project.task, but for other projects. You do not want to give him access to the default project.
  • Your default project is in another company the user does not have access to

Finally, when a user created a task via the wizard, even if he had no permissions in the default project, he would still be able to come back and view/edit the task he created. This was because he was automatically added as a follower by the create() method. I fixed this by immediately unsubscribing him from the task as soon as he has created it.

@ljmnoonan ljmnoonan requested a review from EmilioPascual May 19, 2026 06:22
ljmnoonan added 2 commits May 20, 2026 06:31
Adapt behavior to user permissions:
A user with no permissions in the configured default project will only be
able to add a single task via the “Create Task” button, and that only if a
different task does not already exist. He is not added as a follower on tasks
he creates either. Basically, he is limited to initiating a task. He can use
the oe_stat_button to see linked tasks that he has been given permission to
view/edit, otherwise, the views this button directs him to will be empty.

A user with permissions in the configured default project will be able to
add tasks not only with the “Create Task” button (which will bring him to
a full form view instead of a popup), but also with the “New” buttons in
the views arrived at by clicking the “Task(s)” oe_stat_button. Contextual
default values stay the same regardless of the meton used to create the task.

All of this produces a more consistent and logical ux with less annoying
access errors. Users are never given the opportunity to commit an action
that would result in an access error
Bringing the translations in line with new structure.
This task was done with AI. It also added some new translations, but
I do not speak any of these languages, so cannot verify accuracy.
@ljmnoonan ljmnoonan force-pushed the 19.0-mig-crm_project_task branch from 0226cd4 to 278be58 Compare May 20, 2026 06:34
Copy link
Copy Markdown
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.

Nice

Copy link
Copy Markdown

@fcvalgar fcvalgar 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 the contribution @ljmnoonan and the migration work done on this module.

The following tests have been performed in Odoo 19:

Test 1: OK - Created a project task from a CRM opportunity using Mitchel Admin. The task was correctly linked to the opportunity and accessible through the smart button.
Test 2: OK - Verified that the “Create Task” button is only available when no linked tasks exist on the lead/opportunity.
Test 3: OK - Checked the smart button behavior and confirmed that only related tasks are displayed from the CRM record.
Test 4: OK - Verified that created tasks inherit default values from the CRM opportunity, including customer, assigned user and configured default project.
Test 5: OK - Tested task creation flow with a user without full project permissions. The wizard flow correctly created the task in the configured CRM project.
Test 6: OK - Confirmed that an appropriate validation error is displayed when no default CRM project is configured.
Test 7: OK - Verified navigation from the created project task back to the originating CRM lead/opportunity.
Test 8: OK - Confirmed that linked tasks remain properly assigned after merging CRM opportunities.
Test 9: OK - Verified the new permission selection behavior in Sales and Project access rights views. The “no permission assigned” state is now explicitly displayed as “No” instead of an empty value.

Additionally, there has been a UI modification in the Project access rights view under Sales/Project permissions where the empty permission state is now shown as “No”. While technically correct, this behavior is not common in standard Odoo, where unassigned permission levels are usually displayed as empty values rather than explicit “No” labels.

Image

@OCA-git-bot
Copy link
Copy Markdown
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). 🤖

@ljmnoonan
Copy link
Copy Markdown
Member Author

@fcvalgar , Thank you for the review!
The "No" selection does not have anything to do with this module though and is actually default behavior for Odoo 19. I believe this is the line responsible here

@fcvalgar
Copy link
Copy Markdown

@fcvalgar , Thank you for the review! The "No" selection does not have anything to do with this module though and is actually default behavior for Odoo 19. I believe this is the line responsible here

Thanks for the clarification! I honestly didn’t know this behavior was already standard in Odoo 19.

Thanks again for the migration work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants