diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2011-10-10 11:44:38 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2011-10-10 11:44:38 +0200 |
| commit | 5e417f203aa36255eaf7836fb4b4dbb5ec7f813b (patch) | |
| tree | 97740074c4eb0afe2f84b0ad9b746796e5fe842d /addons/web/static/src/js/data.js | |
| parent | 0f7c7cc33f4cbd689bfe7b2f339ac0d828e9b582 (diff) | |
[imp] improved popup for m2o to support usage of buttons while creating a row
bzr revid: nicolas.vanhoren@openerp.com-20111010094438-33drycp4l7o1vnzt
Diffstat (limited to 'addons/web/static/src/js/data.js')
| -rw-r--r-- | addons/web/static/src/js/data.js | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index fcf6a65dcf5..dc0e21cf796 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -721,26 +721,42 @@ openerp.web.BufferedDataSet = openerp.web.DataSetStatic.extend({ openerp.web.BufferedDataSet.virtual_id_regex = /^one2many_v_id_.*$/; openerp.web.ReadOnlyDataSetSearch = openerp.web.DataSetSearch.extend({ + init: function() { + this._super.apply(this, arguments); + this.create_function = null; + this.write_function = null; + }, default_get: function(fields, callback) { return this._super(fields, callback).then(this.on_default_get); }, on_default_get: function(result) {}, create: function(data, callback, error_callback) { this.on_create(data); - var to_return = $.Deferred().then(callback); - setTimeout(function () {to_return.resolve({"result": undefined});}, 0); - return to_return.promise(); + if (this.create_function) { + return this.create_function(data, callback, error_callback); + } else { + console.warn("trying to create a record using read only dataset"); + var to_return = $.Deferred().then(callback); + setTimeout(function () {to_return.resolve({"result": undefined});}, 0); + return to_return.promise(); + } }, on_create: function(data) {}, write: function (id, data, options, callback) { this.on_write(id, data); - var to_return = $.Deferred().then(callback); - setTimeout(function () {to_return.resolve({"result": true});}, 0); - return to_return.promise(); + if (this.write_function) { + return this.write_function(id, data, options, callback); + } else { + console.warn("trying to write a record using read only dataset"); + var to_return = $.Deferred().then(callback); + setTimeout(function () {to_return.resolve({"result": true});}, 0); + return to_return.promise(); + } }, on_write: function(id, data) {}, unlink: function(ids, callback, error_callback) { this.on_unlink(ids); + console.warn("trying to unlink a record using read only dataset"); var to_return = $.Deferred().then(callback); setTimeout(function () {to_return.resolve({"result": true});}, 0); return to_return.promise(); |
