From 5f5dc64884d7b4dc2f58c84ef479ee62ec24816f Mon Sep 17 00:00:00 2001 From: Zakaria Makrelouf Date: Mon, 12 Feb 2018 11:20:43 +0100 Subject: [PATCH] [9.0][MIG]web_action_conditionable: migration to 9.0 --- .../odoo_addons/__init__.py | 1 + .../odoo_addons/web_action_conditionable | 1 + setup/web_action_conditionable/setup.py | 6 +++ web_action_conditionable/README.rst | 10 +--- web_action_conditionable/__init__.py | 1 - web_action_conditionable/__openerp__.py | 11 +++-- .../static/src/js/views.js | 47 ++++++++++--------- web_action_conditionable/views/view.xml | 21 +++++---- 8 files changed, 54 insertions(+), 44 deletions(-) create mode 100644 setup/web_action_conditionable/odoo_addons/__init__.py create mode 120000 setup/web_action_conditionable/odoo_addons/web_action_conditionable create mode 100644 setup/web_action_conditionable/setup.py diff --git a/setup/web_action_conditionable/odoo_addons/__init__.py b/setup/web_action_conditionable/odoo_addons/__init__.py new file mode 100644 index 00000000..de40ea7c --- /dev/null +++ b/setup/web_action_conditionable/odoo_addons/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/web_action_conditionable/odoo_addons/web_action_conditionable b/setup/web_action_conditionable/odoo_addons/web_action_conditionable new file mode 120000 index 00000000..8aa2f01a --- /dev/null +++ b/setup/web_action_conditionable/odoo_addons/web_action_conditionable @@ -0,0 +1 @@ +../../../web_action_conditionable \ No newline at end of file diff --git a/setup/web_action_conditionable/setup.py b/setup/web_action_conditionable/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/web_action_conditionable/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_action_conditionable/README.rst b/web_action_conditionable/README.rst index 4ed2152b..deec3c87 100644 --- a/web_action_conditionable/README.rst +++ b/web_action_conditionable/README.rst @@ -34,13 +34,11 @@ Not needed. Usage ===== -To use this module, you need to: - -* go to ... +This module has no direct interface, it only adds functionality for custom views. .. 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 + :target: https://runbot.odoo-community.org/runbot/162/9.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 @@ -49,10 +47,6 @@ For further information, please visit: * https://www.odoo.com/forum/help-1 -Known issues / Roadmap -====================== - -* ... Bug Tracker =========== diff --git a/web_action_conditionable/__init__.py b/web_action_conditionable/__init__.py index 40a96afc..e69de29b 100644 --- a/web_action_conditionable/__init__.py +++ b/web_action_conditionable/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/web_action_conditionable/__openerp__.py b/web_action_conditionable/__openerp__.py index 4741f8b5..9a7d5496 100644 --- a/web_action_conditionable/__openerp__.py +++ b/web_action_conditionable/__openerp__.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- { - "name": 'web_action_conditionable', - "version": "8.0.0.1.0", + "name": 'Web Action Conditionable', + "version": "9.0.1.0.0", "depends": [ - 'base', 'web', ], - 'data': ['views/view.xml'], + 'data': [ + 'views/view.xml' + ], "author": "Cristian Salamea,Odoo Community Association (OCA)", - 'installable': False, + "license": "AGPL-3", } diff --git a/web_action_conditionable/static/src/js/views.js b/web_action_conditionable/static/src/js/views.js index 5eeb6c4a..0e375f16 100644 --- a/web_action_conditionable/static/src/js/views.js +++ b/web_action_conditionable/static/src/js/views.js @@ -1,22 +1,27 @@ -/*global openerp, _, $ */ +/* Copyright 2018 Cristian Salamea + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ -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; - } - } - }); -} +odoo.define('web.web_action_conditionable', function (require) { + "use strict"; + + var View = require('web.View'); + + 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 index c1de0b32..63701830 100644 --- a/web_action_conditionable/views/view.xml +++ b/web_action_conditionable/views/view.xml @@ -1,10 +1,13 @@ - - - - - + + + + + + +