summaryrefslogtreecommitdiff
path: root/addons/web/static/test
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2017-03-15 12:06:29 +0100
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commitce36786038b7b9bfa3e292ce40207d1ea46f3c92 (patch)
treed670d2c8c94e7269fc50beeba0f7bb2740d8e167 /addons/web/static/test
parent5e91027a86217e440608ed80f1da5d6f82881e61 (diff)
[FIX] web: _buildOnchangeSpecs must return only the present fields
Before: the method '_buildOnchangeSpecs' returned all fields, but some models like 'res.users' have redefined the fields_get and add some fake fields which cause a crash.
Diffstat (limited to 'addons/web/static/test')
-rw-r--r--addons/web/static/test/views/form_tests.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/addons/web/static/test/views/form_tests.js b/addons/web/static/test/views/form_tests.js
index 8096982d3f7..80c60c4bc20 100644
--- a/addons/web/static/test/views/form_tests.js
+++ b/addons/web/static/test/views/form_tests.js
@@ -736,6 +736,47 @@ QUnit.module('Views', {
form.destroy();
});
+ QUnit.test('onchange send only the present fields to the server', function (assert) {
+ assert.expect(1);
+ this.data.partner.records[0].product_id = false;
+ this.data.partner.onchanges.foo = function (obj) {
+ obj.foo = obj.foo + " alligator";
+ };
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="foo"/>' +
+ '<field name="p">' +
+ '<tree>' +
+ '<field name="bar"/>' +
+ '<field name="product_id"/>' +
+ '</tree>' +
+ '</field>' +
+ '<field name="timmy"/>' +
+ '</form>',
+ archs: {
+ "partner_type,false,list": '<tree><field name="name"/></tree>'
+ },
+ res_id: 1,
+ mockRPC: function (route, args) {
+ if (args.method === "onchange") {
+ assert.deepEqual(args.args[3],
+ {"foo": "1", "p": "", "p.bar": "", "p.product_id": "", "timmy": "", "timmy.name": ""},
+ "should send only the fields used in the views");
+ }
+ return this._super(route, args);
+ },
+ });
+
+ form.$buttons.find('.o_form_button_edit').click();
+ form.$('input:first').val("tralala").trigger('input');
+
+ form.destroy();
+ });
+
QUnit.test('evaluate in python field options', function (assert) {
assert.expect(1);