odoo/documentation#13151

Created by Léo Leclerc (leol)
Merged at 2712116544f4201e2158c25729aa5f8b5440ebf1

Statuses:

label
leclerc-leo:18.0
head
26d7bb71e149d032440057f9ce416a8fbdcf6190
merged
3 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

[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).