diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-06-28 13:20:10 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-06-29 14:58:04 +0200 |
| commit | b954cd64835eb2c251ba0890293079b7bcebd460 (patch) | |
| tree | 370d267b9be3f15813a8b16d0ee63d9aaa993d22 /addons/web/static/tests/fields/relational_fields_tests.js | |
| parent | 2846887ea80ad164fabb4b1e0742629330a527f5 (diff) | |
[FIX] web: BasicModel: send correct context
... when reading and writing on a record (especially inside lists).
Before this rev., the context sent when reading a record, and when
writing records inside lists (editable list views) wasn't correct.
This caused an issue in Sales > Products (variant activated) >
open a product with variants > click on variant prices > edit the
prices of a variant: the value wasn't saved correctly (because the
inverse function requires 'active_id' to be in the context and it
wasn't the case).
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 5a2844f620d..03a39ca1d1e 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -4658,6 +4658,61 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('editable list: contexts are correctly sent', function (assert) { + assert.expect(5); + + this.data.partner.records[0].timmy = [12]; + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form>' + + '<field name="foo"/>' + + '<field name="timmy" context="{\'key\': parent.foo}">' + + '<tree editable="top">' + + '<field name="display_name"/>' + + '</tree>' + + '</field>' + + '</form>', + mockRPC: function (route, args) { + if (args.method === 'read' && args.model === 'partner') { + assert.deepEqual(args.kwargs.context, { + active_field: 2, + bin_size: true, + someKey: 'some value', + }, "sent context should be correct"); + } + if (args.method === 'read' && args.model === 'partner_type') { + assert.deepEqual(args.kwargs.context, { + key: 'yop', + someKey: 'some value', + }, "sent context should be correct"); + } + if (args.method === 'write') { + assert.deepEqual(args.kwargs.context, { + active_field: 2, + someKey: 'some value', + }, "sent context should be correct"); + } + return this._super.apply(this, arguments); + }, + session: { + user_context: {someKey: 'some value'}, + }, + viewOptions: { + mode: 'edit', + context: {active_field: 2}, + }, + res_id: 1, + }); + + form.$('.o_data_cell:first').click(); + form.$('.o_field_widget[name=display_name]').val('abc').trigger('input'); + form.$buttons.find('.o_form_button_save').click(); + + form.destroy(); + }); + QUnit.module('FieldMany2Many'); QUnit.test('many2many kanban: edition', function (assert) { |
