[FIX] web: debug: View Metadata dialog: format dates in user tz
Before this commit, the creation date and last modification date in the metadata dialog (in debug, in any form view, click on the debug item, then View Metadata) were displayed in UTC, whereas they should be formatted in the user timezone. This commit fixes the issue. closes odoo/odoo#111153 X-original-commit: 104e17211be9098b48eac842d65b1c378af5c05a Signed-off-by: Michaël Mattiello <mcm@odoo.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import { _lt } from "@web/core/l10n/translation";
|
||||
import { Dialog } from "@web/core/dialog/dialog";
|
||||
import { editModelDebug } from "@web/core/debug/debug_utils";
|
||||
import { formatDateTime, parseDateTime } from "@web/core/l10n/dates";
|
||||
import { formatDateTime, deserializeDateTime } from "@web/core/l10n/dates";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { formatMany2one } from "@web/views/fields/formatters";
|
||||
@@ -159,8 +159,8 @@ class GetMetadataDialog extends Component {
|
||||
this.state.noupdate = metadata.noupdate;
|
||||
this.state.creator = formatMany2one(metadata.create_uid);
|
||||
this.state.lastModifiedBy = formatMany2one(metadata.write_uid);
|
||||
this.state.createDate = formatDateTime(parseDateTime(metadata.create_date));
|
||||
this.state.writeDate = formatDateTime(parseDateTime(metadata.write_date));
|
||||
this.state.createDate = formatDateTime(deserializeDateTime(metadata.create_date));
|
||||
this.state.writeDate = formatDateTime(deserializeDateTime(metadata.write_date));
|
||||
}
|
||||
}
|
||||
GetMetadataDialog.template = "web.DebugMenu.GetMetadataDialog";
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
import {
|
||||
click,
|
||||
getFixture,
|
||||
getNodesTextContent,
|
||||
legacyExtraNextTick,
|
||||
mount,
|
||||
nextTick,
|
||||
@@ -28,7 +29,7 @@ import {
|
||||
} from "../../helpers/utils";
|
||||
import { createWebClient, doAction, getActionManagerServerData } from "../../webclient/helpers";
|
||||
import { openViewItem } from "@web/webclient/debug_items";
|
||||
import { editSearchView, editView, setDefaults } from "@web/views/debug_items";
|
||||
import { editSearchView, editView, setDefaults, viewMetadata } from "@web/views/debug_items";
|
||||
|
||||
import { Component, xml } from "@odoo/owl";
|
||||
const { prepareRegistriesWithCleanup } = utils;
|
||||
@@ -668,4 +669,72 @@ QUnit.module("DebugMenu", (hooks) => {
|
||||
await click(target.querySelectorAll(".modal .modal-footer button")[1]);
|
||||
assert.containsNone(target, ".modal");
|
||||
});
|
||||
|
||||
QUnit.test("view metadata: basic rendering", async (assert) => {
|
||||
prepareRegistriesWithCleanup();
|
||||
patchWithCleanup(odoo, {
|
||||
debug: true,
|
||||
});
|
||||
|
||||
registry.category("services").add("user", makeFakeUserService());
|
||||
registry.category("debug").category("form").add("viewMetadata", viewMetadata);
|
||||
|
||||
const serverData = getActionManagerServerData();
|
||||
serverData.actions[1234] = {
|
||||
id: 1234,
|
||||
xml_id: "action_1234",
|
||||
name: "Partners",
|
||||
res_model: "partner",
|
||||
res_id: 27,
|
||||
type: "ir.actions.act_window",
|
||||
views: [[false, "form"]],
|
||||
};
|
||||
serverData.models.partner.records = [{ id: 27, display_name: "p1" }];
|
||||
|
||||
const mockRPC = async (route, args) => {
|
||||
if (args.method === "check_access_rights") {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
if (args.method === "get_metadata") {
|
||||
return [
|
||||
{
|
||||
create_date: "2023-01-26 14:12:10",
|
||||
create_uid: [4, "Some user"],
|
||||
id: 27,
|
||||
noupdate: false,
|
||||
write_date: "2023-01-26 14:13:31",
|
||||
write_uid: [6, "Another User"],
|
||||
xmlid: "abc.partner_16",
|
||||
xmlids: [{ xmlid: "abc.partner_16", noupdate: false }],
|
||||
},
|
||||
];
|
||||
}
|
||||
};
|
||||
const webClient = await createWebClient({ serverData, mockRPC });
|
||||
await doAction(webClient, 1234);
|
||||
await click(target.querySelector(".o_debug_manager button"));
|
||||
await click(target.querySelector(".o_debug_manager .dropdown-item"));
|
||||
assert.containsOnce(target, ".modal");
|
||||
assert.deepEqual(
|
||||
getNodesTextContent(
|
||||
target.querySelectorAll(".modal-body table tr th, .modal-body table tr td")
|
||||
),
|
||||
[
|
||||
"ID:",
|
||||
"27",
|
||||
"XML ID:",
|
||||
"abc.partner_16",
|
||||
"No Update:",
|
||||
"false (change)",
|
||||
"Creation User:",
|
||||
"Some user",
|
||||
"Creation Date:",
|
||||
"01/26/2023 15:12:10",
|
||||
"Latest Modification by:",
|
||||
"Another User",
|
||||
"Latest Modification Date:",
|
||||
"01/26/2023 15:13:31",
|
||||
]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user