From 991c74746c04b51a75666a6fc16483def3771e6c Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Fri, 3 Jul 2015 01:26:28 +0200 Subject: [PATCH] port web_readonly_bypass on v7 --- web_readonly_bypass/__openerp__.py | 98 ++++++++++++++----- .../static/src/js/readonly_bypass.js | 7 +- web_readonly_bypass/views/readonly_bypass.xml | 12 --- 3 files changed, 80 insertions(+), 37 deletions(-) delete mode 100644 web_readonly_bypass/views/readonly_bypass.xml diff --git a/web_readonly_bypass/__openerp__.py b/web_readonly_bypass/__openerp__.py index 7f6410e1..cb2fdee9 100644 --- a/web_readonly_bypass/__openerp__.py +++ b/web_readonly_bypass/__openerp__.py @@ -3,14 +3,6 @@ # # Authors: Nemry Jonathan & Laetitia Gangloff # Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) -# All Rights Reserved -# -# WARNING: This program as such is intended to be used by professional -# programmers who take the whole responsibility of assessing all potential -# consequences resulting from its eventual inadequacies and bugs. -# End users who are looking for a ready-to-use solution with commercial -# guarantees and support are strongly advised to contact a Free Software -# Service Company. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -29,8 +21,8 @@ { 'name': 'Read Only ByPass', 'version': '1.0', - "author": "ACSONE SA/NV", - "maintainer": "ACSONE SA/NV", + "author": "ACSONE SA/NV, Anybox", + "maintainer": "ACSONE SA/NV, Odoo Community Association (OCA)", "website": "http://www.acsone.eu", 'category': 'Technical Settings', 'depends': [ @@ -38,24 +30,86 @@ 'web', ], 'description': """ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + Read Only ByPass ================ -This Module provides a solution to the problem of the interaction between -'readonly' attribute and 'on_change' attribute when used together -Behavior: add `readonly_fields` changed by `on_change` into the fields passing -into an update or create. If `filter_out_readonly` is into the context and set +This module provides a solution to the problem of the interaction between +'readonly' attribute and 'on_change' attribute when used together. It allows +saving onchange modifications to readonly fields. + +Behavior: add readonly fields changed by `on_change` methods to the values +passed to write or create. If `filter_out_readonly` is in the context and True then apply native behavior. + +Installation +============ + +There are no specific installation instructions for this module. + +Configuration +============= + +There is nothing to configure. + +Usage +===== + +This module changes the default behaviour of Odoo by propagating +on_change modifications to readonly fields to the backend create and write +methods. + +To restore the standard behaviour, set `filter_out_readonly` in the context. + +For further information, please visit: + +* https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + +None + +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 +------------ + +* Jonathan Nemry +* Laetitia Gangloff +* Pierre Verkest + +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. """, - 'images': [], - 'data': [ - 'views/readonly_bypass.xml', - ], - 'qweb': [ + 'js': [ + 'static/src/js/readonly_bypass.js', ], - 'css': [], - 'demo': [], - 'test': [], 'installable': True, 'auto_install': False, + 'application': False, } diff --git a/web_readonly_bypass/static/src/js/readonly_bypass.js b/web_readonly_bypass/static/src/js/readonly_bypass.js index d8581f3e..d497826a 100644 --- a/web_readonly_bypass/static/src/js/readonly_bypass.js +++ b/web_readonly_bypass/static/src/js/readonly_bypass.js @@ -2,7 +2,7 @@ * Allow to bypass readonly fi the value is changed */ -openerp.readonly_bypass = function(instance) { +openerp.web_readonly_bypass = function(instance) { var QWeb = instance.web.qweb, _t = instance.web._t; /** @@ -19,8 +19,9 @@ openerp.readonly_bypass = function(instance) { */ function ignore_readonly(data, options, mode, context){ if (options){ - if (!('filter_out_readonly' in context && context['filter_out_readonly'] == true - && 'readonly_fields' in options && options['readonly_fields'])) { + if ('readonly_fields' in options && options['readonly_fields'] && + !('filter_out_readonly' in context && + context['filter_out_readonly'] == true)) { if(mode){ $.each( options.readonly_fields, function( key, value ) { if(value==false){ diff --git a/web_readonly_bypass/views/readonly_bypass.xml b/web_readonly_bypass/views/readonly_bypass.xml deleted file mode 100644 index 2bad7ace..00000000 --- a/web_readonly_bypass/views/readonly_bypass.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file