From 2c966909e2c0b5e45912a6ff85577f0b19a5f4c9 Mon Sep 17 00:00:00 2001
From: qsm-odoo
Date: Thu, 5 Jul 2018 13:17:59 +0200
Subject: [PATCH] [FIX] *: fix some side-effects of
https://github.com/odoo/odoo/commit/9de1bc0eef6f5bfaa2a8d745431caa361ae91548
- JS Modals were not correctly built anymore, their .modal-body element
was duplicated and many without-effect JS lines were introduced (as a
side effect, the form view design was broken when inside modals)
- Tests were changed to make bugs go unnoticed. For example, the media
dialog functionnality was entirely broken because the .modal-dialog
element was not receiving the correct class anymore.
- The JS translation function is _t, not _
- Do not use the tag as a regular DOM element, it is meant to
be unique, in the section
- CSS rules were added to the utils.scss file, which is meant to contain
functions and mixins, otherwise, the rule is duplicated in every asset
- Some icons were still broken, as missed by https://github.com/odoo/odoo/commit/f90cf060a3cfeb37a67bec83264c0aaab8892b56
- Tests were changed to use [role="dialog"]/footer/header in their
selectors without any reason, this commit restores some of that to
avoid rebase conflicts with the BS4 work.
- ...
Note: other elements should still be discussed, like the direct use of
the 'o_form_label' class in views definition... but those do not cause
direct problems.
---
.../static/tests/reconciliation_tests.js | 8 +-
.../static/src/js/barcode_form_view.js | 2 +-
addons/barcodes/static/tests/barcode_tests.js | 12 +-
.../views/res_config_settings_views.xml | 7 +-
addons/board/static/tests/dashboard_tests.js | 16 +-
addons/crm/static/src/js/tour.js | 4 +-
.../document/static/tests/document_tests.js | 2 +-
.../static/src/xml/im_livechat_backend.xml | 3 +-
addons/mail/static/tests/chatter_tests.js | 32 +-
addons/pad/static/tests/pad_tests.js | 4 +-
addons/point_of_sale/static/src/xml/pos.xml | 64 +--
addons/project/static/src/js/tour.js | 2 +-
addons/project/static/tests/project_tests.js | 6 +-
addons/sale_stock/static/src/js/tour.js | 6 +-
addons/web/static/src/js/core/dialog.js | 33 +-
.../web/static/src/js/fields/basic_fields.js | 2 +-
.../kanban/kanban_column_quick_create.js | 2 +-
.../kanban/kanban_record_quick_create.js | 2 +-
.../js/views/list/list_editable_renderer.js | 10 +-
.../static/src/js/widgets/change_password.js | 2 +-
.../static/src/js/widgets/debug_manager.js | 2 +-
.../src/js/widgets/domain_selector_dialog.js | 2 +-
addons/web/static/src/scss/kanban_view.scss | 4 +
addons/web/static/src/scss/utils.scss | 8 -
addons/web/static/src/xml/dialog.xml | 2 +-
.../tests/chrome/action_manager_tests.js | 16 +-
.../static/tests/fields/basic_fields_tests.js | 10 +-
.../tests/fields/relational_fields_tests.js | 426 +++++++++---------
.../tests/fields/upgrade_fields_tests.js | 2 +-
.../web/static/tests/views/calendar_tests.js | 78 ++--
addons/web/static/tests/views/form_tests.js | 184 ++++----
addons/web/static/tests/views/kanban_tests.js | 62 +--
addons/web/static/tests/views/list_tests.js | 18 +-
.../static/tests/views/view_dialogs_tests.js | 10 +-
.../static/tests/widgets/data_export_tests.js | 28 +-
.../web_diagram/static/tests/diagram_tests.js | 22 +-
.../static/lib/summernote/src/js/Renderer.js | 4 +-
.../static/src/js/backend/fields.js | 2 +-
addons/web_editor/static/src/js/tours/rte.js | 6 +-
.../static/src/js/widgets/widgets.js | 2 +-
addons/web_tour/static/src/js/tour_manager.js | 12 +-
.../src/js/content/snippets.animation.js | 2 +-
.../website/static/src/js/menu/mobile_view.js | 2 +-
addons/website/static/src/js/tours/rte.js | 10 +-
.../static/src/js/website.tour.blog.js | 8 +-
.../static/src/js/website.tour.event.js | 2 +-
.../static/src/js/website_event.js | 2 +-
.../views/event_templates.xml | 2 +-
.../static/src/js/website_tour_forum.js | 6 +-
.../views/website_quote_templates.xml | 8 +-
.../static/src/js/website_sale_tour_shop.js | 8 +-
addons/website_sale/views/templates.xml | 2 +-
.../static/src/xml/comparison.xml | 2 +-
.../static/src/js/website_sale.test.js | 2 +-
.../views/website_sale_wishlist_template.xml | 5 +-
.../static/src/js/slides_upload.js | 4 +-
.../website_slides/views/website_slides.xml | 6 +-
addons/website_theme_install/views/views.xml | 2 +-
.../test_main_flows/static/src/js/tour.js | 46 +-
.../test_new_api/static/tests/x2many.js | 32 +-
60 files changed, 628 insertions(+), 642 deletions(-)
diff --git a/addons/account/static/tests/reconciliation_tests.js b/addons/account/static/tests/reconciliation_tests.js
index cf149648b1a..7ebffc19e94 100644
--- a/addons/account/static/tests/reconciliation_tests.js
+++ b/addons/account/static/tests/reconciliation_tests.js
@@ -941,11 +941,11 @@ QUnit.module('account', {
// Simulate changing partner with SelectCreateDialog
widget = clientAction.widgets[1];
- assert.strictEqual($('[role="dialog"]').length, 0, "shouldn't have any opened modal");
+ assert.strictEqual($('.modal').length, 0, "shouldn't have any opened modal");
widget.$('.o_input_dropdown input').trigger('click');
$('.ui-autocomplete .ui-menu-item a:contains(Search More):eq(1)').trigger('mouseenter').trigger('click');
- assert.strictEqual($('[role="dialog"]').length, 1, "should open a SelectCreateDialog");
- $('[role="dialog"] table.o_list_view td:contains(Camptocamp)').click();
+ assert.strictEqual($('.modal').length, 1, "should open a SelectCreateDialog");
+ $('.modal table.o_list_view td:contains(Camptocamp)').click();
assert.strictEqual(widget.$('.o_input_dropdown input').val(), "Camptocamp", "the partner many2one should display Camptocamp");
widget = clientAction.widgets[2];
@@ -1100,7 +1100,7 @@ QUnit.module('account', {
widget.$('.create .create_account_id input').trigger('click');
$('.ui-autocomplete .ui-menu-item a:contains(Search)').trigger('mouseenter').trigger('click');
// select the account who does not appear in the drop drown
- $('[role="dialog"] tr.o_data_row:contains(502)').click();
+ $('.modal tr.o_data_row:contains(502)').click();
assert.strictEqual(widget.$('.create .create_account_id input').val(), "101200 Account Receivable", "Selected account does not change");
// wait the name_get to render the changes
def.resolve();
diff --git a/addons/barcodes/static/src/js/barcode_form_view.js b/addons/barcodes/static/src/js/barcode_form_view.js
index 9a09480558b..15e27498f94 100644
--- a/addons/barcodes/static/src/js/barcode_form_view.js
+++ b/addons/barcodes/static/src/js/barcode_form_view.js
@@ -349,7 +349,7 @@ FormController.include({
}
// only catch the event if we're not focused in
// another field and it's a number
- if (!$(event.target).is('body, [role="dialog"]') || !/[0-9]/.test(character)) {
+ if (!$(event.target).is('body, .modal') || !/[0-9]/.test(character)) {
return;
}
diff --git a/addons/barcodes/static/tests/barcode_tests.js b/addons/barcodes/static/tests/barcode_tests.js
index e6efcbe35a0..142fc0feca3 100644
--- a/addons/barcodes/static/tests/barcode_tests.js
+++ b/addons/barcodes/static/tests/barcode_tests.js
@@ -468,12 +468,12 @@ QUnit.test('specification of widget barcode_handler with keypress and notifyChan
setTimeout(function () {
var keycode = $.ui.keyCode.ENTER;
- assert.strictEqual($('main.modal-body').length, 1, 'should open a modal with a quantity as input');
- assert.strictEqual($('main.modal-body .o_set_qty_input').val(), '5', 'the quantity by default in the modal shoud be 5');
+ assert.strictEqual($('.modal .modal-body').length, 1, 'should open a modal with a quantity as input');
+ assert.strictEqual($('.modal .modal-body .o_set_qty_input').val(), '5', 'the quantity by default in the modal shoud be 5');
- $('main.modal-body .o_set_qty_input').val('7');
+ $('.modal .modal-body .o_set_qty_input').val('7');
- $('main.modal-body .o_set_qty_input').trigger($.Event('keypress', {which: keycode, keyCode: keycode}));
+ $('.modal .modal-body .o_set_qty_input').trigger($.Event('keypress', {which: keycode, keyCode: keycode}));
assert.strictEqual(form.$('.o_data_row .o_data_cell:nth(1)').text(), '7',
"quantity checked should be 7");
@@ -524,7 +524,7 @@ QUnit.test('barcode_scanned only trigger error for active view', function (asser
form.$('.o_data_row:first').click();
- // We do not trigger on the body since modal and
+ // We do not trigger on the body since modal and
// form view are both inside it.
function modalTriggerKeypressEvent(char) {
var keycode;
@@ -533,7 +533,7 @@ QUnit.test('barcode_scanned only trigger error for active view', function (asser
} else {
keycode = char.charCodeAt(0);
}
- return $('[role="dialog"]').trigger($.Event('keypress', {which: keycode, keyCode: keycode}));
+ return $('.modal').trigger($.Event('keypress', {which: keycode, keyCode: keycode}));
}
_.each(['O','-','B','T','N','.','c','a','n','c','e','l','Enter'], modalTriggerKeypressEvent);
assert.verifySteps(['warning'], "only one event should be triggered");
diff --git a/addons/base_setup/views/res_config_settings_views.xml b/addons/base_setup/views/res_config_settings_views.xml
index 82bfe8b4dca..53badf36843 100644
--- a/addons/base_setup/views/res_config_settings_views.xml
+++ b/addons/base_setup/views/res_config_settings_views.xml
@@ -120,8 +120,11 @@
-
- the creation of documents between your companies
+
+
+
+ the creation of documents between your companies
+
Save this page and come back here to set up the feature.
diff --git a/addons/board/static/tests/dashboard_tests.js b/addons/board/static/tests/dashboard_tests.js
index 15b08aaf544..9afb88e5648 100644
--- a/addons/board/static/tests/dashboard_tests.js
+++ b/addons/board/static/tests/dashboard_tests.js
@@ -161,17 +161,17 @@ QUnit.test('basic functionality, with one sub action', function (assert) {
assert.ok(form.$('.oe_content').is(':visible'), "content is visible again");
assert.verifySteps(['load action', 'edit custom', 'edit custom']);
- assert.strictEqual($('[role="dialog"]').length, 0, "should have no modal open");
+ assert.strictEqual($('.modal').length, 0, "should have no modal open");
form.$('button.oe_dashboard_link_change_layout').click();
- assert.strictEqual($('[role="dialog"]').length, 1, "should have opened a modal");
- assert.strictEqual($('[role="dialog"] li[data-layout="2-1"] i.oe_dashboard_selected_layout').length, 1,
+ assert.strictEqual($('.modal').length, 1, "should have opened a modal");
+ assert.strictEqual($('.modal li[data-layout="2-1"] i.oe_dashboard_selected_layout').length, 1,
"should mark currently selected layout");
- $('[role="dialog"] .oe_dashboard_layout_selector li[data-layout="1-1"]').click();
+ $('.modal .oe_dashboard_layout_selector li[data-layout="1-1"]').click();
- assert.strictEqual($('[role="dialog"]').length, 0, "should have no modal open");
+ assert.strictEqual($('.modal').length, 0, "should have no modal open");
assert.strictEqual(form.$('table.oe_dashboard[data-layout="1-1"]').length, 1,
"should have rendered a table with correct layout");
@@ -179,12 +179,12 @@ QUnit.test('basic functionality, with one sub action', function (assert) {
assert.strictEqual(form.$('.oe_action').length, 1, "should have one displayed action");
form.$('span.oe_close').click();
- assert.strictEqual($('[role="dialog"]').length, 1, "should have opened a modal");
+ assert.strictEqual($('.modal').length, 1, "should have opened a modal");
// confirm the close operation
- $('[role="dialog"] button.btn-primary').click();
+ $('.modal button.btn-primary').click();
- assert.strictEqual($('[role="dialog"]').length, 0, "should have no modal open");
+ assert.strictEqual($('.modal').length, 0, "should have no modal open");
assert.strictEqual(form.$('.oe_action').length, 0, "should have no displayed action");
assert.verifySteps(['load action', 'edit custom', 'edit custom', 'edit custom', 'edit custom']);
diff --git a/addons/crm/static/src/js/tour.js b/addons/crm/static/src/js/tour.js
index daf550378f5..b7983fe56e0 100644
--- a/addons/crm/static/src/js/tour.js
+++ b/addons/crm/static/src/js/tour.js
@@ -41,12 +41,12 @@ tour.register('crm_tour', {
content: _t("Let's schedule an activity."),
position: "bottom"
}, {
- trigger: 'main.modal-body .o_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:
introductory email
call 10 days after
second call 3 days after, ...
Select a standard activity for now.
"),
position: "bottom",
run: function (actions) {
- actions.auto('footer.modal-footer button[special=cancel]');
+ actions.auto('.modal-footer button[special=cancel]');
},
}, {
trigger: ".o_kanban_record",
diff --git a/addons/document/static/tests/document_tests.js b/addons/document/static/tests/document_tests.js
index 111beeca841..338f3e75581 100644
--- a/addons/document/static/tests/document_tests.js
+++ b/addons/document/static/tests/document_tests.js
@@ -70,7 +70,7 @@ odoo.define('document.tests', function (require) {
assert.strictEqual(form.sidebar.$('.o_sidebar_delete_attachment').length, 2, "there should be two attachments");
form.sidebar.$('.o_sidebar_delete_attachment:eq(0)').click();
- $('footer.modal-footer .btn-primary').click();
+ $('.modal-footer .btn-primary').click();
assert.strictEqual(form.sidebar.$('.o_sidebar_delete_attachment').length, 1, "there should be only one attachment");
form.destroy();
});
diff --git a/addons/im_livechat/static/src/xml/im_livechat_backend.xml b/addons/im_livechat/static/src/xml/im_livechat_backend.xml
index 60b25bf2746..deb4c6be4de 100644
--- a/addons/im_livechat/static/src/xml/im_livechat_backend.xml
+++ b/addons/im_livechat/static/src/xml/im_livechat_backend.xml
@@ -17,7 +17,8 @@
- Livechat
+
+ Livechat
diff --git a/addons/mail/static/tests/chatter_tests.js b/addons/mail/static/tests/chatter_tests.js
index b5882e3b51e..89b943700dd 100644
--- a/addons/mail/static/tests/chatter_tests.js
+++ b/addons/mail/static/tests/chatter_tests.js
@@ -686,7 +686,7 @@ QUnit.test('chatter: discard changes on message post with post_refresh "always"'
var $modal = $('.modal-dialog');
assert.strictEqual($modal.length, 1, "should have a modal opened");
- assert.strictEqual($modal.find('.modal-body p').text(),
+ assert.strictEqual($modal.find('.modal-body').text(),
"The record has been modified, your changes will be discarded. Do you want to proceed?",
"should warn the user that any unsaved changes will be lost");
@@ -862,7 +862,7 @@ QUnit.test('chatter: discard changes on message post with post_refresh "recipien
var $modal = $('.modal-dialog');
assert.strictEqual($modal.length, 1, "should have a modal opened");
- assert.strictEqual($modal.find('.modal-body p').text(),
+ assert.strictEqual($modal.find('.modal-body').text(),
"The record has been modified, your changes will be discarded. Do you want to proceed?",
"should warn the user that any unsaved changes will be lost");
@@ -915,7 +915,7 @@ QUnit.test('chatter: discard changes on opening full-composer', function (assert
var $modal = $('.modal-dialog');
assert.strictEqual($modal.length, 1, "should have a modal opened");
- assert.strictEqual($modal.find('.modal-body p').text(),
+ assert.strictEqual($modal.find('.modal-body').text(),
"The record has been modified, your changes will be discarded. Do you want to proceed?",
"should warn the user that any unsaved changes will be lost");
@@ -994,7 +994,7 @@ QUnit.test('chatter: Attachment viewer', function (assert) {
assert.strictEqual($('.o_modal_fullscreen img.o_viewer_img[data-src="/web/image/1?unique=1"]').length, 1,
"Modal popup should open with first image src");
// click on next button
- $('[role="dialog"] .arrow.arrow-right.move_next span').click();
+ $('.modal .arrow.arrow-right.move_next span').click();
assert.strictEqual($('.o_modal_fullscreen img.o_viewer_img[data-src="/web/image/2?unique=1"]').length, 1,
"Modal popup should have now second image src");
assert.strictEqual($('.o_modal_fullscreen .o_viewer_toolbar .o_download_btn').length, 1,
@@ -1467,8 +1467,8 @@ QUnit.test('followers widget: follow/unfollow, edit subtypes', function (assert)
// click to unfollow
form.$('.o_followers_follow_button').click(); // click to open the dropdown
- assert.ok($('[role="dialog"]').length, 'a confirm modal should be opened');
- $('footer.modal-footer .btn-primary').click(); // click on 'OK'
+ assert.ok($('.modal').length, 'a confirm modal should be opened');
+ $('.modal .modal-footer .btn-primary').click(); // click on 'OK'
assert.strictEqual(form.$('.o_followers_count').text(), "0", 'should have no followers');
assert.ok(form.$('.o_followers_follow_button.o_followers_notfollow').length,
'should display the "Follow" button');
@@ -1672,16 +1672,16 @@ QUnit.test('fieldmany2many tags email', function (assert) {
done();
});
- assert.strictEqual($('main.modal-body.o_act_window').length, 1,
+ assert.strictEqual($('.modal-body.o_act_window').length, 1,
"there should be one modal opened to edit the empty email");
- assert.strictEqual($('main.modal-body input[name="display_name"]').val(), "silver",
+ assert.strictEqual($('.modal-body.o_act_window input[name="display_name"]').val(), "silver",
"the opened modal should be a form view dialog with the partner_type 14");
- assert.strictEqual($('main.modal-body input[name="email"]').length, 1,
+ assert.strictEqual($('.modal-body.o_act_window input[name="email"]').length, 1,
"there should be an email field in the modal");
// set the email and save the modal (will render the form view)
- $('main.modal-body input[name="email"]').val('coucou@petite.perruche').trigger('input');
- $('footer.modal-footer .btn-primary').click();
+ $('.modal-body.o_act_window input[name="email"]').val('coucou@petite.perruche').trigger('input');
+ $('.modal-footer .btn-primary').click();
});
QUnit.test('fieldmany2many tags email (edition)', function (assert) {
@@ -1724,16 +1724,16 @@ QUnit.test('fieldmany2many tags email (edition)', function (assert) {
$input.click(); // opens the dropdown
$input.autocomplete('widget').find('li:first').click(); // add 'silver'
- assert.strictEqual($('main.modal-body.o_act_window').length, 1,
+ assert.strictEqual($('.modal-body.o_act_window').length, 1,
"there should be one modal opened to edit the empty email");
- assert.strictEqual($('main.modal-body input[name="display_name"]').val(), "silver",
+ assert.strictEqual($('.modal-body.o_act_window input[name="display_name"]').val(), "silver",
"the opened modal in edit mode should be a form view dialog with the partner_type 14");
- assert.strictEqual($('main.modal-body input[name="email"]').length, 1,
+ assert.strictEqual($('.modal-body.o_act_window input[name="email"]').length, 1,
"there should be an email field in the modal");
// set the email and save the modal (will rerender the form view)
- $('main.modal-body input[name="email"]').val('coucou@petite.perruche').trigger('input');
- $('footer.modal-footer .btn-primary').click();
+ $('.modal-body.o_act_window input[name="email"]').val('coucou@petite.perruche').trigger('input');
+ $('.modal-footer .btn-primary').click();
assert.strictEqual(form.$('.o_field_many2manytags[name="timmy"] button.o_tag_color_0').length, 2,
"should contain the second tag");
diff --git a/addons/pad/static/tests/pad_tests.js b/addons/pad/static/tests/pad_tests.js
index a6b885429a7..f2ab3a42dfa 100644
--- a/addons/pad/static/tests/pad_tests.js
+++ b/addons/pad/static/tests/pad_tests.js
@@ -184,7 +184,7 @@ QUnit.module('pad widget', {
});
var def = form.canBeDiscarded();
- assert.strictEqual($('[role="dialog"]').length, 0,
+ assert.strictEqual($('.modal').length, 0,
"should have no confirmation modal opened");
assert.strictEqual(def.state(), 'resolved',
@@ -221,7 +221,7 @@ QUnit.module('pad widget', {
form.$buttons.find('.o_form_button_edit').click();
var def = form.canBeDiscarded();
- assert.strictEqual($('[role="dialog"]').length, 0,
+ assert.strictEqual($('.modal').length, 0,
"should have no confirmation modal opened");
assert.strictEqual(def.state(), 'resolved',
diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml
index 12c01733bfd..75c0aecdcac 100644
--- a/addons/point_of_sale/static/src/xml/pos.xml
+++ b/addons/point_of_sale/static/src/xml/pos.xml
@@ -334,7 +334,7 @@
-
+
@@ -360,7 +360,7 @@
- Please select a payment method.
+ Please select a payment method.
@@ -559,19 +559,19 @@
-
+
-
+
-
+
@@ -580,7 +580,7 @@
-
+
@@ -668,8 +668,8 @@
-
-
+
+
@@ -687,7 +687,7 @@
- Tip
+ Tip
@@ -700,7 +700,7 @@
-
+
@@ -795,9 +795,9 @@
-
+
- x
+ x
@@ -841,14 +841,14 @@
-
+