[IMP] web: rpc: more permissive API for read_group
This rev. allows to specify some kwargs of read_group directly in an Object given to kwargs(), instead of explicitly specify them using the corresponding method (e.g. to specify the context in the kwargs instead of by calling .withContext().
This commit is contained in:
@@ -264,7 +264,7 @@ var ReadGroupRPCBuilder = SearchRPCBuilder.extend({
|
||||
* @returns {Object}
|
||||
*/
|
||||
_getParams: function () {
|
||||
var kwargs = _.extend({}, this._kwargs, {
|
||||
var kwargs = _.defaults({}, this._kwargs, {
|
||||
context: this._context || {},
|
||||
domain: this._domain || [],
|
||||
fields: this._fields,
|
||||
|
||||
@@ -208,6 +208,38 @@ QUnit.module('core', {}, function () {
|
||||
.exec();
|
||||
});
|
||||
|
||||
QUnit.test('read_group with kwargs', function (assert) {
|
||||
assert.expect(2);
|
||||
var query = createQuery({
|
||||
model: 'partner',
|
||||
method: 'read_group',
|
||||
mockRPC: function (route, args) {
|
||||
assert.deepEqual(args, {
|
||||
args: [],
|
||||
kwargs: {
|
||||
context: {abc: 'def'},
|
||||
domain: ['a', '=', 1],
|
||||
fields: ['name'],
|
||||
groupby: ['product_id'],
|
||||
lazy: true,
|
||||
orderby: false,
|
||||
},
|
||||
method: 'read_group',
|
||||
model: 'partner',
|
||||
}, "should have correct args");
|
||||
assert.equal(route, '/web/dataset/call_kw/partner/read_group',
|
||||
"should call correct route");
|
||||
},
|
||||
});
|
||||
query
|
||||
.withDomain(['a', '=', 1])
|
||||
.withFields(['name'])
|
||||
.groupBy(['product_id'])
|
||||
.kwargs({context: {abc: 'def'}})
|
||||
.lazy(true)
|
||||
.exec();
|
||||
});
|
||||
|
||||
QUnit.test('search_read with no domain, nor fields', function (assert) {
|
||||
assert.expect(2);
|
||||
createQuery({
|
||||
|
||||
Reference in New Issue
Block a user