mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-22 19:32:00 +02:00
Initial commit: Core packages
This commit is contained in:
commit
12c29a983b
9512 changed files with 8379910 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
/** @odoo-module */
|
||||
import { registry } from "@web/core/registry";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
|
||||
const { Component } = owl;
|
||||
|
||||
class ButtonWithNotification extends Component {
|
||||
setup() {
|
||||
this.orm = useService("orm");
|
||||
this.notification = useService("notification");
|
||||
}
|
||||
|
||||
async onClick() {
|
||||
const result = await this.orm.call(this.props.record.resModel, this.props.method, [this.props.record.resId]);
|
||||
const message = result.toast_message;
|
||||
this.notification.add(message, { type: "success" });
|
||||
}
|
||||
}
|
||||
ButtonWithNotification.template = "purchase.ButtonWithNotification";
|
||||
ButtonWithNotification.extractProps = ({ attrs }) => {
|
||||
return {
|
||||
method: attrs.button_name,
|
||||
title: attrs.title,
|
||||
};
|
||||
};
|
||||
|
||||
registry.category("view_widgets").add("toaster_button", ButtonWithNotification);
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<template>
|
||||
|
||||
<t t-name="purchase.ButtonWithNotification" owl="1">
|
||||
<button t-on-click="onClick" t-att-name="props.method" type="button" class="btn oe_inline btn-link" t-att-title="props.title">
|
||||
<i class="fa fa-fw o_button_icon fa-info-circle"></i>
|
||||
</button>
|
||||
</t>
|
||||
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue