diff --git a/web_action_conditionable/README.rst b/web_action_conditionable/README.rst new file mode 100644 index 00000000..4ed2152b --- /dev/null +++ b/web_action_conditionable/README.rst @@ -0,0 +1,87 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Web Action Conditionable +======================== + +This module was written to extend the functionality of actions in tree views. +Odoo by default support: + +:: + + + +with this module you can: + +:: + + + +It works in any tree view, so you can use it in One2many. + + +Installation +============ + +To install this module, just follow basic steps to install an odoo module. + + +Configuration +============= + +Not needed. + +Usage +===== + +To use this module, you need to: + +* go to ... + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/web/8.0 + +.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt +.. branch is "8.0" for example + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + +* ... + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + + +Credits +======= + +Contributors +------------ + +* Cristian Salamea + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/web_action_conditionable/__init__.py b/web_action_conditionable/__init__.py new file mode 100644 index 00000000..40a96afc --- /dev/null +++ b/web_action_conditionable/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/web_action_conditionable/__openerp__.py b/web_action_conditionable/__openerp__.py new file mode 100644 index 00000000..5f4793c5 --- /dev/null +++ b/web_action_conditionable/__openerp__.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +{ + "name": 'web_action_conditionable', + "version": "0.1", + "depends": [ + 'base', + 'web', + ], + 'data': ['views/view.xml'], + "author": "Cristian Salamea,Odoo Community Association (OCA)", + "installable": True, +} diff --git a/web_action_conditionable/static/src/js/views.js b/web_action_conditionable/static/src/js/views.js new file mode 100644 index 00000000..5eeb6c4a --- /dev/null +++ b/web_action_conditionable/static/src/js/views.js @@ -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; + } + } + }); +} diff --git a/web_action_conditionable/views/view.xml b/web_action_conditionable/views/view.xml new file mode 100644 index 00000000..c1de0b32 --- /dev/null +++ b/web_action_conditionable/views/view.xml @@ -0,0 +1,10 @@ + + + + + +