odoo/documentation#13232

Created by fw-bot
Merged at 8d6b23aa1c8ed71106faac9ac4bf46d5f8a1de5f

Statuses:

label
odoo-dev:saas-18.1-18.0-433053-fw
head
9effac986ddc94a0942d301a77536f56c9a147f1
merged
2 days ago by JavaScript, Florent Dardenne (dafl)
odoo/documentation
18.0 #13151
saas-18.1 #13232
saas-18.2 #13233
saas-18.3 #13234
master #13235

[FW][FIX] rpc: fix code examples for tutorial and service

I am a newbie from April and was following the "Discover the web framework" guide (https://www.odoo.com/documentation/18.0/developer/tutorials/discover_js_framework/02_build_a_dashboard.html#call-the-server-add-some-statistics) and saw that the link and example provided were outdated.

For example, it was like this:

setup() {
      this.rpc = useService("rpc");
      onWillStart(async () => {
         const result = await this.rpc("/my/controller", {a: 1, b: 2});
         // ...
      });
}

Which is now

import { rpc } from "@web/core/network/rpc";
// ... 

setup() {
      onWillStart(async () => {
            const syncResult = await rpc("/my/controller", {a: 1, b: 2});
      })
      // ...
}

I also changed the code example inside the Reference for the RPC service as it was also out of date. There might be a need to move this to another category as it might not be a Service anymore, I wasn't able to determine is it would be best or not (or which one would be best).

Forward-Port-Of: #13151