-
-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] report_py3o: Migration to 15.0
- Loading branch information
1 parent
19335d8
commit 1155598
Showing
11 changed files
with
85 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** @odoo-module **/ | ||
|
||
import {download} from "@web/core/network/download"; | ||
import {registry} from "@web/core/registry"; | ||
|
||
registry | ||
.category("ir.actions.report handlers") | ||
.add("py3o_handler", async function (action, options, env) { | ||
if (action.report_type === "py3o") { | ||
let url = `/report/py3o/${action.report_name}`; | ||
const actionContext = action.context || {}; | ||
if ( | ||
_.isUndefined(action.data) || | ||
_.isNull(action.data) || | ||
(_.isObject(action.data) && _.isEmpty(action.data)) | ||
) { | ||
// Build a query string with `action.data` (it's the place where reports | ||
// using a wizard to customize the output traditionally put their options) | ||
if (actionContext.active_ids) { | ||
var activeIDsPath = "/" + actionContext.active_ids.join(","); | ||
url += activeIDsPath; | ||
} | ||
} else { | ||
var serializedOptionsPath = | ||
"?options=" + encodeURIComponent(JSON.stringify(action.data)); | ||
serializedOptionsPath += | ||
"&context=" + encodeURIComponent(JSON.stringify(actionContext)); | ||
url += serializedOptionsPath; | ||
} | ||
env.services.ui.block(); | ||
try { | ||
await download({ | ||
url: "/report/download", | ||
data: { | ||
data: JSON.stringify([url, action.report_type]), | ||
context: JSON.stringify(env.services.user.context), | ||
}, | ||
}); | ||
} finally { | ||
env.services.ui.unblock(); | ||
} | ||
const onClose = options.onClose; | ||
if (action.close_on_report_download) { | ||
return env.services.action.doAction( | ||
{type: "ir.actions.act_window_close"}, | ||
{onClose} | ||
); | ||
} else if (onClose) { | ||
onClose(); | ||
} | ||
return Promise.resolve(true); | ||
} | ||
return Promise.resolve(false); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.