mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
cherry-pick c639533 combine context, Get windows_action context in
BufferedDataSet Class
This commit is contained in:
@@ -9,8 +9,9 @@ This module provides a solution to the problem of the interaction between
|
|||||||
saving onchange modifications to readonly fields.
|
saving onchange modifications to readonly fields.
|
||||||
|
|
||||||
Behavior: add readonly fields changed by `on_change` methods to the values
|
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
|
passed to write or create. If `readonly_by_pass` is in the context and
|
||||||
True then apply native behavior.
|
True then it will by pass readonly fields and save its data provide by onchange
|
||||||
|
method.
|
||||||
|
|
||||||
Installation
|
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
|
on_change modifications to readonly fields to the backend create and write
|
||||||
methods.
|
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:
|
For further information, please visit:
|
||||||
|
|
||||||
@@ -38,7 +51,6 @@ For further information, please visit:
|
|||||||
Known issues / Roadmap
|
Known issues / Roadmap
|
||||||
======================
|
======================
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
/*
|
(function(){
|
||||||
* Allow to bypass readonly fi the value is changed
|
var instance = openerp;
|
||||||
*/
|
|
||||||
|
|
||||||
openerp.web_readonly_bypass = function(instance) {
|
|
||||||
|
|
||||||
var QWeb = instance.web.qweb, _t = instance.web._t;
|
var QWeb = instance.web.qweb, _t = instance.web._t;
|
||||||
var instance = instance;
|
|
||||||
|
|
||||||
instance.web_readonly_bypass = {
|
instance.web_readonly_bypass = {
|
||||||
/**
|
/**
|
||||||
@@ -21,11 +16,8 @@ openerp.web_readonly_bypass = function(instance) {
|
|||||||
* @param {Object} context->readonly_by_pass
|
* @param {Object} context->readonly_by_pass
|
||||||
*/
|
*/
|
||||||
ignore_readonly: function(data, options, mode, context){
|
ignore_readonly: function(data, options, mode, context){
|
||||||
console.log(options );
|
|
||||||
console.log(context );
|
|
||||||
var readonly_by_pass_fields = this.retrieve_readonly_by_pass_fields(
|
var readonly_by_pass_fields = this.retrieve_readonly_by_pass_fields(
|
||||||
options, context);
|
options, context);
|
||||||
console.log(readonly_by_pass_fields );
|
|
||||||
if(mode){
|
if(mode){
|
||||||
$.each( readonly_by_pass_fields, function( key, value ) {
|
$.each( readonly_by_pass_fields, function( key, value ) {
|
||||||
if(value==false){
|
if(value==false){
|
||||||
@@ -34,7 +26,6 @@ openerp.web_readonly_bypass = function(instance) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
data = $.extend(data,readonly_by_pass_fields);
|
data = $.extend(data,readonly_by_pass_fields);
|
||||||
console.log(data );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,7 +76,9 @@ openerp.web_readonly_bypass = function(instance) {
|
|||||||
*/
|
*/
|
||||||
create : function(data, options) {
|
create : function(data, options) {
|
||||||
var self = this;
|
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);
|
return self._super(data,options);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -99,7 +92,9 @@ openerp.web_readonly_bypass = function(instance) {
|
|||||||
*/
|
*/
|
||||||
write : function(id, data, options) {
|
write : function(id, data, options) {
|
||||||
var self = this;
|
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);
|
return self._super(id,data,options);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -142,4 +137,4 @@ openerp.web_readonly_bypass = function(instance) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
})();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
openerp.testing.section( 'web_readonly_bypass', {},
|
openerp.testing.section( 'web_readonly_bypass', {},
|
||||||
function(test){
|
function(test){
|
||||||
test('ignore_readonly', function(instance){
|
test('ignore_readonly', function(instance){
|
||||||
openerp.web_readonly_bypass(instance);
|
|
||||||
var data = {};
|
var data = {};
|
||||||
var mode_create = true;
|
var mode_create = true;
|
||||||
var options = {};
|
var options = {};
|
||||||
@@ -63,7 +62,6 @@ function(test){
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('retrieve_readonly_by_pass_fields', function(instance){
|
test('retrieve_readonly_by_pass_fields', function(instance){
|
||||||
openerp.web_readonly_bypass(instance);
|
|
||||||
var context = {'readonly_by_pass': true}
|
var context = {'readonly_by_pass': true}
|
||||||
var options = {'readonly_fields': {'field_1': 'va1-1',
|
var options = {'readonly_fields': {'field_1': 'va1-1',
|
||||||
'field_2': 'val-2',
|
'field_2': 'val-2',
|
||||||
|
|||||||
Reference in New Issue
Block a user