[MIG] web_action_conditionable: Migration to 11.0

This commit is contained in:
andreparames
2018-01-22 18:17:04 +01:00
committed by Jasmin Solanki
parent 774227d4ee
commit c96631ffe3
5 changed files with 53 additions and 56 deletions

View File

@@ -1,22 +1,24 @@
/*global openerp, _, $ */
odoo.define('web.web_action_conditionable', function (require) {
"use strict";
openerp.web_action_conditionable = function (instance) {
instance.web.View.include({
is_action_enabled: function(action) {
var attrs = this.fields_view.arch.attrs;
if (action in attrs) {
try {
return this._super(action);
} catch(error) {
var expr = attrs[action];
var expression = py.parse(py.tokenize(expr));
var cxt = this.dataset.get_context().__eval_context.__contexts[1];
var result = py.evaluate(expression, cxt).toJSON();
return result
}
} else {
return true;
}
}
});
}
var View = require('web.View');
View.include({
is_action_enabled: function(action) {
var attrs = this.fields_view.arch.attrs;
if (action in attrs) {
try {
return this._super(action);
} catch(error) {
var expr = attrs[action];
var expression = py.parse(py.tokenize(expr));
var cxt = this.dataset.get_context().__eval_context.__contexts[1];
var result = py.evaluate(expression, cxt).toJSON();
return result
}
} else {
return true;
}
}
});
});