Skip to content
Snippets Groups Projects
Commit b6325ae4 authored by Nicolas Lempereur's avatar Nicolas Lempereur
Browse files

[FIX] pad: no deadlock on pad readonly modification


When the adapation without jQuery promise was done for 12.3 (in
bfed5742) the hack for always saving a pad URL was added in
the deferrence of the start method.

This caused that in the following conditions:

- pad URL is set
- form is in edit mode
- a change in the form change the readonly status of the pad

=> we would have a mutex lock (of the form change) waiting for the pad
that is being rerendered to finish its start but that can only be done
once the mutex is unlocked (because setValue of the pad is protected by
the same mutex) => so we have deadlock and interface does not allow to
save or do any other change.

This happened for example if we had a project.project A without
collaborative pad, project.project B with collaborative pad, and if we
moved a task from project B to project A then back to project B.

With this change, we get back to the behavior before bfed5742 of not
waiting for the fake "setValue" in `start` of Pad.

Without the change, added test fails with:
    Expected 1 assertions, but 0 were run

because interface is deadlocked so write does not happen.

opw-2150827
closes #41346

closes odoo/odoo#41363

X-original-commit: cc73abb218e17756b21824a192f4461eb8537c0e
Signed-off-by: default avatarNicolas Lempereur (nle) <nle@odoo.com>
parent b5020a44
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,6 @@ var FieldPad = AbstractField.extend({
this.$(".oe_configured").addClass('d-none');
return Promise.resolve();
}
var defs = [];
if (this.mode === 'edit' && _.str.startsWith(this.value, 'http')) {
this.url = this.value;
// please close your eyes and look elsewhere...
......@@ -56,11 +55,10 @@ var FieldPad = AbstractField.extend({
// Guess what we decided...
var url = {};
url.toJSON = _.constant(this.url);
defs.push(this._setValue(url, {doNotSetDirty: true}));
this._setValue(url, {doNotSetDirty: true});
}
defs.push(this._super.apply(this, arguments));
return Promise.all(defs);
return this._super.apply(this, arguments);
},
//--------------------------------------------------------------------------
......
......@@ -13,6 +13,7 @@ QUnit.module('pad widget', {
task: {
fields: {
description: {string: "Description", type: "char"},
use_pad: {string: "Use pad", type: "boolean"},
},
records: [
{id: 1, description: false},
......@@ -272,4 +273,38 @@ QUnit.module('pad widget', {
delete FieldPad.prototype.isPadConfigured;
});
QUnit.test('no pad deadlock on form change modifying pad readonly modifier', async function (assert) {
assert.expect(1);
var form = await createView({
View: FormView,
model: 'task',
data: this.data,
arch:'<form>' +
'<sheet>' +
'<group>' +
'<field name="use_pad" widget="toggle_button"/>' +
'<field name="description" widget="pad" attrs="{\'readonly\': [(\'use_pad\', \'=\', False)]}"/>' +
'</group>' +
'</sheet>' +
'</form>',
res_id: 2,
mockRPC: function (route, args) {
if (!args.method) {
return Promise.resolve(true);
}
if (args.method === "write") {
assert.strictEqual(args.args[1].description,
"https://pad.odoo.pad/p/test-03AK6RCJT");
}
return this._super.apply(this, arguments);
},
});
await testUtils.form.clickEdit(form);
await testUtils.dom.click(form.$('.o_field_widget[name="use_pad"]'));
await testUtils.form.clickSave(form);
form.destroy();
delete FieldPad.prototype.isPadConfigured;
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment