Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] web: read_group RPC #21201

Merged
merged 1 commit into from
Nov 24, 2017

Conversation

nim-odoo
Copy link
Contributor

Example of failing request:

rpc.query({
    model: 'link.tracker.click',
    method: 'read_group',
    args: [[links_domain, ['create_date', '>', interval]], ['country_id']],
    kwargs: {groupby:'country_id'},
});

The RPC request built contains the following:

args: [[["link_id", "=", 1]], ["create_date"]]
kwargs: {groupby: "create_date:day", domain: [], fields: []}

This will be interpreted server side as:

model.read_group([['link_id', '=', 1]], ['create_date'], groupby=['create_date:day'], domain=[], fields=[])

2 arguments match domain and fields, which causes a crash.

opw-781300

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@nim-odoo nim-odoo force-pushed the saas-16-opw-781300-web_rpc-nim branch from 730c6c3 to e188cea Compare November 24, 2017 12:00
@nim-odoo nim-odoo self-assigned this Nov 24, 2017
@nim-odoo nim-odoo added the OE the report is linked to a support ticket (opw-...) label Nov 24, 2017
Example of failing request:
```
rpc.query({
    model: 'link.tracker.click',
    method: 'read_group',
    args: [[links_domain, ['create_date', '>', interval]], ['country_id']],
    kwargs: {groupby:'country_id'},
});
```

The RPC request built contains the following:
```
args: [[["link_id", "=", 1]], ["create_date"]]
kwargs: {groupby: "create_date:day", domain: [], fields: []}
```

This will be interpreted server side as:
```
model.read_group([['link_id', '=', 1]], ['create_date'], groupby=['create_date:day'], domain=[], fields=[])
```

2 arguments match `domain` and `fields`, which causes a crash.

opw-781300
Copy link
Contributor

@ged-odoo ged-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good. But if you feel like it, the same fix should be done with the search_read method, just below

@nim-odoo
Copy link
Contributor Author

@ged-odoo hum yeah, but in the case of search_read:
params.kwargs.domain = options.domain || params.domain || params.kwargs.domain;

So here if no kwargs are specified, [] won't be added by default. So I guess if you end up in this situation, it means that you have written something incorrect such as:

rpc.query({
    model: 'link.tracker.click',
    method: 'read_group',
    args: [
        [['create_date', '>', interval]]
    ],
    kwargs: {domain: ['create_date', '>', interval]},
});

In this case I would blame the calling method, not the framework.

@nim-odoo nim-odoo merged commit e703d07 into odoo:saas-16 Nov 24, 2017
@nim-odoo nim-odoo deleted the saas-16-opw-781300-web_rpc-nim branch November 24, 2017 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants