[FIX] web: placing the domain in the kwargs of an rpc call
Steps to reproduce:
- go to Contacts app;
- add a reporting view (Graph, Pivot or Dashboard) (with studio for example)
- tape any character in the search bar;
- on "search related company for" field either use the arrow keys to go down to this and then click the right arrow key or click on the triangle to the left of this field.
Issue:
An error occurs.
Cause:
There is a mismatch between the parameters that are sent by the rpc call and those processed by the logic part.
Specifically, the domain must be part of the kwargs and not the args of the params key in the rpc call.
The problem occurs with a filter that looks like: `<field name="parent_id" domain="[('is_company', '=', True)]" operator="child_of"/>`
Solution:
Move domain in kwargs under key named args in the params of the rpc call.
opw-3031096
closes odoo/odoo#106074
X-original-commit: 8a9b418b27dcc9b904413f14cd0443f9a5b10d17
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Signed-off-by: Lefebvre Thomas (thle) <thle@odoo.com>
This commit is contained in:
@@ -189,7 +189,8 @@ export class SearchBar extends Component {
|
||||
// Pass
|
||||
}
|
||||
}
|
||||
const options = await this.orm.call(field.relation, "name_search", domain, {
|
||||
const options = await this.orm.call(field.relation, "name_search", [], {
|
||||
args: domain,
|
||||
context: field.context,
|
||||
limit: 8,
|
||||
name: query.trim(),
|
||||
|
||||
@@ -38,6 +38,7 @@ QUnit.module("Search", (hooks) => {
|
||||
birth_datetime: { string: "Birth DateTime", type: "datetime" },
|
||||
foo: { string: "Foo", type: "char" },
|
||||
bool: { string: "Bool", type: "boolean" },
|
||||
company: { string: "Company", type: "many2one", relation: "partner" },
|
||||
},
|
||||
records: [
|
||||
{
|
||||
@@ -57,6 +58,7 @@ QUnit.module("Search", (hooks) => {
|
||||
bool: false,
|
||||
birthday: "1982-06-04",
|
||||
birth_datetime: "1982-06-04 02:00:00",
|
||||
company: 1,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
@@ -66,6 +68,7 @@ QUnit.module("Search", (hooks) => {
|
||||
bool: false,
|
||||
birthday: "1985-09-13",
|
||||
birth_datetime: "1985-09-13 03:00:00",
|
||||
company: 5,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
@@ -96,6 +99,7 @@ QUnit.module("Search", (hooks) => {
|
||||
<field name="birthday"/>
|
||||
<field name="birth_datetime"/>
|
||||
<field name="bar" context="{'bar': self}"/>
|
||||
<field name="company" domain="[('bool', '=', True)]"/>
|
||||
<filter string="Birthday" name="date_filter" date="birthday"/>
|
||||
<filter string="Birthday" name="date_group_by" context="{'group_by': 'birthday:day'}"/>
|
||||
</search>
|
||||
@@ -315,8 +319,8 @@ QUnit.module("Search", (hooks) => {
|
||||
assert.containsN(
|
||||
target,
|
||||
".o_searchview_autocomplete li",
|
||||
2,
|
||||
"there should be 2 result for 'a' in search bar autocomplete"
|
||||
3,
|
||||
"there should be 3 result for 'a' in search bar autocomplete"
|
||||
);
|
||||
|
||||
const searchInput = target.querySelector(".o_searchview input");
|
||||
@@ -947,4 +951,51 @@ QUnit.module("Search", (hooks) => {
|
||||
await validateSearch(target);
|
||||
assert.deepEqual(getDomain(controlPanel), [["foo", "ilike", "1a"]]);
|
||||
});
|
||||
|
||||
QUnit.test("check kwargs of a rpc call with a domain", async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
const mockRPC = async (route, args) => {
|
||||
if (route.includes("/partner/name_search")) {
|
||||
assert.deepEqual(args, {
|
||||
model: "partner",
|
||||
method: "name_search",
|
||||
args: [],
|
||||
kwargs: {
|
||||
args: [["bool", "=", true]],
|
||||
context: { lang: "en", uid: 7, tz: "taht" },
|
||||
limit: 8,
|
||||
name: "F",
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const controlPanel = await makeWithSearch({
|
||||
serverData,
|
||||
mockRPC,
|
||||
resModel: "partner",
|
||||
Component: ControlPanel,
|
||||
searchMenuTypes: [],
|
||||
searchViewId: false,
|
||||
});
|
||||
|
||||
await editSearch(target, "F");
|
||||
assert.containsN(
|
||||
target,
|
||||
".o_searchview_autocomplete li",
|
||||
3,
|
||||
"there should be 3 result for 'F' in search bar autocomplete"
|
||||
);
|
||||
|
||||
const searchInput = target.querySelector(".o_searchview input");
|
||||
await triggerEvent(searchInput, null, "keydown", { key: "ArrowDown" });
|
||||
await triggerEvent(searchInput, null, "keydown", { key: "ArrowDown" });
|
||||
await triggerEvent(searchInput, null, "keydown", { key: "ArrowRight" });
|
||||
await triggerEvent(searchInput, null, "keydown", { key: "ArrowDown" });
|
||||
await triggerEvent(searchInput, null, "keydown", { key: "ArrowDown" });
|
||||
await triggerEvent(searchInput, null, "keydown", { key: "ArrowDown" });
|
||||
await triggerEvent(searchInput, null, "keydown", { key: "Enter" });
|
||||
assert.deepEqual(getDomain(controlPanel), [["company", "=", 5]]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user