[FIX] account: actionable errors widget state
The widget for actionable errors does not update when the errors it displays are updated due to, for example, a recomputation of the field. This results in irrelevant errors being displayed in the view, when a particular configuration is correct. The correct errors (or an absence of any errors) will not be displayed until the view is refreshed. This commit adapts the component, such that the record data is accessed directly from the template. This means that the recordObserver, and the method it uses can be removed (as they were redundant) closes odoo/odoo#155914 Task-id: None Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
This commit is contained in:
@@ -3,21 +3,11 @@
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates>
|
||||
<t t-name="account.ActionableErrors">
|
||||
<t t-if="errorsData">
|
||||
<t t-if="this.props.record.data[this.props.name]">
|
||||
<div class="alert alert-warning mb-2 px-3 py-2" role="alert">
|
||||
<t t-foreach="errorsData" t-as="error" t-key="error">
|
||||
<t t-foreach="this.props.record.data[this.props.name]" t-as="error" t-key="error">
|
||||
<div t-att-name="error">
|
||||
<t t-out="error_value.message"/>
|
||||
<a class="fw-bold"
|
||||
|
||||
Reference in New Issue
Block a user