From 03ef19e40c0fc378c18fa0dbfa830f29be852406 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 11 Oct 2017 16:37:38 +0200 Subject: [PATCH] [FIX] web, hr_timesheet_sheet: make m2o friendly-usable outside of views Before this commit, m2o external button was always floating outside the m2o main DOM element, on the right. This induced problems when using the m2o outside of views (like in Odoo Studio). Now, the m2o design is made so that this button is inside the m2o, except in form views where we expect the button to overflow in the tables' right paddings. --- .../static/src/less/timesheet.less | 8 +------- .../static/src/js/fields/relational_fields.js | 2 +- addons/web/static/src/less/fields.less | 10 +--------- addons/web/static/src/less/form_view.less | 17 +++++++++++------ addons/web/static/src/less/list_view.less | 3 --- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/addons/hr_timesheet_sheet/static/src/less/timesheet.less b/addons/hr_timesheet_sheet/static/src/less/timesheet.less index 86f106e6078..611042f087b 100644 --- a/addons/hr_timesheet_sheet/static/src/less/timesheet.less +++ b/addons/hr_timesheet_sheet/static/src/less/timesheet.less @@ -28,9 +28,6 @@ .oe_timesheet_button_add { margin-left: 8px; } - .o_with_button + .oe_timesheet_button_add { - margin-left: 45px; - } } .oe_timesheet_weekly_today { @@ -47,7 +44,7 @@ > div { .o-flex-display(); .o-align-items(center); - + .o_field_many2one { min-width: 200px; margin: 0; @@ -62,9 +59,6 @@ .o-flex(0, 0, auto); margin-left: 8px; } - .o_with_button + .oe_timesheet_button_add { - margin-left: 45px; - } } } } diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 194165b2206..9218897fb1f 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -422,7 +422,7 @@ var FieldMany2One = AbstractField.extend({ _updateExternalButton: function () { var has_external_button = !this.nodeOptions.no_open && !this.floating && this.isSet(); this.$external_button.toggle(has_external_button); - this.$el.toggleClass('o_with_button', has_external_button); + this.$el.toggleClass('o_with_button', has_external_button); // Should not be required anymore but kept for compatibility }, diff --git a/addons/web/static/src/less/fields.less b/addons/web/static/src/less/fields.less index 02885ef3514..fe7a4ad0d8e 100644 --- a/addons/web/static/src/less/fields.less +++ b/addons/web/static/src/less/fields.less @@ -49,7 +49,7 @@ // Dropdowns input (many2one, ...) .o_input_dropdown { - .o-flex(1, 0, auto); + .o-flex(1, 1, auto); position: relative; width: 100%; @@ -185,14 +185,6 @@ color: @brand-success; } - // Many2One - &.o_field_many2one { - .o-inline-flex-display(); - > span, > button { - .o-flex(0, 0, auto); - } - } - // Handle widget &.o_row_handle { cursor: ns-resize; diff --git a/addons/web/static/src/less/form_view.less b/addons/web/static/src/less/form_view.less index c4990e6c824..7224ff5c20d 100644 --- a/addons/web/static/src/less/form_view.less +++ b/addons/web/static/src/less/form_view.less @@ -64,12 +64,6 @@ .o-align-self(center); } } - - .o_row .o_field_many2one, .o_field_many2one.oe_inline { - &.o_with_button:not(:last-child) { // If invisible element as last child, this line has no effect but that's not very important - margin-right: (35px + (@odoo-form-spacing-unit/2)); - } - } } .o_row > div > .o_field_widget { @@ -338,6 +332,17 @@ } } + :not(.o_row) > .o_field_widget, + .o_row > .o_field_widget:last-child { // Note: this does not take care + // of an invisible last-child but + // it does not really matter + // Makes extra buttons (e.g. m2o external button) overflow on the + // right padding of the parent element + .o_input_dropdown { + .o-flex(1, 0, auto); + } + } + &.o_label_nowrap .o_form_label { white-space: nowrap; } diff --git a/addons/web/static/src/less/list_view.less b/addons/web/static/src/less/list_view.less index d84f673ab75..4a5429c6de2 100644 --- a/addons/web/static/src/less/list_view.less +++ b/addons/web/static/src/less/list_view.less @@ -153,9 +153,6 @@ .o_field_widget { min-width: 0; } - .o_with_button .o_input_dropdown { - width: 1%; // Hack so that the sibling button is not overlapped - } .o_input_dropdown, .o_datepicker { > .o_input { padding-right: 15px; // To prevent caret overlapping