Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import {ActWindowMessageDialog} from "./web_ir_actions_act_window_msg_component.esm";
import {markup} from "@odoo/owl";
import {registry} from "@web/core/registry";
// Define a function to open the dialog
function openDialog({env, action}) {
// Created new Dialog widget.
env.services.dialog.add(ActWindowMessageDialog, {
title: action.title,
body: action.is_html_message ? markup(action.message) : action.message,
action: action,
is_html_message: action.is_html_message,
size: "md",
env: env,
});
}
registry.category("action_handlers").add("ir.actions.act_window.message", openDialog);

View File

@@ -0,0 +1,89 @@
import {Component, onWillStart, useState} from "@odoo/owl";
import {Dialog} from "@web/core/dialog/dialog";
import {_t} from "@web/core/l10n/translation";
export class ActWindowMessageDialog extends Component {
setup() {
this.state = useState({
buttons: [],
});
onWillStart(this.willStart);
}
async willStart() {
this.generateButtons();
}
_refreshWidget(env) {
const controller = env.services.action.currentController;
const state = env.services.router.current.hash;
const props = controller.props;
env.services.action.switchView(props.type, {resId: state.id});
}
generateButtons() {
var self = this;
const action = self.props.action;
const env = self.props.env;
if (action.close_button_title !== false) {
self.state.buttons.push({
name: action.close_button_title || _t("Close"),
click: () => {
// Refresh the view before closing the dialog
self._refreshWidget(env);
self.props.close();
},
classes: "btn btn-default",
});
}
for (var i = 0; action.buttons && i < action.buttons.length; i++) {
const button = action.buttons[i];
const button_data = {
name: button.name || "No name set",
classes: button.classes || "btn btn-default",
click: () => {
if (button.type === "method") {
env.services
.rpc("/web/dataset/call_button", {
model: button.model,
method: button.method,
args: button.args,
kwargs: button.kwargs,
})
.then(function (result) {
if (typeof result === "object") {
return env.services.action.doAction(result);
}
self._refreshWidget(env);
});
} else {
return env.services.action.doAction(button);
}
self.props.close();
},
};
self.state.buttons.push(button_data);
}
}
}
ActWindowMessageDialog.template =
"web_ir_actions_act_window_message.ActWindowMessageDialog";
ActWindowMessageDialog.components = {
Dialog,
};
ActWindowMessageDialog.props = {
title: {
type: String,
optional: true,
},
body: {
type: String,
optional: true,
},
action: {type: Object, optional: true},
env: {type: Object, optional: true},
is_html_message: {type: Boolean, optional: true},
size: {type: String},
close: Function,
};

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="web_ir_actions_act_window_message.ActWindowMessageDialog">
<Dialog size="props.size" title="props.title">
<div t-att-style="!props.is_html_message ? 'white-space: pre-line' : ''">
<t t-out="props.body" />
</div>
<t t-set-slot="footer">
<t t-foreach="state.buttons" t-as="button" t-key="button.name">
<button
t-att-class="button.classes"
t-out="button.name"
t-on-click="button.click"
/>
</t>
</t>
</Dialog>
</t>
</templates>