', {
+ text:_t("command not found")
+ }),
+ }).open();
+ }
+ }
+ else{
+ self.props.close()
+ var buttons = [
+ {
+ text: _t("Ok"),
+ classes: 'btn-primary',
+ close: true,
+ },
+ ];
+ new Dialog(self, {
+ size: 'medium',
+ buttons: buttons,
+ $content: $('
', {
+ text:_t("command not found")
+ }),
+ }).open();
+ }
+ }
+ },
+ //Check fields
+ _fields_check(model){
+ var self = this
+ const searchValue = this.state.searchValue
+ const pattern = /^Open\s.*\s(of|in)\s(.*)$/
+ const match = searchValue.match(pattern)
+ if (match){
+ const string = match[2].split(" ")
+ var field_string = ""
+ var data = {
+ 'model':model,
+ 'field_string':string,
+ 'regex':2,
+ }
+ rpc.query({
+ model:'ir.model',
+ method:'check_fields_model',
+ args:[data]
+ }).then(function(res){
+ if (res.length!=0){
+ data['field_string'] = match[2].replace(res[0]['del'],"")
+ data['field'] = res[0]['name']
+ data['field_type'] = res[0]['ttype']
+ data['field_relation'] = res[0]['relation']
+ rpc.query({
+ model:'ir.model',
+ method:'get_records',
+ args:[data]
+ }).then(function(res){
+ self.action.doAction({
+ name:'Records',
+ type: 'ir.actions.act_window',
+ res_model: model,
+ domain: [["id", "in", res]],
+ views: [[false, "list"], [false, "form"]],
+ view_mode: "list,form",
+ target: "current",
+ })
+ })
+ self.props.close()
+ }
+ else{
+ self.props.close()
+ var buttons = [
+ {
+ text: _t("Ok"),
+ classes: 'btn-primary',
+ close: true,
+ },
+ ];
+ new Dialog(self, {
+ size: 'medium',
+ buttons: buttons,
+ $content: $('
', {
+ text:_t("field not found")
+ }),
+ }).open();
+ }
+ })
+ }
+ },
+ //Executing the command
+ async executeCommand(command) {
+ if (this.state.namespace != '!'){
+ const config = await command.action();
+ if (config) {
+ this.setCommandPaletteConfig(config);
+ }
+ else {
+ this.props.close();
+ }
+ }
+ }
+});
diff --git a/text_commander/static/src/js/model_providers.js b/text_commander/static/src/js/model_providers.js
new file mode 100644
index 000000000..3dffa009c
--- /dev/null
+++ b/text_commander/static/src/js/model_providers.js
@@ -0,0 +1,27 @@
+/** @odoo-module **/
+
+import { _lt } from "@web/core/l10n/translation";
+import { registry } from "@web/core/registry";
+import { Component } from "@odoo/owl";
+//Creates a class for rendering the template when the commander is entered
+class ModelItemCommand extends Component {}
+ModelItemCommand.template = "text_commander.ModelItemsCommand";
+//Creating a new namespace
+const ModelItemCommandRegistry = registry.category("command_setup");
+ModelItemCommandRegistry.add("!", {
+ debounceDelay: 200,
+ emptyMessage: _lt("Commands: "),
+ name: _lt("Record"),
+ placeholder: _lt("Search for a record..."),
+});
+const ModelItemCommandProvider = registry.category("command_provider");
+ModelItemCommandProvider.add("model",{
+ namespace: "!",
+ async provide(env, options){
+ const suggestion = []
+ suggestion.push({
+ Component: ModelItemCommand,
+ });
+ return suggestion
+ },
+});
diff --git a/text_commander/static/src/xml/model_command_item.xml b/text_commander/static/src/xml/model_command_item.xml
new file mode 100644
index 000000000..61841866d
--- /dev/null
+++ b/text_commander/static/src/xml/model_command_item.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+ Open Record:
+
+
+ !Open <Model Name>/Value
+
+
+ !Open <Model Name> <of/in>
+ <field name> >value>
+
+
+ Eg:!Open sales order/S00016
+
+ !Open sales order of customer
+ azure
+
+
+
+ Create Record:
+
+
+ !Create <Model Name>
+
+ Eg: !Create purchase order
+
+
+
+