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.

24 lines
798 B

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