[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.
This commit is contained in:
committed by
Aaron Bohy
parent
5e91027a86
commit
ce36786038
@@ -1239,8 +1239,8 @@ var BasicModel = AbstractModel.extend({
|
||||
var field = record.fields[name];
|
||||
specs[name] = (field.onChange) || "";
|
||||
_.each(field.views, function (view) {
|
||||
_.each(view.fields, function (field, subname) {
|
||||
specs[name + '.' + subname] = (field.onChange) || "";
|
||||
_.each(view.fieldAttrs, function (field, subname) {
|
||||
specs[name + '.' + subname] = (view.fields[subname].onChange) || "";
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -89,6 +89,7 @@ var FormView = BasicView.extend({
|
||||
field.views[viewName === 'list' ? 'tree' : viewName] = view;
|
||||
field.relatedFields = fieldView.view_fields;
|
||||
field.fieldAttrs = fieldView.fieldAttrs;
|
||||
view.fieldAttrs = fieldView.fieldAttrs;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user