[FIX] project: select the any project in the sub task

Steps:
- Install Project
- Open project module
- Actived Task Dependencies
- Select any project
- Now select any task
- Go to Sub-Task notebook
- Add sub task
- Select any other project in the sub task

Issue:
 Currently, we cannot create sub task of another project in the form view.

Fix:
 - we can create sub task of any project.

Task-3508241

closes odoo/odoo#140794

X-original-commit: 5c2471f4ed1f61b0ba75e05280eccf39a6a44f62
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
Ritika Rathore
2023-11-06 11:16:40 +00:00
committed by Prakash Prajapati
parent 8d3baa20fe
commit c82ffda05d
2 changed files with 41 additions and 3 deletions
@@ -20,8 +20,8 @@ export class ProjectMany2OneField extends Many2OneField {
}
updateRecord(value) {
const { project_id, display_in_project } = this.props.record.data;
if (!display_in_project && value && value[0] === project_id[0]) {
const { display_in_project } = this.props.record.data;
if (!display_in_project && value) {
this.props.record.update({ "display_in_project": true });
}
super.updateRecord(value);
@@ -5,7 +5,12 @@ import { addModelNamesToFetch } from "@bus/../tests/helpers/model_definitions_he
import { start } from "@mail/../tests/helpers/test_utils";
import { click, getFixture } from "@web/../tests/helpers/utils";
import {
click,
getFixture,
clickOpenedDropdownItem,
clickDropdown,
} from "@web/../tests/helpers/utils";
import { setupViewRegistries } from "@web/../tests/views/helpers";
addModelNamesToFetch(["project.project", "project.task"]);
@@ -18,6 +23,9 @@ QUnit.module('Subtask Kanban List tests', {
const projectId = pyEnv['project.project'].create([
{ name: "Project One" },
]);
const projectId2 = pyEnv['project.project'].create([
{ name: "Project Two" },
]);
const userId = pyEnv['res.users'].create([
{ name: "User One", login: 'one', password: 'one' },
]);
@@ -30,6 +38,9 @@ QUnit.module('Subtask Kanban List tests', {
{ name: 'task six', parent_id: 5, closed_subtask_count: 0, subtask_count: 0, child_ids: [], state: '1_canceled' },
{ name: 'task seven', parent_id: 1, closed_subtask_count: 0, subtask_count: 0, child_ids: [], state: '01_in_progress', user_ids: [userId] },
]);
this.task = pyEnv['project.task'].create([
{ name: "task's Project Two", project_id: projectId2, child_ids: [] }
]);
this.views = {
"project.task,false,kanban":
`<kanban js_class="project_task_kanban">
@@ -51,6 +62,15 @@ QUnit.module('Subtask Kanban List tests', {
</t>
</templates>
</kanban>`,
"project.task,false,form":
`<form>
<field name="child_ids" widget="subtasks_one2many">
<tree editable="bottom">
<field name="display_in_project" force_save="1"/>
<field name="project_id" widget="project"/>
</tree>
</field>
</form>`
};
target = getFixture();
setupViewRegistries();
@@ -112,4 +132,22 @@ QUnit.module('Subtask Kanban List tests', {
"project.task/web_read", // read the parent task to recompute the subtask count
]);
});
QUnit.test("Check that the sub task of another project can be added", async function (assert) {
assert.expect(1);
const { openView } = await start({
serverData: { views: this.views },
});
await openView({
res_model: "project.task",
views: [[false, "form"]],
res_id: this.task,
});
await click(target.querySelector(".o_field_x2many_list_row_add a"));
await clickDropdown(target, 'project_id');
await clickOpenedDropdownItem(target, 'project_id', 'Project One');
await click(target, ".o_form_button_save");
assert.equal(target.querySelector('.o_field_project').textContent.trim(), 'Project One')
});
});