跳至内容
菜单
此问题已终结
3657 查看

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 ?

形象
丢弃
相关帖文 回复 查看 活动
0
5月 21
3791
0
7月 25
290
1
7月 25
5068
0
7月 25
630
0
6月 25
699