From c66fbed5c60a655c245c5a6093f0d4b01f98c2b0 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Mon, 31 Jul 2017 13:57:07 +0200 Subject: [PATCH 1/3] [FIX] board: pass domain in view creation In the dashboard, the domain wasn't passed to the view since the new views. The action in the dashboard and the one saved were thus different (ex: when saving 'Customer', you got all partners). This was also causing a traceback when editing a value in the grid view. This domain is now correctly passed. --- addons/board/static/src/js/dashboard.js | 1 + addons/board/static/tests/dashboard_tests.js | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/board/static/src/js/dashboard.js b/addons/board/static/src/js/dashboard.js index 3c40524e12c..72a2a0383f6 100644 --- a/addons/board/static/src/js/dashboard.js +++ b/addons/board/static/src/js/dashboard.js @@ -232,6 +232,7 @@ FormRenderer.include({ var view = new View(viewInfo, { action: action, context: context, + domain: params.domain, groupBy: context.group_by, modelName: action.res_model, hasSelectors: false, diff --git a/addons/board/static/tests/dashboard_tests.js b/addons/board/static/tests/dashboard_tests.js index 1b55551fe2b..27d685ff46e 100644 --- a/addons/board/static/tests/dashboard_tests.js +++ b/addons/board/static/tests/dashboard_tests.js @@ -99,7 +99,7 @@ QUnit.test('display the no content helper', function (assert) { }); QUnit.test('basic functionality, with one sub action', function (assert) { - assert.expect(24); + assert.expect(25); var form = createView({ View: FormView, @@ -108,11 +108,11 @@ QUnit.test('basic functionality, with one sub action', function (assert) { arch: '
' + '' + '' + - '' + + '' + '' + '' + '
', - mockRPC: function (route) { + mockRPC: function (route, args) { if (route === '/web/action/load') { assert.step('load action'); return $.when({ @@ -120,6 +120,9 @@ QUnit.test('basic functionality, with one sub action', function (assert) { views: [[4, 'list']], }); } + if (route === '/web/dataset/search_read') { + assert.deepEqual(args.domain, [['foo', '!=', 'False']], "the domain should be passed"); + } if (route === '/board/static/src/img/layout_1-1-1.png') { return $.when(); } From 28bf5f007fd777f7cf2c8f85ea9938b288d391f0 Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Mon, 31 Jul 2017 14:48:50 +0200 Subject: [PATCH 2/3] [FIX] web: fix action context with no explicit context When I did efd15852, I accidentally undid d20074c5. That commit wanted to filter out unwanted values from the action context, but it was too violent, as it was discarding the action context. (See bug described in efd15852) My original commit aimed at avoiding the filtering of the action context by having it devoid of unwanted values altogether. The idea was "if this is an action button, we don't want the element context". However, the default behavior of the _getContext function was to add the element context. There were options to force to add the element context despite being in a case where it should not be added, but we needed the opposite: do not add the element context. We used "additionalContext" in this fashion, the idea was: "if I give you specific context values, don't polute it with the element context". This was efd15852. However, not all actions have context defined explicitely in their definition. In this case, since additionalContext was undefined, the element context was added again, despite our will not to add it for actions. We solved this by simply always giving an additionalContext to getContext, providing an empty one if needed. To reproduce this bug (which is the same as efd15852): - Go to Manufacturing - Click on menu Master Data then Products - Open a product - Click on the "Bills of Materials" stat button - Click on create - The create crashes because of the "default_type" context key that is erroneously passed from the "Products" action to the "Bills of Materials" stat button action. --- .../src/js/views/basic/basic_controller.js | 2 +- addons/web/static/tests/views/form_tests.js | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 54c8ccfbf51..39e596db5b8 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -238,7 +238,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { var recordID = record.data.id; this.trigger_up('execute_action', { action_data: _.extend({}, attrs, { - context: record.getContext({additionalContext: attrs.context}), + context: record.getContext({additionalContext: attrs.context || {}}), }), model: record.model, res_ids: [recordID], diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js index 65c19818118..2a08a305fd0 100644 --- a/addons/web/static/tests/views/form_tests.js +++ b/addons/web/static/tests/views/form_tests.js @@ -3572,6 +3572,40 @@ QUnit.module('Views', { form.destroy(); }); + QUnit.test('clicking on a stat button with no context', function (assert) { + assert.expect(1); + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: + '
' + + '' + + '
' + + '' + + '
' + + '
' + + '
', + res_id: 2, + viewOptions: { + context: {some_context: true}, + }, + intercepts: { + execute_action: function (e) { + assert.deepEqual(e.data.action_data.context, {}, + "button context should have been evaluated and given to the action, without previous context"); + }, + }, + }); + + form.$('.oe_stat_button').click(); + + form.destroy(); + }); + QUnit.test('diplay a stat button outside a buttonbox', function (assert) { assert.expect(3); From 3becbd764d7af69a58014afa64dce5c85b07aae6 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 31 Jul 2017 18:59:30 +0200 Subject: [PATCH 3/3] [FIX] test_main_flows: wait buttons to be active before triggering them Since a1f7aa3362eded33f7142e218e74acad98367511, buttons are deactivated during action. --- .../test_main_flows/static/src/js/tour.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/odoo/addons/test_main_flows/static/src/js/tour.js b/odoo/addons/test_main_flows/static/src/js/tour.js index 107c5d62c65..bf96428dff6 100644 --- a/odoo/addons/test_main_flows/static/src/js/tour.js +++ b/odoo/addons/test_main_flows/static/src/js/tour.js @@ -278,7 +278,7 @@ tour.register('main_flow_tour', { position: "bottom", }, { // Create a quotation - trigger: ".o_statusbar_buttons > button:contains('New Quotation')", + trigger: ".o_statusbar_buttons > button:enabled:contains('New Quotation')", content: _t('

Create a quotation

'), position: "right" }, { @@ -325,11 +325,11 @@ tour.register('main_flow_tour', { } }, }, { - trigger: ".o_statusbar_buttons > button.o_sale_print", + trigger: ".o_statusbar_buttons > button.o_sale_print:enabled", content: _t("

Print this quotation.

"), position: "bottom" }, { - trigger: ".o_statusbar_buttons > button:contains('Send by Email')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Send by Email')", extra_trigger: ".o_statusbar_status .btn-primary:contains('Quotation Sent')", content: _t("Try to send it to email"), position: "bottom", @@ -347,7 +347,7 @@ tour.register('main_flow_tour', { content: _t("Try to send it to email"), position: "bottom", }, { - trigger: ".o_statusbar_buttons > button:contains('Confirm Sale')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Confirm Sale')", content: _t("

Confirm this quotation

"), position: "bottom" }, { @@ -430,15 +430,15 @@ tour.register('main_flow_tour', { content: _t('Select the generated request for quotation'), position: 'bottom', }, { - trigger: ".o_statusbar_buttons > button:contains('Confirm Order')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Confirm Order')", content: _t("Confirm quotation"), position: "bottom", }, { - trigger: ".o_statusbar_buttons > button:contains('Receive Products')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Receive Products')", content: _t("Receive Product"), position: "bottom", }, { - trigger: ".o_statusbar_buttons > button:contains('Validate')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Validate')", content: _t("Validate"), position: "bottom", }, { @@ -459,11 +459,11 @@ tour.register('main_flow_tour', { content: _t("Let's create a new vendor bill"), position: "right", }, { - trigger: ".o_statusbar_buttons > button:contains('Validate')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Validate')", content: _t("Try to send it to email"), position: "bottom", }, { - trigger: ".o_statusbar_buttons > button:contains('Register Payment')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Register Payment')", content: _t("Register Payment"), position: "bottom", }, { @@ -491,11 +491,11 @@ tour.register('main_flow_tour', { content: _t('Select the generated manufacturing order'), position: 'bottom', }, { - trigger: ".o_statusbar_buttons > button:contains('Check availability')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Check availability')", content: _t("Check availability"), position: "bottom", }, { - trigger: ".o_statusbar_buttons > button.oe_highlight:contains('Produce')", + trigger: ".o_statusbar_buttons > button.oe_highlight:enabled:contains('Produce')", content: _t("Produce"), position: "bottom", }, { @@ -503,7 +503,7 @@ tour.register('main_flow_tour', { content: _t('Record Production'), position: 'bottom', }, { - trigger: ".o_statusbar_buttons > button:contains('Mark as Done')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Mark as Done')", content: _t("Mark as Done"), position: "bottom", }, { @@ -574,7 +574,7 @@ tour.register('main_flow_tour', { content: _t('Back to the sale order'), position: 'bottom', }, { - trigger: ".o_statusbar_buttons > button:contains('Create Invoice')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Create Invoice')", content: _t("Validate"), position: "bottom", }, { @@ -582,11 +582,11 @@ tour.register('main_flow_tour', { content: _t("Create and View Invoices"), position: "bottom", }, { - trigger: ".o_statusbar_buttons > button:contains('Validate')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Validate')", content: _t("Validate"), position: "bottom", }, { - trigger: ".o_statusbar_buttons > button:contains('Register Payment')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Register Payment')", content: _t("Register Payment"), position: "bottom", }, { @@ -661,7 +661,7 @@ tour.register('main_flow_tour', { position: 'bottom', }, { edition: "enterprise", - trigger: ".o_statusbar_buttons > button:contains('Reconcile')", + trigger: ".o_statusbar_buttons > button:enabled:contains('Reconcile')", content: _t('

Reconcile

'), position: "bottom", }, {