Skip to Content
Menu
This question has been flagged
2862 Views

Hi!

I was trying to get a better understanding of the intepretation of the XML attributes and how, when and why odoo properly evaluates expressions inside those attributes. Then I found this function:

https://github.com/odoo/odoo/blob/a463a8718979581bbaec1e2a67edfded6ba35ffc/addons/web/static/src/js/views/basic/basic_model.js#L2090

/**

     * Evaluate modifiers

     *

     * @private

     * @param {Object} element a valid element object, which will serve as eval

     *   context.

     * @param {Object} modifiers

     * @returns {Object}

     */

    _evalModifiers: function (element, modifiers) {

        var result = {};

        var self = this;

        var evalContext;

        function evalModifier(mod) {

            if (mod === undefined || mod === false || mod === true) {

                return !!mod;

            }

            evalContext = evalContext || self._getEvalContext(element);

            return new Domain(mod, evalContext).compute(evalContext);

        }

        if ('invisible' in modifiers) {

            result.invisible = evalModifier(modifiers.invisible);

        }

        if ('column_invisible' in modifiers) {

            result.column_invisible = evalModifier(modifiers.column_invisible);

        }

        if ('readonly' in modifiers) {

            result.readonly = evalModifier(modifiers.readonly);

        }

        if ('required' in modifiers) {

            result.required = evalModifier(modifiers.required);

        }

        return result;

    },

Is there ANY special reason why to hard-code these specific modifiers ?

Avatar
Discard
Related Posts Replies Views Activity
0
May 21
2933
1
Dec 24
116
2
Nov 24
82
1
Oct 24
257
0
Sep 24
212