Browse Source

cherry-pick c639533 combine context, Get windows_action context in

BufferedDataSet Class
pull/162/head
Pierre Verkest 9 years ago
parent
commit
56da0dbff5
  1. 22
      web_readonly_bypass/README.rst
  2. 23
      web_readonly_bypass/static/src/js/readonly_bypass.js
  3. 4
      web_readonly_bypass/static/test/web_readonly_bypass.js

22
web_readonly_bypass/README.rst

@ -8,9 +8,10 @@ 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.
Behavior: add readonly fields changed by `on_change` methods to the values
passed to write or create. If `readonly_by_pass` is in the context and
True then it will by pass readonly fields and save its data provide by onchange
method.
Installation
============
@ -29,7 +30,19 @@ 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.
To change that behavior you have to set context on ``ur.actions.act_window``::
<record id="sale.action_quotations" model="ir.actions.act_window">
<field name="context">{'readonly_by_pass': True}</field>
</record>
or by telling fields allowed to change::
<record id="sale.action_quotations" model="ir.actions.act_window">
<field name="context">
{'readonly_by_pass': ['readonly_field_1', 'readonly_field_2',]}
</field>
</record>
For further information, please visit:
@ -38,7 +51,6 @@ For further information, please visit:
Known issues / Roadmap
======================
None
Bug Tracker
===========

23
web_readonly_bypass/static/src/js/readonly_bypass.js

@ -1,11 +1,6 @@
/*
* Allow to bypass readonly fi the value is changed
*/
openerp.web_readonly_bypass = function(instance) {
(function(){
var instance = openerp;
var QWeb = instance.web.qweb, _t = instance.web._t;
var instance = instance;
instance.web_readonly_bypass = {
/**
@ -21,11 +16,8 @@ openerp.web_readonly_bypass = function(instance) {
* @param {Object} context->readonly_by_pass
*/
ignore_readonly: function(data, options, mode, context){
console.log(options );
console.log(context );
var readonly_by_pass_fields = this.retrieve_readonly_by_pass_fields(
options, context);
console.log(readonly_by_pass_fields );
if(mode){
$.each( readonly_by_pass_fields, function( key, value ) {
if(value==false){
@ -34,7 +26,6 @@ openerp.web_readonly_bypass = function(instance) {
});
}
data = $.extend(data,readonly_by_pass_fields);
console.log(data );
},
/**
@ -85,7 +76,9 @@ openerp.web_readonly_bypass = function(instance) {
*/
create : function(data, options) {
var self = this;
readonly_bypass.ignore_readonly(data, options, true, self.context);
var context = instance.web.pyeval.eval('contexts',
self.context.__eval_context);
readonly_bypass.ignore_readonly(data, options, true, context);
return self._super(data,options);
},
/**
@ -99,7 +92,9 @@ openerp.web_readonly_bypass = function(instance) {
*/
write : function(id, data, options) {
var self = this;
readonly_bypass.ignore_readonly(data, options, false, self.context);
var context = instance.web.pyeval.eval('contexts',
self.context.__eval_context);
readonly_bypass.ignore_readonly(data, options, false, context);
return self._super(id,data,options);
},
@ -142,4 +137,4 @@ openerp.web_readonly_bypass = function(instance) {
},
});
};
})();

4
web_readonly_bypass/static/test/web_readonly_bypass.js

@ -1,7 +1,6 @@
openerp.testing.section( 'web_readonly_bypass', {},
function(test){
test('ignore_readonly', function(instance){
openerp.web_readonly_bypass(instance);
var data = {};
var mode_create = true;
var options = {};
@ -63,7 +62,6 @@ function(test){
});
test('retrieve_readonly_by_pass_fields', function(instance){
openerp.web_readonly_bypass(instance);
var context = {'readonly_by_pass': true}
var options = {'readonly_fields': {'field_1': 'va1-1',
'field_2': 'val-2',
@ -165,4 +163,4 @@ function(test){
"false option and false context"
);
});
});
});
Loading…
Cancel
Save