diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-08-09 09:21:13 +0200 |
|---|---|---|
| committer | David Monjoie <dmo@odoo.com> | 2017-08-10 08:48:32 +0200 |
| commit | 1e8f6d01ffe324348ce5d75f8643f170f6478657 (patch) | |
| tree | f833ee666fa709fdae4f3de1824733c6e638f4f4 /addons/web/static/tests/fields/relational_fields_tests.js | |
| parent | 50957038b9ebe5e249da28a9745f957ad02a0760 (diff) | |
[FIX] web,*: send correct context on button clicked
*account_asset
When a button of type 'action' is clicked (execute a given action),
special keys must be set in the context (active_id, active_ids and
active_model). They must be computed regarding the record containing
the clicked button, i.e. if we are in a modal, it must be the id
and model of the record displayed in the modal.
Before this rev., we always sent the id and model of the record
displayed in the background (i.e. the id and model of the url).
This caused a bug in MRP that could be reproduced as follows:
- open a manufacturing order in form view
- click on edit
- click on one of the line of the one2many, and click on the green
icon to edit a product
- click on the update product quantity button on top of it
- the product field must be correctly filled, which was not the
case before this rev.
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 62 |
1 files changed, 58 insertions, 4 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 6d4c68d245f..29f8666455a 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -1002,6 +1002,60 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('list in form: call button in sub view', function (assert) { + assert.expect(6); + + this.data.partner.records[0].p = [2]; + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form>' + + '<sheet>' + + '<field name="p">' + + '<tree editable="bottom">' + + '<field name="product_id"/>' + + '</tree>' + + '</field>' + + '</sheet>' + + '</form>', + res_id: 1, + mockRPC: function (route, args) { + if (route === '/web/dataset/call_kw/product/get_formview_id') { + return $.when(false); + } + return this._super.apply(this, arguments); + }, + intercepts: { + execute_action: function (event) { + assert.strictEqual(event.data.env.model, 'product', + 'should call with correct model in env'); + assert.strictEqual(event.data.env.currentID, 37, + 'should call with correct currentID in env'); + assert.deepEqual(event.data.env.resIDs, [37], + 'should call with correct resIDs in env'); + }, + }, + archs: { + 'product,false,form': '<form string="Partners">' + + '<header>' + + '<button name="action" type="action" string="Just do it !"/>' + + '<button name="object" type="object" string="Just don\'t do it !"/>' + + '<field name="display_name"/>' + + '</header>' + + '</form>', + }, + }); + + form.$buttons.find('.o_form_button_edit').click(); + form.$('td.o_data_cell:first').click(); // edit first one2many line + form.$('.o_external_button').click(); // open product sub view in modal + $('button:contains("Just do it !")').click(); // click on action button + $('button:contains("Just don\'t do it !")').click(); // click on object button + + form.destroy(); + }); + QUnit.test('autocompletion in a many2one, in form view with a domain', function (assert) { assert.expect(1); @@ -4036,9 +4090,9 @@ QUnit.module('relational_fields', { res_id: 1, intercepts: { execute_action: function (event) { - assert.deepEqual(event.data.res_ids, [2], + assert.deepEqual(event.data.env.currentID, 2, 'should call with correct id'); - assert.strictEqual(event.data.model, 'partner', + assert.strictEqual(event.data.env.model, 'partner', 'should call with correct model'); assert.strictEqual(event.data.action_data.name, 'method_name', "should call correct method"); @@ -4080,9 +4134,9 @@ QUnit.module('relational_fields', { res_id: 1, intercepts: { execute_action: function (event) { - assert.deepEqual(event.data.res_ids, [2], + assert.deepEqual(event.data.env.currentID, 2, 'should call with correct id'); - assert.strictEqual(event.data.model, 'partner', + assert.strictEqual(event.data.env.model, 'partner', 'should call with correct model'); assert.strictEqual(event.data.action_data.name, 'method_name', "should call correct method"); |
