mirror of https://github.com/OCA/web.git
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
/** @odoo-module **/
|
|
/* global console */
|
|
import {X2ManyField} from "@web/views/fields/x2many/x2many_field";
|
|
import {evaluateExpr} from "@web/core/py_js/py";
|
|
import {patch} from "@web/core/utils/patch";
|
|
|
|
patch(X2ManyField.prototype, {
|
|
get rendererProps() {
|
|
this.updateActiveActions();
|
|
return super.rendererProps;
|
|
},
|
|
updateActiveActions() {
|
|
if (
|
|
this.props.viewMode === "list" &&
|
|
this.activeActions.type === "one2many" &&
|
|
!this.props.readonly
|
|
) {
|
|
const self = this;
|
|
const archInfo = this.activeField.views[this.props.viewMode];
|
|
const xmlDoc = archInfo.xmlDoc;
|
|
["create", "delete"].forEach(function (item) {
|
|
if (item in self.activeActions && xmlDoc.hasAttribute(item)) {
|
|
const expr = xmlDoc.getAttribute(item);
|
|
try {
|
|
self.activeActions[item] = evaluateExpr(
|
|
expr,
|
|
self.props.record.data
|
|
);
|
|
} catch (error) {
|
|
console.warn(
|
|
"[web_action_conditionable] unrecognized expr '" +
|
|
expr +
|
|
"', ignoring"
|
|
);
|
|
console.warn(error);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
},
|
|
});
|