mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[MIG][10.0] web_readonly_bypass rewrite JS and tests
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
"use strict";
|
||||
(function(){
|
||||
var instance = openerp;
|
||||
var QWeb = instance.web.qweb, _t = instance.web._t;
|
||||
odoo.define('web_readonly_bypass', function(require) {
|
||||
'use strict';
|
||||
|
||||
instance.web_readonly_bypass = {
|
||||
var data = require('web.data'),
|
||||
pyeval = require('web.pyeval');
|
||||
|
||||
var readonly_bypass = {
|
||||
/**
|
||||
* ignore readonly: place options['readonly_fields'] into the data
|
||||
* if nothing is specified into the context
|
||||
@@ -26,7 +27,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
data = $.extend(data,readonly_by_pass_fields);
|
||||
data = $.extend(data, readonly_by_pass_fields);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -59,15 +60,13 @@
|
||||
},
|
||||
};
|
||||
|
||||
var readonly_bypass = instance.web_readonly_bypass;
|
||||
|
||||
instance.web.BufferedDataSet.include({
|
||||
data.BufferedDataSet.include({
|
||||
|
||||
init : function() {
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
/**
|
||||
* Creates Overriding
|
||||
* Create Overriding
|
||||
*
|
||||
* @param {Object} data field values to set on the new record
|
||||
* @param {Object} options Dictionary that can contain the following keys:
|
||||
@@ -77,13 +76,12 @@
|
||||
*/
|
||||
create : function(data, options) {
|
||||
var self = this;
|
||||
var context = instance.web.pyeval.eval('contexts',
|
||||
self.context.__eval_context);
|
||||
var context = pyeval.eval('contexts', self.context.get_eval_context());
|
||||
readonly_bypass.ignore_readonly(data, options, true, context);
|
||||
return self._super(data,options);
|
||||
},
|
||||
/**
|
||||
* Creates Overriding
|
||||
* Write Overriding
|
||||
*
|
||||
* @param {Object} data field values to set on the new record
|
||||
* @param {Object} options Dictionary that can contain the following keys:
|
||||
@@ -93,15 +91,14 @@
|
||||
*/
|
||||
write : function(id, data, options) {
|
||||
var self = this;
|
||||
var context = instance.web.pyeval.eval('contexts',
|
||||
self.context.__eval_context);
|
||||
var context = pyeval.eval('contexts', self.context.get_eval_context());
|
||||
readonly_bypass.ignore_readonly(data, options, false, context);
|
||||
return self._super(id,data,options);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
instance.web.DataSet.include({
|
||||
data.DataSet.include({
|
||||
/*
|
||||
BufferedDataSet: case of 'add an item' into a form view
|
||||
*/
|
||||
@@ -138,4 +135,7 @@
|
||||
},
|
||||
|
||||
});
|
||||
})();
|
||||
|
||||
return readonly_bypass;
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user