From 250e716c3a12e88acb4a199b427dc47d4ec55d5d Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 19 Apr 2017 18:06:12 +0200 Subject: [PATCH] [REF] web, *: restore views design Since the new views merge, a lot of design elements were broken. This was particularly impacting the fields in the editable list view; indeed the editable list view is not using an inline form view anymore so the fields in the list were not properly styled as the LESS was still defined assuming the form view environment (for example the invalid fields were red for o2m fields in form view but not in editable list view even though they got the right CSS class). This commit refactor the LESS following these rules: - No more division of non-layout and layout rules. Dividing LESS rules in x_layout.less and x.less was a mistake. Many rules can be considered to be layout and not layout at the same time, developers always have to switch from one file part to the other, many CSS selectors (and rules!) are duplicated for nothing, ... - Field style is extracted from x_view.less and put in the new fields.less file. As before, the fields_extra.less will contain the rules specific to community so that the enterprise repo can override those by replacing the whole file. - Many classes have been renamed so that o_form_x_y becomes o_x_y as many classes can now be applied outside of form view. These classes should not be used in templates anyway. The commit also changes the DOM of fields so that it is more minimalist (no useless parent div, etc). Input elements are not automatically styled anymore, they have to get the o_input class explicitely. This allows to fix lots of small style bugs of previous versions (required monetary field had not the proper style, readonly m2m tags appeared as editable, ...). This also improves the LESS code. The editable list view should also completely stop flickering on chrome and firefox. The commit also removes the orange outline on list view dirty cells. The commit also removes deprecated static xml, LESS and other code. Notice there are still styles to restore/fix and LESS to improve. --- .../reconciliation/reconciliation_renderer.js | 4 +- .../static/src/xml/account_payment.xml | 2 +- .../tests/account_payment_field_tests.js | 10 +- .../static/tests/reconciliation_tests.js | 10 +- .../static/src/js/barcode_form_view.js | 2 +- addons/board/static/src/less/dashboard.less | 2 +- .../calendar/static/tests/calendar_tests.js | 12 +- addons/crm/static/src/js/tour.js | 2 +- .../views/crm_lead_views.xml | 2 +- addons/gamification/views/challenge.xml | 2 +- .../static/src/less/hr_org_chart.less | 2 +- .../views/hr_recruitment_views.xml | 4 +- .../views/hr_applicant_views.xml | 4 +- .../views/hr_timesheet_sheet_views.xml | 2 +- .../static/src/less/timesheet.less | 2 +- addons/lunch/static/tests/lunch_tests.js | 2 +- addons/lunch/views/lunch_views.xml | 2 +- addons/mail/static/src/js/composer.js | 4 +- .../mail/static/src/less/mail_activity.less | 2 +- addons/mail/static/tests/chatter_tests.js | 2 +- addons/mail/views/mail_template_views.xml | 4 +- .../views/marketing_campaign_views.xml | 2 +- addons/mrp/static/src/less/mrp.less | 2 +- addons/mrp/static/src/xml/mrp.xml | 6 +- addons/mrp/static/tests/mrp_tests.js | 16 +- addons/mrp/views/mrp_production_views.xml | 4 +- addons/mrp/views/mrp_routing_views.xml | 2 +- addons/mrp/views/mrp_workcenter_views.xml | 8 +- addons/mrp/views/mrp_workorder_views.xml | 2 +- addons/payment/views/payment_views.xml | 4 +- .../point_of_sale/views/pos_session_view.xml | 4 +- addons/product/views/product_views.xml | 2 +- addons/project/static/src/js/tour.js | 2 +- addons/sale/static/src/js/tour.js | 6 +- addons/sale_crm/views/crm_lead_views.xml | 2 +- addons/stock/views/product_views.xml | 12 +- addons/web/controllers/main.py | 6 - addons/web/doc/list_view.rst | 2 +- addons/web/static/src/js/core/dom.js | 41 +- .../static/src/js/fields/abstract_field.js | 2 +- .../web/static/src/js/fields/basic_fields.js | 105 ++-- .../static/src/js/fields/field_registry.js | 2 +- .../web/static/src/js/fields/field_utils.js | 19 +- .../static/src/js/fields/relational_fields.js | 37 +- .../src/js/views/basic/basic_renderer.js | 18 +- .../static/src/js/views/form/form_renderer.js | 45 +- .../js/views/list/list_editable_renderer.js | 54 +- .../src/js/widgets/switch_company_menu.js | 4 +- addons/web/static/src/less/animation.less | 43 +- addons/web/static/src/less/control_panel.less | 135 +++-- .../static/src/less/control_panel_layout.less | 70 --- addons/web/static/src/less/fields.less | 367 ++++++++++++ addons/web/static/src/less/fields_extra.less | 58 ++ addons/web/static/src/less/form_view.less | 545 +++++++++--------- .../web/static/src/less/form_view_extra.less | 145 +++-- .../web/static/src/less/form_view_layout.less | 373 ------------ .../src/less/form_view_layout_extra.less | 109 ---- addons/web/static/src/less/kanban_view.less | 7 +- addons/web/static/src/less/list_view.less | 148 ++--- .../web/static/src/less/list_view_extra.less | 10 + .../static/src/less/model_field_selector.less | 2 - addons/web/static/src/less/navbar.less | 59 +- addons/web/static/src/less/new_views.less | 83 --- .../static/src/less/search_view_extra.less | 3 +- .../static/src/less/switch_company_menu.less | 6 - addons/web/static/src/less/tree_view.less | 50 -- addons/web/static/src/less/utils.less | 4 +- addons/web/static/src/less/views.less | 99 +--- addons/web/static/src/less/web_calendar.less | 2 +- .../web/static/src/less/webclient_extra.less | 35 +- addons/web/static/src/xml/base.xml | 224 +------ .../static/tests/fields/basic_fields_tests.js | 500 ++++++++-------- .../tests/fields/relational_fields_tests.js | 380 ++++++------ .../web/static/tests/views/calendar_tests.js | 16 +- addons/web/static/tests/views/form_tests.js | 244 ++++---- addons/web/static/tests/views/kanban_tests.js | 14 +- addons/web/static/tests/views/list_tests.js | 61 +- addons/web/views/webclient_templates.xml | 38 +- addons/web_editor/static/src/js/backend.js | 6 +- .../static/src/less/web_editor.backend.less | 2 +- addons/web_tour/static/src/js/tour_manager.js | 3 - .../views/website_navbar_templates.xml | 2 - .../test_new_api/static/tests/x2many.js | 210 +++---- 83 files changed, 2024 insertions(+), 2516 deletions(-) delete mode 100644 addons/web/static/src/less/control_panel_layout.less create mode 100644 addons/web/static/src/less/fields.less create mode 100644 addons/web/static/src/less/fields_extra.less delete mode 100644 addons/web/static/src/less/form_view_layout.less delete mode 100644 addons/web/static/src/less/form_view_layout_extra.less create mode 100644 addons/web/static/src/less/list_view_extra.less delete mode 100644 addons/web/static/src/less/new_views.less delete mode 100644 addons/web/static/src/less/switch_company_menu.less delete mode 100644 addons/web/static/src/less/tree_view.less diff --git a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js index 311bea5d403..003f1a768d8 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js @@ -55,7 +55,7 @@ var StatementRenderer = Widget.extend(FieldManagerMixin, { {mode: 'edit'}); self.name.appendTo(self.$('.statement_name_edition')).then(function () { - self.name.$el.addClass('o_form_required'); + self.name.$el.addClass('o_required_modifier'); }); self.$('.statement_name').text(self._initialState.bank_statement_id.display_name); }); @@ -458,7 +458,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { self.$('.create').append($create); function addRequiredStyle(widget) { - widget.$el.addClass('o_form_required'); + widget.$el.addClass('o_required_modifier'); } }); }, diff --git a/addons/account/static/src/xml/account_payment.xml b/addons/account/static/src/xml/account_payment.xml index 61b2e50b5bc..a8c3c5e6896 100644 --- a/addons/account/static/src/xml/account_payment.xml +++ b/addons/account/static/src/xml/account_payment.xml @@ -25,7 +25,7 @@ - Paid on + Paid on diff --git a/addons/account/static/tests/account_payment_field_tests.js b/addons/account/static/tests/account_payment_field_tests.js index b0b6aff3052..1bbeaf6d352 100644 --- a/addons/account/static/tests/account_payment_field_tests.js +++ b/addons/account/static/tests/account_payment_field_tests.js @@ -62,20 +62,20 @@ QUnit.module('account', { }, }); - assert.strictEqual(form.$('.o_form_field[name="payments_widget"]').text().replace(/[\s\n\r]+/g, ' '), + assert.strictEqual(form.$('.o_field_widget[name="payments_widget"]').text().replace(/[\s\n\r]+/g, ' '), " Paid on 04/25/2017 $ 555.00 ", "should display payment information"); - form.$('.o_form_field[name="outstanding_credits_debits_widget"] .outstanding_credit_assign').trigger('click'); + form.$('.o_field_widget[name="outstanding_credits_debits_widget"] .outstanding_credit_assign').trigger('click'); - assert.strictEqual(form.$('.o_form_field[name="outstanding_credits_debits_widget"]').text().replace(/[\s\n\r]+/g, ' '), + assert.strictEqual(form.$('.o_field_widget[name="outstanding_credits_debits_widget"]').text().replace(/[\s\n\r]+/g, ' '), " Outstanding credits Add INV/2017/0004 $ 100.00 ", "should display outstanding information"); - form.$('.o_form_field[name="payments_widget"] .js_payment_info').trigger('focus'); + form.$('.o_field_widget[name="payments_widget"] .js_payment_info').trigger('focus'); form.$('.popover .js_open_payment').trigger('click'); - form.$('.o_form_field[name="payments_widget"] .js_payment_info').trigger('focus'); + form.$('.o_field_widget[name="payments_widget"] .js_payment_info').trigger('focus'); form.$('.popover .js_unreconcile_payment').trigger('click'); form.destroy(); diff --git a/addons/account/static/tests/reconciliation_tests.js b/addons/account/static/tests/reconciliation_tests.js index 293baaf5480..b44c82d6b80 100644 --- a/addons/account/static/tests/reconciliation_tests.js +++ b/addons/account/static/tests/reconciliation_tests.js @@ -512,7 +512,7 @@ QUnit.module('account', { assert.strictEqual(widget.$('.create').length, 1, "should have 'create' panel"); assert.strictEqual(widget.$('thead').text().replace(/[\n\r\s]+/g, ' '), " 101401 2017-01-01 SAJ/2014/002 and SAJ/2014/003 $ 1,175.00 ", "should display the line information"); - assert.ok(widget.$('caption .o_form_field.o_form_field_many2one').length, "should display the many2one with to select a partner"); + assert.ok(widget.$('caption .o_field_many2one').length, "should display the many2one with to select a partner"); assert.strictEqual(clientAction.$('[data-mode="inactive"]').length, 3, "should be as 'inactive' mode by default"); assert.strictEqual(widget.$el.data('mode'), 'match', "the first one should automatically switch to match mode"); @@ -540,12 +540,12 @@ QUnit.module('account', { var widget = clientAction.widgets[0]; - assert.strictEqual(widget.$('.o_form_input_dropdown input').val(), "Agrolait", "the partner many2one should display agrolait"); - assert.strictEqual(clientAction.widgets[2].$('.o_form_input_dropdown input').val(), "Camptocamp", "the partner many2one should display Camptocamp"); + assert.strictEqual(widget.$('.o_input_dropdown input').val(), "Agrolait", "the partner many2one should display agrolait"); + assert.strictEqual(clientAction.widgets[2].$('.o_input_dropdown input').val(), "Camptocamp", "the partner many2one should display Camptocamp"); widget.$('.accounting_view tfoot td:first').trigger('click'); - assert.strictEqual(widget.$('.create .o_form_input').length, 6, + assert.strictEqual(widget.$('.create .o_input').length, 6, "create panel should display 5 fields (account_id, tax_id, analytic_account_id, label, amount)"); - assert.strictEqual(widget.$('.create .create_account_id .o_form_required, .create .create_label .o_form_required, .create .create_amount .o_form_required').length, 3, + assert.strictEqual(widget.$('.create .create_account_id .o_required_modifier, .create .create_label .o_required_modifier, .create .create_amount .o_required_modifier').length, 3, "account_id, label and amount should be required fields"); assert.strictEqual(widget.$('.create .create_label input').val(), 'SAJ/2014/002 and SAJ/2014/003', "should use the name of the reconciliation line for the default label value"); diff --git a/addons/barcodes/static/src/js/barcode_form_view.js b/addons/barcodes/static/src/js/barcode_form_view.js index 2d74e6db8bb..678b23444a8 100644 --- a/addons/barcodes/static/src/js/barcode_form_view.js +++ b/addons/barcodes/static/src/js/barcode_form_view.js @@ -312,7 +312,7 @@ FormRenderer.include({ var commands = {}; commands.barcode = function () {return $.when();}; commands['O-BTN.' + node.attrs.barcode_trigger] = function () { - if (!$button.hasClass('o_form_invisible')) { + if (!$button.hasClass('o_invisible_modifier')) { $button.click(); } return $.when(); diff --git a/addons/board/static/src/less/dashboard.less b/addons/board/static/src/less/dashboard.less index 36f0727c0ac..72131e2fa2e 100644 --- a/addons/board/static/src/less/dashboard.less +++ b/addons/board/static/src/less/dashboard.less @@ -111,7 +111,7 @@ } // Override border of many2manytags defined for form_views - .o_kanban_view .o_kanban_record .oe_kanban_list_many2many .o_form_field_many2manytags { + .o_kanban_view .o_kanban_record .oe_kanban_list_many2many .o_field_many2manytags { border: none; } } diff --git a/addons/calendar/static/tests/calendar_tests.js b/addons/calendar/static/tests/calendar_tests.js index ad7f9fd141c..bf2326ce848 100644 --- a/addons/calendar/static/tests/calendar_tests.js +++ b/addons/calendar/static/tests/calendar_tests.js @@ -62,16 +62,16 @@ QUnit.module('calendar', { }, }); - assert.ok(form.$('.o_form_field[name="partner_ids"]').hasClass('o_form_field_many2manytags')); - assert.strictEqual(form.$('.o_form_field[name="partner_ids"] > span').length, 2, + assert.ok(form.$('.o_field_widget[name="partner_ids"]').hasClass('o_field_many2manytags')); + assert.strictEqual(form.$('.o_field_widget[name="partner_ids"] > span').length, 2, "there should be 2 tags"); - assert.strictEqual(form.$('.o_form_field[name="partner_ids"] > span:first').text().trim(), "Jesus", + assert.strictEqual(form.$('.o_field_widget[name="partner_ids"] > span:first').text().trim(), "Jesus", "the tag should be correctly named"); - assert.ok(form.$('.o_form_field[name="partner_ids"] > span:first .o_calendar_invitation').hasClass('accepted'), + assert.ok(form.$('.o_field_widget[name="partner_ids"] > span:first .o_calendar_invitation').hasClass('accepted'), "Jesus should attend the meeting"); - assert.strictEqual(form.$('.o_form_field[name="partner_ids"] > span[data-id="2"]').text().trim(), "Mahomet", + assert.strictEqual(form.$('.o_field_widget[name="partner_ids"] > span[data-id="2"]').text().trim(), "Mahomet", "the tag should be correctly named"); - assert.ok(form.$('.o_form_field[name="partner_ids"] > span[data-id="2"] .o_calendar_invitation').hasClass('needsAction'), + assert.ok(form.$('.o_field_widget[name="partner_ids"] > span[data-id="2"] .o_calendar_invitation').hasClass('needsAction'), "Mohamet should still confirm his attendance to the meeting"); form.destroy(); diff --git a/addons/crm/static/src/js/tour.js b/addons/crm/static/src/js/tour.js index ae2f7169825..271275cc83b 100644 --- a/addons/crm/static/src/js/tour.js +++ b/addons/crm/static/src/js/tour.js @@ -45,7 +45,7 @@ tour.register('crm_tour', { content: _t("Schedule an activity by clicking here"), position: "bottom" }, { - trigger: ".modal-body .o_form_field_many2one", + trigger: ".modal-body .o_field_many2one", extra_trigger: ".o_opportunity_kanban", content: _t("

You will be able to customize your followup activities. Examples:

  1. introductory email
  2. call 10 days after
  3. second call 3 days after, ...

Select a standard activity for now on.

"), position: "bottom", diff --git a/addons/crm_project_issue/views/crm_lead_views.xml b/addons/crm_project_issue/views/crm_lead_views.xml index ff92a4d52c3..4ea470237c2 100644 --- a/addons/crm_project_issue/views/crm_lead_views.xml +++ b/addons/crm_project_issue/views/crm_lead_views.xml @@ -9,7 +9,7 @@ @@ -478,7 +478,7 @@ diff --git a/addons/hr_recruitment_survey/views/hr_applicant_views.xml b/addons/hr_recruitment_survey/views/hr_applicant_views.xml index 02f0ff3f668..b1c7c09dedb 100644 --- a/addons/hr_recruitment_survey/views/hr_applicant_views.xml +++ b/addons/hr_recruitment_survey/views/hr_applicant_views.xml @@ -25,7 +25,7 @@ help="Answer related job question" context="{'survey_id': survey_id}" attrs="{'invisible':[('survey_id','=',False)]}"> -
+
Start Interview
@@ -36,7 +36,7 @@ type="object" help="Print interview report" attrs="{'invisible':[('survey_id','=',False)]}"> -
+
Print Interview
diff --git a/addons/hr_timesheet_attendance/views/hr_timesheet_sheet_views.xml b/addons/hr_timesheet_attendance/views/hr_timesheet_sheet_views.xml index dbec63ccd51..7b87b2ff4de 100644 --- a/addons/hr_timesheet_attendance/views/hr_timesheet_sheet_views.xml +++ b/addons/hr_timesheet_attendance/views/hr_timesheet_sheet_views.xml @@ -42,7 +42,7 @@ name="%(hr_timesheet_attendance.act_hr_timesheet_sheet_sheet_2_hr_analytic_timesheet)d" class="oe_stat_button" icon="fa-clock-o"> -
+
Timesheet
diff --git a/addons/hr_timesheet_sheet/static/src/less/timesheet.less b/addons/hr_timesheet_sheet/static/src/less/timesheet.less index c052e99fc47..86f106e6078 100644 --- a/addons/hr_timesheet_sheet/static/src/less/timesheet.less +++ b/addons/hr_timesheet_sheet/static/src/less/timesheet.less @@ -48,7 +48,7 @@ .o-flex-display(); .o-align-items(center); - .o_form_field_many2one { + .o_field_many2one { min-width: 200px; margin: 0; } diff --git a/addons/lunch/static/tests/lunch_tests.js b/addons/lunch/static/tests/lunch_tests.js index fc48cb2df23..2b0405307f0 100644 --- a/addons/lunch/static/tests/lunch_tests.js +++ b/addons/lunch/static/tests/lunch_tests.js @@ -74,7 +74,7 @@ QUnit.module('lunch', { }, }); - var widgetText = form.$('.o_form_field[name="previous_order_widget"]').text(); + var widgetText = form.$('.o_field_widget[name="previous_order_widget"]').text(); assert.ok(widgetText.indexOf('This is the first time you order a meal') !== -1, "the widget should display its no content text"); assert.strictEqual(form.$('.o_lunch_vignette').length, 0, diff --git a/addons/lunch/views/lunch_views.xml b/addons/lunch/views/lunch_views.xml index 32828e4842e..dc34b96e6d4 100644 --- a/addons/lunch/views/lunch_views.xml +++ b/addons/lunch/views/lunch_views.xml @@ -357,7 +357,7 @@ name="%(lunch_cashmove_action_account)d" icon="fa-money" type="action"> -
+
Balance
diff --git a/addons/mail/static/src/js/composer.js b/addons/mail/static/src/js/composer.js index 88053c22447..edfb78f00db 100644 --- a/addons/mail/static/src/js/composer.js +++ b/addons/mail/static/src/js/composer.js @@ -351,7 +351,7 @@ var BasicComposer = Widget.extend(chat_mixin, { events: { "keydown .o_composer_input textarea": "on_keydown", "keyup .o_composer_input": "on_keyup", - "change input.o_form_input_file": "on_attachment_change", + "change input.o_input_file": "on_attachment_change", "click .o_composer_button_send": "send_message", "click .o_composer_button_add_attachment": "on_click_add_attachment", "click .o_attachment_delete": "on_attachment_delete", @@ -508,7 +508,7 @@ var BasicComposer = Widget.extend(chat_mixin, { // Events on_click_add_attachment: function () { - this.$('input.o_form_input_file').click(); + this.$('input.o_input_file').click(); this.$input.focus(); }, diff --git a/addons/mail/static/src/less/mail_activity.less b/addons/mail/static/src/less/mail_activity.less index 448913ab360..0781d24b82a 100644 --- a/addons/mail/static/src/less/mail_activity.less +++ b/addons/mail/static/src/less/mail_activity.less @@ -1,6 +1,6 @@ /* Common */ .o_mail_activity { - &.o_form_field { + &.o_field_widget { display: block; } diff --git a/addons/mail/static/tests/chatter_tests.js b/addons/mail/static/tests/chatter_tests.js index 834f58a40fe..7e90a3fbec8 100644 --- a/addons/mail/static/tests/chatter_tests.js +++ b/addons/mail/static/tests/chatter_tests.js @@ -196,7 +196,7 @@ QUnit.test('chatter is not rendered in mode === create', function (assert) { assert.strictEqual(form.$('.o_chatter').length, 0, "chatter should not be displayed"); - form.$('.o_form_input').val('coucou').trigger('input'); + form.$('.o_field_char').val('coucou').trigger('input'); form.$buttons.find('.o_form_button_save').click(); assert.strictEqual(form.$('.o_chatter').length, 1, diff --git a/addons/mail/views/mail_template_views.xml b/addons/mail/views/mail_template_views.xml index 483c80ae394..077f3f6105f 100644 --- a/addons/mail/views/mail_template_views.xml +++ b/addons/mail/views/mail_template_views.xml @@ -12,7 +12,7 @@
-