mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[add] web_action_conditionable
This commit is contained in:
committed by
Jairo Llopis
parent
6726c8ef74
commit
1da5bbdfa9
22
web_action_conditionable/static/src/js/views.js
Normal file
22
web_action_conditionable/static/src/js/views.js
Normal file
@@ -0,0 +1,22 @@
|
||||
/*global openerp, _, $ */
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user