[FIX] web: quickedit on readonly one2many list
Steps to follow
- Go to the purchase app
- Create a RFQ, add a line, confirm it, lock it and save it
- Click on the one2many line
-> An editable popup is opened and the main form is also switched in edit mode
Solution
- Check if the one2many list has a readonly modifier before switching the main
form to edit mode
- When opening the one2many preview popup, pass along an editable param
opw-2689420
closes odoo/odoo#80338
X-original-commit: d1c9265659572c738596889f7a5ad53f673e9db4
Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
This commit is contained in:
@@ -602,7 +602,7 @@ var AbstractField = Widget.extend({
|
||||
* @param {MouseEvent} ev
|
||||
*/
|
||||
_onClick: function (ev) {
|
||||
if (this._canQuickEdit && this.mode === 'readonly' &&
|
||||
if (!this.hasReadonlyModifier && this._canQuickEdit && this.mode === 'readonly' &&
|
||||
!this.quickEditExclusion.some(x => ev.target.closest(x))
|
||||
) {
|
||||
this.trigger_up('quick_edit', {
|
||||
|
||||
@@ -2123,6 +2123,7 @@ var FieldOne2Many = FieldX2Many.extend({
|
||||
parentID: this.value.id,
|
||||
viewInfo: this.view,
|
||||
deletable: this.activeActions.delete && params.deletable && this.canDelete,
|
||||
editable: !this.hasReadonlyModifier,
|
||||
disable_multiple_selection: params.disable_multiple_selection,
|
||||
}));
|
||||
},
|
||||
|
||||
@@ -87,6 +87,7 @@ var AbstractView = Factory.extend({
|
||||
* @param {Array[]} [params.domain=[]]
|
||||
* @param {Object[]} [params.dynamicFilters] transmitted to the
|
||||
* ControlPanel
|
||||
* @param {boolean} [params.editable]
|
||||
* @param {number[]} [params.ids]
|
||||
* @param {boolean} [params.isEmbedded=false]
|
||||
* @param {Object} [params.searchQuery={}]
|
||||
@@ -139,7 +140,7 @@ var AbstractView = Factory.extend({
|
||||
this.controllerParams = {
|
||||
actionViews: params.actionViews,
|
||||
activeActions: {
|
||||
edit: this.arch.attrs.edit ? !!JSON.parse(this.arch.attrs.edit) : true,
|
||||
edit: typeof params.editable === 'boolean' ? params.editable : this.arch.attrs.edit ? !!JSON.parse(this.arch.attrs.edit) : true,
|
||||
create: this.arch.attrs.create ? !!JSON.parse(this.arch.attrs.create) : true,
|
||||
delete: this.arch.attrs.delete ? !!JSON.parse(this.arch.attrs.delete) : true,
|
||||
duplicate: this.arch.attrs.duplicate ? !!JSON.parse(this.arch.attrs.duplicate) : true,
|
||||
|
||||
@@ -664,6 +664,7 @@ var FormController = BasicController.extend({
|
||||
on_remove: data.on_remove,
|
||||
parentID: data.parentID,
|
||||
readonly: data.readonly,
|
||||
editable: data.editable,
|
||||
deletable: record ? data.deletable : false,
|
||||
disable_multiple_selection: data.disable_multiple_selection,
|
||||
recordID: record && record.id,
|
||||
@@ -690,6 +691,7 @@ var FormController = BasicController.extend({
|
||||
on_remove: ev.data.on_remove,
|
||||
readonly: ev.data.readonly,
|
||||
deletable: ev.data.deletable,
|
||||
editable: ev.data.editable,
|
||||
res_id: record.res_id,
|
||||
res_model: record.model,
|
||||
title: _t("Open: ") + ev.data.string,
|
||||
|
||||
@@ -73,6 +73,8 @@ var FormViewDialog = ViewDialog.extend({
|
||||
* creation mode
|
||||
* @param {boolean} [options.deletable=false] whether or not the record can
|
||||
* be deleted
|
||||
* @param {boolean} [options.editable=true] whether or not the record can
|
||||
* be edited
|
||||
* @param {boolean} [options.disable_multiple_selection=false] set to true
|
||||
* to remove the possibility to create several records in a row
|
||||
* @param {function} [options.on_saved] callback executed after saving a
|
||||
@@ -105,6 +107,7 @@ var FormViewDialog = ViewDialog.extend({
|
||||
this.shouldSaveLocally = options.shouldSaveLocally;
|
||||
this.readonly = options.readonly;
|
||||
this.deletable = options.deletable;
|
||||
this.editable = options.editable;
|
||||
this.disable_multiple_selection = options.disable_multiple_selection;
|
||||
var oBtnRemove = 'o_btn_remove';
|
||||
|
||||
@@ -209,6 +212,7 @@ var FormViewDialog = ViewDialog.extend({
|
||||
parentID: self.parentID,
|
||||
recordID: self.recordID,
|
||||
isFromFormViewDialog: true,
|
||||
editable: self.editable
|
||||
});
|
||||
return formview.getController(self);
|
||||
}).then(function (formView) {
|
||||
|
||||
@@ -10935,7 +10935,7 @@ QUnit.module('Views', {
|
||||
});
|
||||
|
||||
QUnit.test('Quick Edition: Readonly one2many list', async function (assert) {
|
||||
assert.expect(7);
|
||||
assert.expect(4);
|
||||
|
||||
this.data.partner.records[0].p.push(2);
|
||||
|
||||
@@ -10962,13 +10962,8 @@ QUnit.module('Views', {
|
||||
|
||||
await testUtils.dom.click(form.$('.o_field_cell:first'));
|
||||
|
||||
assert.containsOnce(form, '.o_form_view.o_form_editable',
|
||||
'should switch into edit mode');
|
||||
assert.containsNone(form, '.o_field_x2many_list_row_add',
|
||||
'create line should still not be displayed');
|
||||
assert.containsNone(form, '.o_list_record_remove',
|
||||
'remove buttons should still not be displayed');
|
||||
assert.containsNone(form, 'input');
|
||||
assert.containsOnce(form, '.o_form_view.o_form_readonly',
|
||||
'should not switch into edit mode');
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
@@ -11326,7 +11321,7 @@ QUnit.module('Views', {
|
||||
|
||||
await testUtils.dom.click(form.$('.o_field_widget[name="timmy"] label:eq(1)'));
|
||||
|
||||
assert.containsOnce(form, '.o_form_view.o_form_editable');
|
||||
assert.containsOnce(form, '.o_form_view.o_form_readonly');
|
||||
assert.containsNone(form, 'input[type="checkbox"]:not(:disabled)');
|
||||
assert.containsNone(form, 'input[type="checkbox"]:checked');
|
||||
|
||||
@@ -11408,9 +11403,9 @@ QUnit.module('Views', {
|
||||
|
||||
await testUtils.dom.click(form.$('.o_field_widget[name="trululu"] label:eq(1)'));
|
||||
|
||||
assert.containsOnce(form, '.o_form_view.o_form_editable');
|
||||
assert.containsOnce(form, '.o_form_view.o_form_readonly');
|
||||
assert.containsOnce(form, 'input[type="radio"]:eq(2):checked');
|
||||
assert.containsNone(form, 'input[type="checkbox"]:not(:disabled)');
|
||||
assert.containsNone(form, 'input[type="radio"]:not(:disabled)');
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user