From 388e258ce8c2a4fbd5e2ec5ec746bb91ca48d97f Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 21 Dec 2016 16:35:09 +0100 Subject: [FIX] web: rotate graph label When there are too many labels to display on the x-axis, they overlap and it simply becomes unreadable. By slightly rotating them, this can be avoided in most cases. opw-697625 opw-697626 --- addons/web/static/src/js/views/graph_widget.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views/graph_widget.js b/addons/web/static/src/js/views/graph_widget.js index db6418fd15a..2aa98965329 100644 --- a/addons/web/static/src/js/views/graph_widget.js +++ b/addons/web/static/src/js/views/graph_widget.js @@ -166,7 +166,7 @@ return Widget.extend({ var chart = nv.models.multiBarChart(); var maxVal = _.max(values, function(v) {return v.y}) chart.options({ - margin: {left: 12 * String(maxVal && maxVal.y || 10000000).length}, + margin: {left: 12 * String(maxVal && maxVal.y || 10000000).length, bottom: 60}, delay: 250, transition: 10, showLegend: _.size(data) <= MAX_LEGEND_LENGTH, @@ -175,7 +175,7 @@ return Widget.extend({ rightAlignYAxis: false, stacked: this.stacked, reduceXTicks: false, - // rotateLabels: 40, + rotateLabels: -20, showControls: (this.groupbys.length > 1) }); chart.yAxis.tickFormat(function(d) { return formats.format_value(d, { type : 'float' });}); -- cgit v1.2.3 From 6797d6a7c639c22f9987207481accee9b9b5b486 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 22 Aug 2017 13:41:12 +0200 Subject: [FIX] web: don't save empty required x2manys Before this commit, the same function was called at the rendering and at the writing of a field. It caused a field that should be displayed all the time (field is never false) to ignore its required attribute, in particular with one2many's. After this commit, we differentiate between the rendering function and the validate to write function, making a type of field both requirable and always displayed even if empty OPW 766002 Closes odoo/enterprise#1306 Cherry-pick odoo/enterprise@be8e5709918b42e6c60fe0327329f855a29f5a99 --- addons/web/static/src/js/views/form_common.js | 13 ++++++++++++- addons/web/static/src/js/views/form_relational_widgets.js | 12 ++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views/form_common.js b/addons/web/static/src/js/views/form_common.js index 6752885f372..3ed2e77e695 100644 --- a/addons/web/static/src/js/views/form_common.js +++ b/addons/web/static/src/js/views/form_common.js @@ -716,7 +716,7 @@ var AbstractField = FormWidget.extend(FieldInterface, { } }, _toggle_label: function() { - var empty = this.get('effective_readonly') && this.is_false(); + var empty = this.get('effective_readonly') && !this.is_set(); this.$label.toggleClass('o_form_label_empty', empty).toggleClass('o_form_label_false', this.get('effective_readonly') && this.get('value') === false); this.$el.toggleClass('o_form_field_empty', empty); }, @@ -755,10 +755,21 @@ var AbstractField = FormWidget.extend(FieldInterface, { /** * Method useful to implement to ease validity testing. Must return true if the current * value is similar to false in OpenERP. + * Used at write time, in particular when the field is required */ is_false: function() { return this.get('value') === false; }, + + /** + * Method called at rendering time to determine if the field should be + * displayed (non-empty) or not (empty) + * We test the same thing as is_false but with different semantics + */ + is_set: function() { + return !this.is_false(); + }, + _check_css_flags: function() { var show_translate = (!this.get('effective_readonly') && this.field_manager.get('actual_mode') !== "create"); this.$translate.toggleClass('o_translate_active', !!show_translate); 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 9a24eef6ae5..722ef2f4932 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -345,8 +345,8 @@ var FieldMany2One = common.AbstractField.extend(common.CompletionFieldMixin, com if (!this.get("effective_readonly")) { this.$input.val(noValue ? "" : (str.split("\n")[0].trim() || $(data.noDisplayContent).text())); this.current_display = this.$input.val(); - this.$follow_button.toggle(!this.is_false()); - this.$el.toggleClass('o_with_button', !!this.$follow_button && this.$follow_button.length > 0 && !this.is_false()); + this.$follow_button.toggle(this.is_set()); + this.$el.toggleClass('o_with_button', !!this.$follow_button && this.$follow_button.length > 0 && this.is_set()); } else { this.$el.html(noValue ? "" : (_.escape(str.trim()).split("\n").join("
") || data.noDisplayContent)); // Define callback to perform when clicking on the field @@ -871,6 +871,10 @@ var FieldX2Many = AbstractManyField.extend({ is_false: function () { return _(this.dataset.ids).isEmpty(); }, + is_set: function() { + // always consider that field is "set" hence displayed + return true; + }, }); var X2ManyDataSet = data.BufferedDataSet.extend({ @@ -1697,6 +1701,10 @@ var FieldMany2ManyCheckBoxes = AbstractManyField.extend(common.ReinitializeField is_false: function() { return false; }, + is_set: function() { + // always consider that field is "set" hence displayed + return true; + }, }); core.form_widget_registry -- cgit v1.2.3