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.

27 lines
605 B

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