[FIX] web: field: relational: search more: _view_ref passed in context
Have a x2many field with a _view_ref (ie tree_view_ref) in its context Open the select create dialog (Search More) of that field Before this commit, there was a crash because the _view_ref string was passed to the get_views as if it were an Integer ID. After this commit, there is no crash, and the select create dialog opens correctly. closes odoo/odoo#97224 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -25,8 +25,7 @@ export class SelectCreateDialog extends Component {
|
||||
}
|
||||
|
||||
get viewProps() {
|
||||
let id;
|
||||
const viewProps = {
|
||||
return {
|
||||
...this.baseViewProps,
|
||||
context: this.props.context,
|
||||
domain: this.props.domain,
|
||||
@@ -36,14 +35,6 @@ export class SelectCreateDialog extends Component {
|
||||
searchViewId: this.props.searchViewId,
|
||||
type: this.env.isSmall ? "kanban" : "list",
|
||||
};
|
||||
const context = this.props.context || {};
|
||||
if (viewProps.type === "kanban") {
|
||||
viewProps.forceGlobalClick = true;
|
||||
id = context["kanban_view_ref"];
|
||||
} else {
|
||||
id = context["list_view_ref"] || context["tree_view_ref"];
|
||||
}
|
||||
return { ...viewProps, viewId: id || false };
|
||||
}
|
||||
|
||||
async select(resIds) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
click,
|
||||
clickEdit,
|
||||
clickSave,
|
||||
clickOpenedDropdownItem,
|
||||
editInput,
|
||||
editSelect,
|
||||
getFixture,
|
||||
@@ -13,6 +14,8 @@ import {
|
||||
patchWithCleanup,
|
||||
} from "@web/../tests/helpers/utils";
|
||||
import { editSearch, validateSearch } from "@web/../tests/search/helpers";
|
||||
import { AutoComplete } from "@web/core/autocomplete/autocomplete";
|
||||
import { Many2XAutocomplete } from "@web/views/fields/relational_utils";
|
||||
|
||||
let target;
|
||||
let serverData;
|
||||
@@ -1821,4 +1824,49 @@ QUnit.module("Fields", (hooks) => {
|
||||
await click(target.querySelector(".oe_kanban_global_click"));
|
||||
assert.verifySteps(["doActionButton type object name a1"]);
|
||||
});
|
||||
|
||||
QUnit.test("select create with _view_ref as text", async (assert) => {
|
||||
serverData.views = {
|
||||
"partner_type,my.little.string,list": `<tree><field name="display_name"/></tree>`,
|
||||
"partner_type,false,search": `<search />`,
|
||||
};
|
||||
|
||||
patchWithCleanup(AutoComplete, {
|
||||
timeout: 0,
|
||||
});
|
||||
|
||||
patchWithCleanup(Many2XAutocomplete.defaultProps, {
|
||||
searchLimit: 1,
|
||||
});
|
||||
|
||||
let checkGetViews = false;
|
||||
await makeView({
|
||||
type: "form",
|
||||
resId: 1,
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="timmy" widget="many2many_tags" context="{ 'tree_view_ref': 'my.little.string' }"/>
|
||||
</form>`,
|
||||
mockRPC(route, args) {
|
||||
if (args.method === "get_views" && checkGetViews) {
|
||||
assert.step("get_views");
|
||||
assert.deepEqual(args.kwargs.views, [
|
||||
[false, "list"],
|
||||
[false, "search"],
|
||||
]);
|
||||
assert.strictEqual(args.kwargs.context.tree_view_ref, "my.little.string");
|
||||
}
|
||||
},
|
||||
});
|
||||
await clickEdit(target);
|
||||
await click(target, ".o_field_many2many_selection input");
|
||||
checkGetViews = true;
|
||||
await clickOpenedDropdownItem(target, "timmy", "Search More...");
|
||||
assert.verifySteps([`get_views`]);
|
||||
|
||||
assert.containsOnce(target, ".modal");
|
||||
assert.strictEqual(target.querySelector(".modal-title").textContent, "Search: pokemon");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user