diff --git a/addons/iap/__manifest__.py b/addons/iap/__manifest__.py index 39d20462b95..45b8d4b9804 100644 --- a/addons/iap/__manifest__.py +++ b/addons/iap/__manifest__.py @@ -22,13 +22,13 @@ to support In-App purchases inside Odoo. """, 'auto_install': True, 'assets': { 'web.assets_backend': [ - 'iap/static/src/js/**/*', + 'iap/static/src/**/*.js', ], 'web.tests_assets': [ 'iap/static/tests/**/*', ], 'web.assets_qweb': [ - 'iap/static/src/xml/**/*', + 'iap/static/src/**/*.xml', ], }, 'license': 'LGPL-3', diff --git a/addons/iap/static/src/action_buttons_widget/action_buttons_widget.js b/addons/iap/static/src/action_buttons_widget/action_buttons_widget.js new file mode 100644 index 00000000000..10a1fc398a0 --- /dev/null +++ b/addons/iap/static/src/action_buttons_widget/action_buttons_widget.js @@ -0,0 +1,38 @@ +/** @odoo-modules */ + +import { registry } from "@web/core/registry"; +import { useService } from "@web/core/utils/hooks"; + +const { Component } = owl; + +class IAPActionButtonsWidget extends Component { + setup() { + this.orm = useService("orm"); + this.action = useService("action"); + } + + async onViewServicesClicked() { + const url = await this.orm.silent.call("iap.account", "get_account_url"); + this.action.doAction({ + type: "ir.actions.act_url", + url: url, + }); + } + + async onBuyLinkClicked() { + const url = await this.orm.silent.call("iap.account", "get_credits_url", [this.props.serviceName]); + this.action.doAction({ + type: "ir.actions.act_url", + url: url, + }); + } +} +IAPActionButtonsWidget.template = "iap.ActionButtonsWidget"; +IAPActionButtonsWidget.extractProps = ({ attrs }) => { + return { + serviceName: attrs.service_name, + showServiceButtons: !Boolean(attrs.hide_service), + }; +}; + +registry.category("view_widgets").add("iap_buy_more_credits", IAPActionButtonsWidget); diff --git a/addons/iap/static/src/action_buttons_widget/action_buttons_widget.xml b/addons/iap/static/src/action_buttons_widget/action_buttons_widget.xml new file mode 100644 index 00000000000..fe8ec15744e --- /dev/null +++ b/addons/iap/static/src/action_buttons_widget/action_buttons_widget.xml @@ -0,0 +1,13 @@ + +