[FIX] web: fix record saving issue
Steps: - Open the Project module. - Open any project. - Add a subtask. - Without manually saving the subtask beforehand, click on 'View'. Form view of sub-task opens that doesn't have any of the fields it should inherit from its parent task. - Go back to the parent task using the breadcrumbs. - Click on 'View' again. Now, the sub-task has all of its fields set as it should. Issue: - After clicking on 'View', the form view of the sub-task opens, but it doesn't have any of the fields it should inherit from its parent task. Cause: - On clicking 'View', the switchToForm action is called, and this action doesn't save records before switching to the form view. Also, it should load that record into the Parent task after saving. In other modules, when clicking on 'View', the openRecord action is called, which is also not saving data. Fix: - Records should be saved when the action is called on clicking 'View'. For the project module, when the action is called, after saving the record, it should also load records in the parent task. task-3631285 closes odoo/odoo#147665 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
committed by
kcv-odoo
parent
5e38390f47
commit
d89b6556d6
@@ -227,7 +227,8 @@ export class X2ManyField extends Component {
|
||||
return props;
|
||||
}
|
||||
|
||||
switchToForm(record) {
|
||||
async switchToForm(record) {
|
||||
await this.props.record.save();
|
||||
this.action.doAction(
|
||||
{
|
||||
type: "ir.actions.act_window",
|
||||
|
||||
@@ -236,6 +236,7 @@ export class ListController extends Component {
|
||||
}
|
||||
|
||||
async openRecord(record) {
|
||||
await record.save();
|
||||
if (this.archInfo.openAction) {
|
||||
this.actionService.doActionButton({
|
||||
name: this.archInfo.openAction.action,
|
||||
|
||||
@@ -351,14 +351,14 @@ QUnit.module("Fields", (hooks) => {
|
||||
assert.containsNone(target, ".badge.dropdown-toggle", "the tags should not be dropdowns");
|
||||
|
||||
// click on the tag: should do nothing and open the form view
|
||||
click(target.querySelector(".o_field_many2many_tags .badge :nth-child(1)"));
|
||||
await click(target.querySelector(".o_field_many2many_tags .badge :nth-child(1)"));
|
||||
assert.verifySteps(["selectRecord"]);
|
||||
await nextTick();
|
||||
|
||||
assert.containsNone(target, ".o_colorlist");
|
||||
|
||||
await click(target.querySelectorAll(".o_list_record_selector")[1]);
|
||||
click(target.querySelector(".o_field_many2many_tags .badge :nth-child(1)"));
|
||||
await click(target.querySelector(".o_field_many2many_tags .badge :nth-child(1)"));
|
||||
assert.verifySteps(["selectRecord"]);
|
||||
await nextTick();
|
||||
|
||||
@@ -386,14 +386,14 @@ QUnit.module("Fields", (hooks) => {
|
||||
assert.containsNone(target, ".badge.dropdown-toggle", "the tags should not be dropdowns");
|
||||
|
||||
// click on the tag: should do nothing and open the form view
|
||||
click(target.querySelector(".o_field_many2many_tags .badge :nth-child(1)"));
|
||||
await click(target.querySelector(".o_field_many2many_tags .badge :nth-child(1)"));
|
||||
assert.verifySteps(["selectRecord"]);
|
||||
await nextTick();
|
||||
|
||||
assert.containsNone(target, ".o_colorlist");
|
||||
|
||||
await click(target.querySelectorAll(".o_list_record_selector")[1]);
|
||||
click(target.querySelector(".o_field_many2many_tags .badge :nth-child(1)"));
|
||||
await click(target.querySelector(".o_field_many2many_tags .badge :nth-child(1)"));
|
||||
assert.verifySteps([]);
|
||||
await nextTick();
|
||||
|
||||
|
||||
@@ -19830,4 +19830,28 @@ QUnit.module("Views", (hooks) => {
|
||||
assert.containsOnce(target, ".o_data_row");
|
||||
assert.containsOnce(target, ".o_data_row.o_selected_row");
|
||||
});
|
||||
|
||||
QUnit.test("Adding new record in list view with open form view button", async function (assert) {
|
||||
await makeView({
|
||||
type: "list",
|
||||
resModel: "foo",
|
||||
serverData,
|
||||
arch: '<tree editable="top" open_form_view="1"><field name="foo"/></tree>',
|
||||
selectRecord: (resId, options) => {
|
||||
assert.step(`switch to form - resId: ${resId} activeIds: ${options.activeIds}`);
|
||||
},
|
||||
});
|
||||
|
||||
await clickAdd();
|
||||
assert.containsN(
|
||||
target,
|
||||
"td.o_list_record_open_form_view",
|
||||
5,
|
||||
"button to open form view should be present on each row"
|
||||
);
|
||||
|
||||
await editInput(target, ".o_field_widget[name=foo] input", "new");
|
||||
await click(target.querySelector("td.o_list_record_open_form_view"));
|
||||
assert.verifySteps(["switch to form - resId: 5 activeIds: 5,1,2,3,4"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user