Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] project: Saving and Task Creation Issues #143282

Closed
wants to merge 3 commits into from

Conversation

mjvi-odoo
Copy link
Contributor

@mjvi-odoo mjvi-odoo commented Nov 23, 2023

Current behavior before PR:

  • Unable to save subtasks when adding a project.
  • Traceback occurs when creating a new task from the subtask kanban view in project sharing.

Desired behavior after PR is merged:

  • Enable successful saving of subtasks after adding a project.
  • Resolve traceback issue during new task creation in project sharing, ensuring correct task creation without traceback.

task-3584963


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented Nov 23, 2023

@C3POdoo C3POdoo added the RD research & development, internal work label Nov 23, 2023
Copy link
Contributor

@pkyriakou pkyriakou left a comment

Choose a reason for hiding this comment

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

Thank you @mjvi-odoo for your work 💯
I left one comment for you, its a bit long but I think it should be helpful for the first bug. If you have any questions feel free to shoot me a message on Discord.

Copy link
Contributor

Choose a reason for hiding this comment

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

I do not think that this is really solving the bug reported.
What this method does is that it hides the project that the subtask has by default because we want to give the user the choice for whether they want the subtask to be shown or not in the project's views.
By removing this method, we remove that functionality which in this case is not correct.
The problem stems from a different place and it is here
Because the display_in_project field is readonly and we don't specify the forcesave attribute, this method doesn't include it in its changes and thus doesn't allow the user to save.
We can add the force_save attribute in the xml of the field as you can see from the parser

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @pkyriakou, I did changes as per you suggested and removed force_save from display_in_project field.

@mjvi-odoo mjvi-odoo force-pushed the 17.0-bug-fixes-project-mjvi branch 3 times, most recently from c32d83a to 7bcf49d Compare December 11, 2023 06:11
Copy link
Contributor

@pkyriakou pkyriakou left a comment

Choose a reason for hiding this comment

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

Thank you for your updates @mjvi-odoo
I left you some more comments.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @mjvi-odoo thank you for your changes but are you sure that this will fully solve the traceback on portal ?
As you can see here, the error stems from the recurrence_id field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I confirm that the changes resolve the traceback issue with the recurrence_id field. @pkyriakou

@@ -383,7 +383,7 @@
widget="subtasks_one2many">
<tree editable="bottom" decoration-muted="state in ['1_done','1_canceled']" open_form_view="True">
<field name="allow_milestones" column_invisible="True"/>
<field name="display_in_project" column_invisible="True" force_save="1"/>
<field name="display_in_project" column_invisible="True"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually your change here is not correct, removing the force_save here will just further break the feature. What the problem is is that the display_in_project field does not appear in the base task form and thus the force_save is not inside the activeFields in the record class.
What you should do is add this line:

<field name="display_in_project" invisible="True" force_save="1"/>

in line 339 under the project_id field.

Copy link
Contributor Author

@mjvi-odoo mjvi-odoo Dec 13, 2023

Choose a reason for hiding this comment

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

understood, I have made the changes as per your comment. @pkyriakou

Copy link
Contributor

@pkyriakou pkyriakou left a comment

Choose a reason for hiding this comment

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

Alright then, I have nothing else to comment on, thank you for the changes ✌️

@mjvi-odoo mjvi-odoo force-pushed the 17.0-bug-fixes-project-mjvi branch 5 times, most recently from 2ea4f69 to 956bf08 Compare January 5, 2024 07:02
Copy link
Contributor

@pkyriakou pkyriakou left a comment

Choose a reason for hiding this comment

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

Hello @mjvi-odoo I added a question for you to look into 💪

@@ -529,7 +530,8 @@
<group>
<field name="project_id" invisible="1" />
<field name="company_id" invisible="1" />
<field name="parent_id" domain="[('id', '!=', id)]" context="{'search_default_project_id': project_id, 'search_default_open_tasks': 1}" />
<field name="child_ids" invisible="1" />
<field name="parent_id" domain="[('id', '!=', id), ('id', 'not in', child_ids), ('parent_id.id', 'not in', child_ids)]" context="{'search_default_project_id': project_id, 'search_default_open_tasks': 1}" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the third part needed for the domain ? the ('parent_id.id', 'not in', child_ids)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added this third part to restrict sub-sub-task, but now I have updated code and added: '!', ('id', 'child_of', id)

Copy link
Contributor

@pkyriakou pkyriakou left a comment

Choose a reason for hiding this comment

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

Thank you @mjvi-odoo for the update. I left two minor comments regarding formatting 😁

Comment on lines 533 to 534
<field name="child_ids" invisible="1" />
<field name="parent_id" domain="[('id', '!=', id),'!', ('id', 'child_of', id)]" context="{'search_default_project_id': project_id, 'search_default_open_tasks': 1}" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<field name="child_ids" invisible="1" />
<field name="parent_id" domain="[('id', '!=', id),'!', ('id', 'child_of', id)]" context="{'search_default_project_id': project_id, 'search_default_open_tasks': 1}" />
<field name="child_ids" invisible="1"/>
<field name="parent_id" domain="[('id', '!=', id), '!', ('id', 'child_of', id)]" context="{'search_default_project_id': project_id, 'search_default_open_tasks': 1}" />

Just formatting

@@ -140,7 +140,7 @@
</div>
</button>
<button name="action_project_sharing_open_subtasks" type="object" class="oe_stat_button" icon="fa-tasks"
invisible="not id or subtask_count == 0" context="{'default_user_ids': [(6, 0, [uid])]}">
invisible="not id or subtask_count == 0" context="{'default_user_ids': [(6, 0, [uid])],'default_project_id': project_id }">
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
invisible="not id or subtask_count == 0" context="{'default_user_ids': [(6, 0, [uid])],'default_project_id': project_id }">
invisible="not id or subtask_count == 0" context="{'default_user_ids': [(6, 0, [uid])], 'default_project_id': project_id }">

Copy link
Contributor

@auon-odoo auon-odoo 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 fix

@@ -529,7 +530,8 @@
<group>
<field name="project_id" invisible="1" />
<field name="company_id" invisible="1" />
<field name="parent_id" domain="[('id', '!=', id)]" context="{'search_default_project_id': project_id, 'search_default_open_tasks': 1}" />
<field name="child_ids" invisible="1"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it needed in the view? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my bad 🙈

Steps to reproduce:
- Access the 'project.task' module.
- Create a subtask.
- Attempt to save the subtask after adding a project to it.

Issue:
- Saving a subtask becomes impossible when a project is added, causing an
  obstruction in the process.

Solution:
- Rectify the functionality to enable successful saving of a subtask even after
  adding a project, ensuring a seamless process for subtask creation and
  association with projects.

task-3584963
Steps to reproduce:
- In 'project sharing' create a task T in project A.
- Add 2 subtasks to task T in project A.
- Share project A in edit mode.
- Access the view form of task T as a portal user.
- Click on the subtask button to navigate to the tree/kanban view of subtasks.
- Select the kanban view.
- Create a new task on the fly, resulting in a traceback.

Issue:
- When a portal user creates a new task on the fly from the subtask kanban view,
  a traceback occurs, and the expected behavior of creating a new task Y in
  project A is not met. Additionally, task Y should not be a subtask of task T.

Solution:
- Resolve the traceback issue when creating a new task from the subtask kanban
  view as a portal user in project sharing.
- Ensure that the new task Y is correctly created in project A and is not
  set as a subtask of task T.

task-3584963
- Instead of raising an error, we simply exclude sub-tasks of the current
  task from the domain of the 'parent task' field

task-3584963
Copy link
Contributor

@xavierbol xavierbol left a comment

Choose a reason for hiding this comment

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

LGTM, thanks again for your work. 🙂

@xavierbol xavierbol marked this pull request as ready for review March 28, 2024 13:46
@xavierbol
Copy link
Contributor

robodoo rebase-ff r+

@robodoo
Copy link
Contributor

robodoo commented Mar 28, 2024

Merge method set to rebase and fast-forward.

@C3POdoo C3POdoo requested a review from a team March 28, 2024 13:58
robodoo pushed a commit that referenced this pull request Mar 28, 2024
Steps to reproduce:
- Access the 'project.task' module.
- Create a subtask.
- Attempt to save the subtask after adding a project to it.

Issue:
- Saving a subtask becomes impossible when a project is added, causing an
  obstruction in the process.

Solution:
- Rectify the functionality to enable successful saving of a subtask even after
  adding a project, ensuring a seamless process for subtask creation and
  association with projects.

task-3584963

Part-of: #143282
robodoo pushed a commit that referenced this pull request Mar 28, 2024
Steps to reproduce:
- In 'project sharing' create a task T in project A.
- Add 2 subtasks to task T in project A.
- Share project A in edit mode.
- Access the view form of task T as a portal user.
- Click on the subtask button to navigate to the tree/kanban view of subtasks.
- Select the kanban view.
- Create a new task on the fly, resulting in a traceback.

Issue:
- When a portal user creates a new task on the fly from the subtask kanban view,
  a traceback occurs, and the expected behavior of creating a new task Y in
  project A is not met. Additionally, task Y should not be a subtask of task T.

Solution:
- Resolve the traceback issue when creating a new task from the subtask kanban
  view as a portal user in project sharing.
- Ensure that the new task Y is correctly created in project A and is not
  set as a subtask of task T.

task-3584963

Part-of: #143282
@robodoo robodoo closed this in 3dda557 Mar 28, 2024
@xavierbol xavierbol deleted the 17.0-bug-fixes-project-mjvi branch April 2, 2024 12:12
willylohws pushed a commit to willylohws/odoo that referenced this pull request May 1, 2024
Steps to reproduce:
- Access the 'project.task' module.
- Create a subtask.
- Attempt to save the subtask after adding a project to it.

Issue:
- Saving a subtask becomes impossible when a project is added, causing an
  obstruction in the process.

Solution:
- Rectify the functionality to enable successful saving of a subtask even after
  adding a project, ensuring a seamless process for subtask creation and
  association with projects.

task-3584963

Part-of: odoo#143282
willylohws pushed a commit to willylohws/odoo that referenced this pull request May 1, 2024
Steps to reproduce:
- In 'project sharing' create a task T in project A.
- Add 2 subtasks to task T in project A.
- Share project A in edit mode.
- Access the view form of task T as a portal user.
- Click on the subtask button to navigate to the tree/kanban view of subtasks.
- Select the kanban view.
- Create a new task on the fly, resulting in a traceback.

Issue:
- When a portal user creates a new task on the fly from the subtask kanban view,
  a traceback occurs, and the expected behavior of creating a new task Y in
  project A is not met. Additionally, task Y should not be a subtask of task T.

Solution:
- Resolve the traceback issue when creating a new task from the subtask kanban
  view as a portal user in project sharing.
- Ensure that the new task Y is correctly created in project A and is not
  set as a subtask of task T.

task-3584963

Part-of: odoo#143282
willylohws pushed a commit to willylohws/odoo that referenced this pull request May 1, 2024
- Instead of raising an error, we simply exclude sub-tasks of the current
  task from the domain of the 'parent task' field

task-3584963

closes odoo#143282

Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants