forked from Techsystech/web
[IMP/FIX] web_widget_domain_editor_dialog: work in dialog
- IMP: Now it's possible to work with the domain editor when the widget has de in_dialog option. - FIX: When a boolean opertator was present in the domain, the editor dialog would raise an error as the default filter couldn't be interpretated. TT3282713.0
parent
0ca42805e9
commit
7446ee101b
|
@ -26,7 +26,9 @@ odoo.define("web_widget_domain_editor_dialog.basic_fields", function(require) {
|
||||||
readonly: false,
|
readonly: false,
|
||||||
disable_multiple_selection: false,
|
disable_multiple_selection: false,
|
||||||
no_create: true,
|
no_create: true,
|
||||||
|
|
||||||
on_selected: function(selected_ids) {
|
on_selected: function(selected_ids) {
|
||||||
|
_this.inDomainEditor = true;
|
||||||
_this.domainSelector
|
_this.domainSelector
|
||||||
.setDomain(this.get_domain(selected_ids))
|
.setDomain(this.get_domain(selected_ids))
|
||||||
.then(_this._replaceContent.bind(_this));
|
.then(_this._replaceContent.bind(_this));
|
||||||
|
@ -39,5 +41,14 @@ odoo.define("web_widget_domain_editor_dialog.basic_fields", function(require) {
|
||||||
this.trigger("dialog_opened", dialog);
|
this.trigger("dialog_opened", dialog);
|
||||||
return dialog;
|
return dialog;
|
||||||
},
|
},
|
||||||
|
_onDomainSelectorValueChange: function() {
|
||||||
|
// This allows the domain editor to work with in dialog mode
|
||||||
|
const inDialog = this.inDialog;
|
||||||
|
if (this.inDomainEditor) {
|
||||||
|
this.inDialog = false;
|
||||||
|
}
|
||||||
|
this._super.apply(this, arguments);
|
||||||
|
this.inDialog = inDialog;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,13 +13,24 @@ odoo.define("web_widget_domain_editor_dialog.DomainEditorDialog", function(requi
|
||||||
init: function() {
|
init: function() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
const _this = this;
|
const _this = this;
|
||||||
|
let domain = Domain.prototype.stringToArray(_this.options.default_domain);
|
||||||
|
// HACK: dynamicFilters don't work fine with booleans as they pass through
|
||||||
|
// pyeval as a jason domain. This way, they're full compatible and we avoid
|
||||||
|
// making an _rpc call.
|
||||||
|
domain = domain.map(tuple => {
|
||||||
|
if (tuple[2] === true) {
|
||||||
|
tuple[2] = 1;
|
||||||
|
}
|
||||||
|
if (tuple[2] === false) {
|
||||||
|
tuple[2] = 0;
|
||||||
|
}
|
||||||
|
return tuple;
|
||||||
|
});
|
||||||
this.options = _.defaults(this.options, {
|
this.options = _.defaults(this.options, {
|
||||||
dynamicFilters: [
|
dynamicFilters: [
|
||||||
{
|
{
|
||||||
description: _.str.sprintf(_t("Selected domain")),
|
description: _.str.sprintf(_t("Selected domain")),
|
||||||
domain: Domain.prototype.stringToArray(
|
domain: domain,
|
||||||
_this.options.default_domain
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue