diff --git a/addons/account/static/src/components/actionable_errors/actionable_errors.js b/addons/account/static/src/components/actionable_errors/actionable_errors.js new file mode 100644 index 00000000000..87db1d567fe --- /dev/null +++ b/addons/account/static/src/components/actionable_errors/actionable_errors.js @@ -0,0 +1,27 @@ +/** @odoo-module **/ + +import { registry } from "@web/core/registry"; +import { Component } from "@odoo/owl"; +import { standardFieldProps } from "@web/views/fields/standard_field_props"; +import { useRecordObserver } from "@web/model/relational_model/utils"; + +export class ActionableErrors extends Component { + static props = { ...standardFieldProps }; + static template = "account.ActionableErrors"; + + setup() { + useRecordObserver(this.formatData.bind(this)); + } + + formatData(record) { + const errorsField = record.data[this.props.name]; + this.errorsData = JSON.parse(JSON.stringify(errorsField)); + } + + async handleOnClick(errorData){ + this.env.model.action.doAction(errorData.action); + } +} + +export const actionableErrors = {component: ActionableErrors}; +registry.category("fields").add("actionable_errors", actionableErrors); diff --git a/addons/account/static/src/components/actionable_errors/actionable_errors.xml b/addons/account/static/src/components/actionable_errors/actionable_errors.xml new file mode 100644 index 00000000000..14d619208e7 --- /dev/null +++ b/addons/account/static/src/components/actionable_errors/actionable_errors.xml @@ -0,0 +1,23 @@ + + + + + + + +