You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
566 B

  1. /*global openerp, _, $ */
  2. openerp.web_action_conditionable = function (instance) {
  3. instance.web.View.include({
  4. is_action_enabled: function(action) {
  5. var attrs = this.fields_view.arch.attrs;
  6. if (action in attrs) {
  7. try {
  8. return this._super(action);
  9. } catch(error) {
  10. var expr = attrs[action];
  11. var expression = py.parse(py.tokenize(expr));
  12. var cxt = this.dataset.get_context().__eval_context.__contexts[1];
  13. var result = py.evaluate(expression, cxt).toJSON();
  14. return result
  15. }
  16. } else {
  17. return true;
  18. }
  19. }
  20. });
  21. }