From acf8dfc94363b0f6de2ef45e7e8c2e5aa9893b42 Mon Sep 17 00:00:00 2001 From: lme-axelor <102581501+lme-axelor@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:59:55 +0100 Subject: [PATCH] fix: reduce number of call of print action --- changelogs/unreleased/87597.json | 5 +++++ packages/core/src/header/hooks.js | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 changelogs/unreleased/87597.json diff --git a/changelogs/unreleased/87597.json b/changelogs/unreleased/87597.json new file mode 100644 index 0000000000..1122886dce --- /dev/null +++ b/changelogs/unreleased/87597.json @@ -0,0 +1,5 @@ +{ + "title": "Print header action: check if a template exists only when model and id are present", + "type": "fix", + "packages": "core" +} diff --git a/packages/core/src/header/hooks.js b/packages/core/src/header/hooks.js index 143366e048..ba82a58cf1 100644 --- a/packages/core/src/header/hooks.js +++ b/packages/core/src/header/hooks.js @@ -107,11 +107,13 @@ export const useBasicActions = ({ }, [model]); useEffect(() => { - fetchActionPrint({model, id: modelId}) - .catch(() => setDisablePrinting(true)) - .then(({templateSet, fileName}) => { - setDisablePrinting(templateSet == null && fileName == null); - }); + if (model && modelId) { + fetchActionPrint({model, id: modelId}) + .catch(() => setDisablePrinting(true)) + .then(({templateSet, fileName}) => { + setDisablePrinting(templateSet == null && fileName == null); + }); + } }, [model, modelId]); const checkInternetConnection = useCallback(async () => {