[FIX] web: fix crash when building domain with dates

Before this commit, the rawify function assumed that any object is
necessary a record object.  This was true until recently, when we
decided that dates should be internally stored as a moment instance.
This commit is contained in:
Géry Debongnie
2017-04-11 19:44:38 +02:00
committed by Aaron Bohy
parent 1a7fbd5a13
commit db2198b7ef
2 changed files with 28 additions and 0 deletions
@@ -760,6 +760,9 @@ function rawify (data) {
// replaces the value of relational fields by their raw value (the id, if
// any, for many2ones and an array of ids for x2manys), in turn
return _.mapObject(data, function (value) {
if (value instanceof moment) {
return moment;
}
if (_.isObject(value)) {
return value.type === 'record' ? value.res_id : value.res_ids;
}
@@ -345,6 +345,31 @@ QUnit.module('relational_fields', {
form.$('input').click();
});
QUnit.test('autocompletion in a many2one, in form view with a date field', function (assert) {
assert.expect(1);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: '<form>' +
'<field name="bar"/>' +
'<field name="date"/>' +
'<field name="trululu" domain="[(\'bar\',\'=\',True)]"/>' +
'</form>',
res_id: 2,
mockRPC: function (route, args) {
if (args.method === 'name_search') {
assert.deepEqual(args.kwargs.args, [["bar", "=", true]], "should not have a domain");
}
return this._super(route, args);
},
});
form.$buttons.find('.o_form_button_edit').click();
form.$('input:eq(2)').click();
});
QUnit.test('creating record with many2one with option always_reload', function (assert) {
assert.expect(2);