Error when using userService("orm") - odoo16
I was on a mission to create a new page, and here's how I did it.
1. root/controller => Create a Controller that renders the root template
@http.route("/tracking", type="http", website=True, csrf=False, auth="public")
def tracking_page(self):
return http.request.render("tpc_custom_website.tracking_owl")
2. views/template.xml => Create a template containing a div with id root_owl
3. static/src/js => Generate js to use owl framework
import {useState, Component, whenReady, App, onWillStart, mount} from "@odoo/owl"
import {templates} from "@web/core/assets"
import {useService} from "@web/core/utils/hooks";
class TrackingOwl extends Component {
setup() {
super.setup();
this.orm = useService("orm")
}
}
TrackingOwl.template = "tpc_custom_website.tracking_owl"
whenReady(async () => {
const tracking_owl_root = document.querySelector("#root_owl")
if (tracking_owl_root)
await mount(TrackingOwl, tracking_owl_root, {templates})
});
4. static/src/xml => Create component to mount to root
Page tracking
5. in file __manifest__
"data": [
'views/template.xml'
],
"assets": {
"web.assets_frontend": [
'{module_name}/static/src/js/tracking.js',
'{module_name}/static/src/xml/tracking_page.xml'
]
},
and I get an error in step 3 with the message "TypeError: Cannot use 'in' operator to search for 'orm' in undefined"
So how do I fix this error, thank you everyone