[FIX] web: currency reload
The currency service is responsible for reloading currencies from the session_info, however it does not retrieve the correct key/value. The issue can be reproduced in saas-16.4: - Activate a currency - Accounting Dashboard > Reconcile x items - Client stack trace (after hard refresh the correct currencies are loaded) closes odoo/odoo#132375 Cause: the `reloadCurrencies` method is assigning the entire session_info response object to the session's currencies X-original-commit: bbbf836f99b0271442e5e3a7ec03f108de69ec78 Signed-off-by: Francois Georis (fge) <fge@odoo.com> Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
This commit is contained in:
@@ -15,7 +15,7 @@ export const currencyService = {
|
||||
for (const k in currencies) {
|
||||
delete currencies[k];
|
||||
}
|
||||
Object.assign(currencies, result);
|
||||
Object.assign(currencies, result?.currencies);
|
||||
}
|
||||
env.bus.addEventListener("RPC:RESPONSE", (ev) => {
|
||||
const { data, error } = ev.detail;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { ormService } from "@web/core/orm_service";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { currencies } from "@web/core/currency";
|
||||
import { currencyService } from "@web/webclient/currency_service";
|
||||
import { makeTestEnv } from "../helpers/mock_env";
|
||||
import { makeFakeRPCService } from "../helpers/mock_services";
|
||||
@@ -15,6 +16,14 @@ QUnit.test("reload currencies when updating a res.currency", async (assert) => {
|
||||
serviceRegistry.add("orm", ormService);
|
||||
const fakeRpc = makeFakeRPCService((route) => {
|
||||
assert.step(route);
|
||||
if (route === "/web/session/get_session_info") {
|
||||
return {
|
||||
uid: 1,
|
||||
currencies: {
|
||||
7: { symbol: "$", position: "before", digits: 2 },
|
||||
},
|
||||
};
|
||||
}
|
||||
});
|
||||
serviceRegistry.add("rpc", fakeRpc);
|
||||
const env = await makeTestEnv();
|
||||
@@ -28,6 +37,7 @@ QUnit.test("reload currencies when updating a res.currency", async (assert) => {
|
||||
]);
|
||||
await env.services.orm.unlink("notcurrency", [32]);
|
||||
assert.verifySteps(["/web/dataset/call_kw/notcurrency/unlink"]);
|
||||
assert.deepEqual(Object.keys(currencies), ["7"]);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
|
||||
Reference in New Issue
Block a user