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 | |
| parent | ad766ba20db73ceb433b9afe3b5db3e52cf1494a (diff) | |
| parent | 6c4389df41fb29f9707b205a8dcca13b3bf8a322 (diff) | |
[MERGE] forward port branch saas-14 up to 6c4389df41f
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/framework/formats.js | 12 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/form_relational_widgets.js | 6 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/form_widgets.js | 23 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/list_view.js | 18 | ||||
| -rw-r--r-- | addons/web/static/src/js/widgets/data_export.js | 1 | ||||
| -rw-r--r-- | addons/web/static/src/js/widgets/domain_selector.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 5 |
7 files changed, 42 insertions, 25 deletions
diff --git a/addons/web/static/src/js/framework/formats.js b/addons/web/static/src/js/framework/formats.js index d084b285f6c..479fa1082cd 100644 --- a/addons/web/static/src/js/framework/formats.js +++ b/addons/web/static/src/js/framework/formats.js @@ -161,26 +161,30 @@ function parse_value (value, descriptor, value_if_empty) { return parse_value(value, {type: "float"}); case 'datetime': var datetime = moment(value, [date_pattern + ' ' + time_pattern, date_pattern_wo_zero + ' ' + time_pattern_wo_zero, moment.ISO_8601], true); - if (datetime.isValid()) + if (datetime.isValid() && datetime.year() >= 1900) return time.datetime_to_str(datetime.toDate()); datetime = moment(value, [date_pattern + ' ' + time_pattern, date_pattern_wo_zero + ' ' + time_pattern_wo_zero, moment.ISO_8601]); if (datetime.isValid()) { if (datetime.year() === 0) { datetime.year(moment.utc().year()); } - return time.datetime_to_str(datetime.toDate()); + if (datetime.year() >= 1900) { + return time.datetime_to_str(datetime.toDate()); + } } throw new Error(_.str.sprintf(_t("'%s' is not a correct datetime"), value)); case 'date': var date = moment(value, [date_pattern, date_pattern_wo_zero, moment.ISO_8601], true); - if (date.isValid()) + if (date.isValid() && date.year() >= 1900) return time.date_to_str(date.toDate()); date = moment(value, [date_pattern, date_pattern_wo_zero, moment.ISO_8601]); if (date.isValid()) { if (date.year() === 0) { date.year(moment.utc().year()); } - return time.date_to_str(date.toDate()); + if (date.year() >= 1900) { + return time.date_to_str(date.toDate()); + } } throw new Error(_.str.sprintf(_t("'%s' is not a correct date"), value)); case 'time': diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js index b95b708aa05..fc3db6fd1ce 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -1062,8 +1062,10 @@ var One2ManyListView = X2ManyListView.extend({ this._dataset_changed = false; }); - this.on('warning', this, function(e) { // In case of a one2many, we do not want any warning which comes from the editor - e.stop_propagation(); + this.on('warning', this, function(e) { // In case of editable list view, we do not want any warning which comes from the editor + if (this.editable()) { + e.stop_propagation(); + } }); }, do_add_record: function () { 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, diff --git a/addons/web/static/src/js/views/list_view.js b/addons/web/static/src/js/views/list_view.js index 2468db8cbcf..572fcbff95f 100644 --- a/addons/web/static/src/js/views/list_view.js +++ b/addons/web/static/src/js/views/list_view.js @@ -1502,20 +1502,16 @@ ListView.Groups = Class.extend({ }); }, setup_resequence_rows: function (list, dataset) { + var sequence_field = _(this.columns).findWhere({'widget': 'handle'}); + var seqname = sequence_field ? sequence_field.name : 'sequence'; + // drag and drop enabled if list is not sorted (unless it is sorted by - // sequence (ASC)), and there is a visible column with @widget=handle - // or "sequence" column in the view. - if ((dataset.sort && dataset.sort() && dataset.sort() !== 'sequence' - && dataset.sort() !== 'sequence ASC') - || !_(this.columns).any(function (column) { - return column.widget === 'handle' - || column.name === 'sequence'; })) { + // its sequence field (ASC)), and there is a visible column with + // @widget=handle or "sequence" column in the view. + if ((dataset.sort && [seqname, seqname + 'ASC', ''].indexOf(dataset.sort()) === -1) + || !_(this.columns).findWhere({'name': seqname})) { return; } - var sequence_field = _(this.columns).find(function (c) { - return c.widget === 'handle'; - }); - var seqname = sequence_field ? sequence_field.name : 'sequence'; // ondrop, move relevant record & fix sequences list.$current.sortable({ diff --git a/addons/web/static/src/js/widgets/data_export.js b/addons/web/static/src/js/widgets/data_export.js index 30adbd64017..d3135f86ba6 100644 --- a/addons/web/static/src/js/widgets/data_export.js +++ b/addons/web/static/src/js/widgets/data_export.js @@ -408,6 +408,7 @@ var DataExport = Dialog.extend({ }, add_field: function(field_id, string) { var $field_list = this.$('.o_fields_list'); + field_id = this.records[field_id].value || field_id; if($field_list.find("option[value='" + field_id + "']").length === 0) { $field_list.append(new Option(string, field_id)); } diff --git a/addons/web/static/src/js/widgets/domain_selector.js b/addons/web/static/src/js/widgets/domain_selector.js index 15e967ff4d4..8ae15325d34 100644 --- a/addons/web/static/src/js/widgets/domain_selector.js +++ b/addons/web/static/src/js/widgets/domain_selector.js @@ -50,7 +50,7 @@ var DomainNode = Widget.extend({ "click .o_domain_add_node_button": function (e) { e.preventDefault(); e.stopPropagation(); - this.trigger_up("add_node_clicked", {newBranch: !!$(e.target).data("branch"), child: this}); + this.trigger_up("add_node_clicked", {newBranch: !!$(e.currentTarget).data("branch"), child: this}); }, }, /// A DomainNode needs a model and domain to work. It can also receives a set of options diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 2ee261a3bdd..108bf1c0aac 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -679,8 +679,9 @@ </button> <span class="text-warning o_domain_error_message hidden"><i class="fa fa-exclamation-triangle"/> Invalid domain</span> <button t-if="widget.options.in_dialog && !widget.get('effective_readonly')" - class="btn btn-sm btn-primary o_form_field_domain_dialog_button">Edit domain</button> + class="btn btn-xs btn-primary o_form_field_domain_dialog_button">Edit domain</button> </div> + <div class="o_domain_model_missing o_hidden">Select a model to add a filter.</div> </div> <t t-name="DomainNode.ControlPanel"> @@ -711,7 +712,7 @@ <div t-name="DomainSelector" t-attf-class="o_domain_node o_domain_tree o_domain_selector #{widget.readonly ? 'o_read_mode' : 'o_edit_mode'}"> <t t-if="widget.children.length === 0"> <span>Match <strong>all records</strong></span> - <button t-if="!widget.readonly" class="btn btn-sm btn-primary o_domain_add_first_node_button"><i class="fa fa-plus"/> Add filter</button> + <button t-if="!widget.readonly" class="btn btn-xs btn-primary o_domain_add_first_node_button"><i class="fa fa-plus"/> Add filter</button> </t> <t t-else=""> <div> |
