-
-
Notifications
You must be signed in to change notification settings - Fork 2k
[18.0][IMP] web_responsive: Quick Record Search #3192
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
base: 18.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's really good that you have added a screenshot! Please update the USAGE file and add the description of how this feature works in it. You can also embed this gif in it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ivs-cetmix check my comment about the convenience of this feature being here: #3192 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@pedrobaeza yup, that makes sense. I see two options:
@mohammedshahil what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yes separate module is better |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Command Palette Record Search Provider | ||
*/ | ||
import { registry } from "@web/core/registry"; | ||
import { DefaultCommandItem } from "@web/core/commands/command_palette"; | ||
|
||
const commandProviderRegistry = registry.category("command_provider"); | ||
|
||
commandProviderRegistry.add("record_search", { | ||
namespace: "/", | ||
async provide(env, options = {}) { | ||
const searchValue = options.searchValue || ""; | ||
const match = searchValue.match(/^([\w\.]+)(?:\s+(.*))?$/); | ||
if (!match) { | ||
return []; | ||
} | ||
const model = match[1]; | ||
const term = (match[2] || "").trim(); | ||
let results = []; | ||
try { | ||
results = await env.services.orm.searchRead( | ||
model, | ||
[["display_name", "ilike", term]], | ||
["id", "display_name"], | ||
{ limit: 10 } | ||
); | ||
} catch (e) { | ||
return []; | ||
} | ||
return results.map((rec) => ({ | ||
Component: DefaultCommandItem, | ||
action: () => { | ||
env.services.action.doAction({ | ||
type: "ir.actions.act_window", | ||
res_model: model, | ||
res_id: rec.id, | ||
view_mode: "form", | ||
views: [[false, "form"]], | ||
target: "current", | ||
}); | ||
}, | ||
category: "default", | ||
name: rec.display_name, | ||
})); | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is auto-generated. Please modify the CONTRIBUTORS file instead. Check the example here.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.