[FIX] web: relational_utils save & new
As of now, if a user clicks on the "Save & New" button while the form is not valid, it will disable all buttons without any options to make them enabled again. The only solution then is to close the form and re-open it. Steps to reproduce: Inventory -> Configuration -> Route -> Select any route -> Add a line to the rules. As soon as you click on the "Save & New" button and the form isn't valid, you can't use any buttons anymore. Part of task-2985735 closes odoo/odoo#102315 X-original-commit: 6d63d1035b28f2004774a99a7be84b92a1cb1883 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Tiffany Chang <tic@odoo.com>
This commit is contained in:
@@ -514,8 +514,8 @@ export class X2ManyFieldDialog extends Component {
|
||||
async saveAndNew() {
|
||||
const disabledButtons = this.disableButtons();
|
||||
const saved = await this.save({ saveAndNew: true });
|
||||
this.enableButtons(disabledButtons);
|
||||
if (saved) {
|
||||
this.enableButtons(disabledButtons);
|
||||
if (this.title) {
|
||||
this.title = this.title.replace(this.env._t("Open:"), this.env._t("New:"));
|
||||
}
|
||||
|
||||
@@ -12442,4 +12442,36 @@ QUnit.module("Fields", (hooks) => {
|
||||
|
||||
assert.containsOnce(target, ".modal .o_data_row td[name=display_name]");
|
||||
});
|
||||
|
||||
QUnit.test('Add a line, click on "Save & New" with an invalid form', async function (assert) {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="p">
|
||||
<tree>
|
||||
<field name="display_name"/>
|
||||
</tree>
|
||||
<form>
|
||||
<field name="display_name" required="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</form>`,
|
||||
});
|
||||
|
||||
assert.containsNone(target, ".o_data_row");
|
||||
// Add a new record
|
||||
await addRow(target);
|
||||
assert.containsOnce(target, ".o_dialog .o_form_view");
|
||||
|
||||
// Click on "Save & New" with an invalid form
|
||||
await click(target, ".o_dialog .o_form_button_save_new");
|
||||
assert.containsOnce(target, ".o_dialog .o_form_view");
|
||||
|
||||
// Check that no buttons are disabled
|
||||
assert.hasAttrValue(target.querySelector(".o_dialog .o_form_button_save_new"), "disabled", undefined);
|
||||
assert.hasAttrValue(target.querySelector(".o_dialog .o_form_button_cancel"), "disabled", undefined);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user