Files
odoo_source/addons/web/static/tests/webclient/currency_service_tests.js
T
Géry Debongnie 3db0ad01a1 [REF] web, *: rework webclient cache invalidation system
The web client has a mechanism to invalidate the action and the view
cache: in the basic model (and the relationalmodel), some code is
looking for updates to some specific models (such as ir.actions) and
trigger a `CLEAR-CACHE` event. This event is then listened by the action
and view services to properly clear the caches.  This mechanism was also
used to reload the page after editing a company, or reloading the
currencies after editing some currency.

With this commit, we modify the orm service to trigger an event after
each rpc. This event can then be used by the action/view service, and
also by the currency/company services to perform their specific cleanup.
This work is one step in the future refactoring of the relational model.

closes odoo/odoo#115655

Related: odoo/enterprise#38814
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-27 16:04:58 +02:00

32 lines
1.2 KiB
JavaScript

/** @odoo-module **/
import { ormService } from "@web/core/orm_service";
import { registry } from "@web/core/registry";
import { currencyService } from "@web/webclient/currency_service";
import { makeTestEnv } from "../helpers/mock_env";
import { makeFakeRPCService } from "../helpers/mock_services";
const serviceRegistry = registry.category("services");
QUnit.module("currency service");
QUnit.test("reload currencies when updating a res.currency", async (assert) => {
serviceRegistry.add("currency", currencyService);
serviceRegistry.add("orm", ormService);
const fakeRpc = makeFakeRPCService((route) => {
assert.step(route);
});
serviceRegistry.add("rpc", fakeRpc);
const env = await makeTestEnv();
assert.verifySteps([]);
await env.services.orm.read("res.currency", [32]);
assert.verifySteps(["/web/dataset/call_kw/res.currency/read"]);
await env.services.orm.unlink("res.currency", [32]);
assert.verifySteps([
"/web/dataset/call_kw/res.currency/unlink",
"/web/session/get_session_info",
]);
await env.services.orm.unlink("notcurrency", [32]);
assert.verifySteps(["/web/dataset/call_kw/notcurrency/unlink"]);
});