diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-01-23 14:51:11 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-01-23 14:51:11 +0100 |
| commit | fded0065ae217ed3f3ccda24a230677e92a0e8d1 (patch) | |
| tree | dff3b3970e89ab546b7fb64d74df0090d0ec8332 /addons/web/static/src/js/views/form_widgets.js | |
| parent | ad766ba20db73ceb433b9afe3b5db3e52cf1494a (diff) | |
| parent | 6c4389df41fb29f9707b205a8dcca13b3bf8a322 (diff) | |
[MERGE] forward port branch saas-14 up to 6c4389df41f
Diffstat (limited to 'addons/web/static/src/js/views/form_widgets.js')
| -rw-r--r-- | addons/web/static/src/js/views/form_widgets.js | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/addons/web/static/src/js/views/form_widgets.js b/addons/web/static/src/js/views/form_widgets.js index 7a13fc6d1f7..31e83d24777 100644 --- a/addons/web/static/src/js/views/form_widgets.js +++ b/addons/web/static/src/js/views/form_widgets.js @@ -447,9 +447,11 @@ var FieldDomain = common.AbstractField.extend(common.ReinitializeFieldMixin).ext }, initialize_content: function () { this._super.apply(this, arguments); - this.$recordsCountDisplay = this.$(".o_domain_records_count"); - this.$showSelectionButton = this.$(".o_domain_show_selection_button"); - this.$errorMessage = this.$(".o_domain_error_message"); + this.$panel = this.$(".o_form_field_domain_panel"); + this.$showSelectionButton = this.$panel.find(".o_domain_show_selection_button"); + this.$recordsCountDisplay = this.$showSelectionButton.find(".o_domain_records_count"); + this.$errorMessage = this.$panel.find(".o_domain_error_message"); + this.$modelMissing = this.$(".o_domain_model_missing"); }, set_value: function (value, noDomainSelectorRender) { this._noDomainSelectorRender = !!noDomainSelectorRender; @@ -459,6 +461,17 @@ var FieldDomain = common.AbstractField.extend(common.ReinitializeFieldMixin).ext render_value: function() { this._super.apply(this, arguments); + // If there is no set model, the field should only display the corresponding error message + this.$panel.toggleClass("o_hidden", !this.model); + this.$modelMissing.toggleClass("o_hidden", !!this.model); + if (!this.model) { + if (this.domainSelector) { + this.domainSelector.destroy(); + this.domainSelector = undefined; + } + return; + } + var domain = pyeval.eval("domain", this.get("value") || "[]"); // Recreate domain widget with new domain value @@ -496,14 +509,14 @@ var FieldDomain = common.AbstractField.extend(common.ReinitializeFieldMixin).ext return new common.SelectCreateDialog(this, { title: _t("Selected records"), res_model: this.model, - domain: this.get("value"), + domain: this.get("value") || "[]", no_create: true, readonly: true, disable_multiple_selection: true, }).open(); }, openDomainDialog: function () { - new DomainSelectorDialog(this, this.model, this.get("value"), { + new DomainSelectorDialog(this, this.model, this.get("value") || "[]", { readonly: this.get("effective_readonly"), fs_filters: this.options.fs_filters, debugMode: session.debug, |
