From 558ad0616a4fef54ec290ef1967ab0d0ac083260 Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Wed, 3 Oct 2012 16:04:28 +0530 Subject: [PATCH 1/5] [IMP]remove callbacks from call method and improve related code. bzr revid: vme@tinyerp.com-20121003103428-fnr942tzl065rcei --- addons/web/static/src/js/data.js | 4 ++-- addons/web/static/test/fulltest/dataset.js | 4 ++-- addons/web_view_editor/static/src/js/view_editor.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 2b82e618203..cf4b29ab56b 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -586,8 +586,8 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ * @param {Function} error_callback * @returns {$.Deferred} */ - call: function (method, args, callback, error_callback) { - return this._model.call(method, args).then(callback, error_callback); + call: function (method, args) { + return this._model.call(method, args); }, /** * Calls an arbitrary method, with more crazy diff --git a/addons/web/static/test/fulltest/dataset.js b/addons/web/static/test/fulltest/dataset.js index d276f4e2494..f7e64fba53e 100644 --- a/addons/web/static/test/fulltest/dataset.js +++ b/addons/web/static/test/fulltest/dataset.js @@ -82,14 +82,14 @@ $(document).ready(function () { }); t.test('call', function (openerp) { var ds = new openerp.web.DataSet({session: openerp.session}, 'mod'); - t.expect(ds.call('frob', ['a', 'b', 42]), function (r) { + t.expect(ds.call('frob', ['a', 'b', 42]).then(function (r) { strictEqual(r.method, 'frob'); strictEqual(r.args.length, 3); deepEqual(r.args, ['a', 'b', 42]); ok(_.isEmpty(r.kwargs)); - }); + })); }); t.test('name_get').then(function (openerp) { var ds = new openerp.web.DataSet({session: openerp.session}, 'mod'); diff --git a/addons/web_view_editor/static/src/js/view_editor.js b/addons/web_view_editor/static/src/js/view_editor.js index 73d07efd5c0..e65f0ab5d38 100644 --- a/addons/web_view_editor/static/src/js/view_editor.js +++ b/addons/web_view_editor/static/src/js/view_editor.js @@ -136,7 +136,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({ var field_dataset = new instance.web.DataSetSearch(this, this.model, null, null); var model_dataset = new instance.web.DataSetSearch(this, 'ir.model', null, null); var view_string = "", field_name = false, self = this; - field_dataset.call( 'fields_get', [], function(fields) { + field_dataset.call( 'fields_get', []).then(function(fields) { _.each(['name', 'x_name'], function(value) { if (_.include(_.keys(fields), value)) { field_name = value; @@ -539,7 +539,7 @@ instance.web_view_editor.ViewEditor = instance.web.Widget.extend({ var value = _.has(_CHILDREN, element) ? element : _.str.include(html_tag, element)?"html_tag":false; property_to_check.push(value); }); - field_dataset.call( 'fields_get', [], function(result) { + field_dataset.call( 'fields_get', []).then(function(result) { var fields = _.keys(result); fields.push(" "),fields.sort(); self.on_add_node(property_to_check, fields); From 30069a02398c4f9de698c6fcc43bc4958aa1d960 Mon Sep 17 00:00:00 2001 From: ggh-openerp Date: Wed, 3 Oct 2012 17:58:36 +0530 Subject: [PATCH 2/5] [IMP]In rpc method remove callback and modify relate code bzr revid: ggh@tinyerp.com-20121003122836-36g8ijxdcjwgntjl --- addons/web/static/src/js/chrome.js | 10 +++++----- addons/web/static/src/js/corelib.js | 6 +++--- addons/web/static/src/js/coresetup.js | 4 ++-- addons/web/static/src/js/data_export.js | 8 ++++---- addons/web/static/src/js/search.js | 2 +- addons/web/static/src/js/view_form.js | 4 ++-- addons/web/static/src/js/view_list.js | 2 +- addons/web/static/src/js/view_tree.js | 2 +- addons/web/static/src/js/views.js | 6 +++--- addons/web_calendar/static/src/js/calendar.js | 2 +- addons/web_diagram/static/src/js/diagram.js | 3 +-- 11 files changed, 24 insertions(+), 25 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index bed4a159535..985912d57bf 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -392,7 +392,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({ do_create: function(form) { var self = this; var fields = $(form).serializeArray(); - self.rpc("/web/database/create", {'fields': fields}, function(result) { + self.rpc("/web/database/create", {'fields': fields}).then(function(result) { var form_obj = self.to_object(fields); var client_action = { type: 'ir.actions.client', @@ -418,7 +418,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({ if (!db || !confirm("Do you really want to delete the database: " + db + " ?")) { return; } - self.rpc("/web/database/drop", {'fields': fields}, function(result) { + self.rpc("/web/database/drop", {'fields': fields}).then(function(result) { if (result.error) { self.display_error(result); return; @@ -481,7 +481,7 @@ instance.web.DatabaseManager = instance.web.Widget.extend({ var self = this; self.rpc("/web/database/change_password", { 'fields': $(form).serializeArray() - }, function(result) { + }).then(function(result) { if (result.error) { self.display_error(result); return; @@ -660,7 +660,7 @@ instance.web.ChangePassword = instance.web.Widget.extend({ submitHandler: function (form) { self.rpc("/web/session/change_password",{ 'fields': $(form).serializeArray() - }, function(result) { + }).then(function(result) { if (result.error) { self.display_error(result); return; @@ -1165,7 +1165,7 @@ instance.web.EmbeddedClient = instance.web.Client.extend({ var self = this; return $.when(this._super()).pipe(function() { return instance.session.session_authenticate(self.dbname, self.login, self.key, true).pipe(function() { - return self.rpc("/web/action/load", { action_id: self.action_id }, function(result) { + return self.rpc("/web/action/load", { action_id: self.action_id }).then(function(result) { var action = result.result; action.flags = _.extend({ //views_switcher : false, diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index 62ac48f0c61..d6dfac963e0 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -841,7 +841,7 @@ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, { rpc: function(url, data, success, error) { var def = $.Deferred().then(success, error); var self = this; - instance.session.rpc(url, data). then(function() { + instance.session.rpc(url, data).then(function() { if (!self.isDestroyed()) def.resolve.apply(def, arguments); }, function() { @@ -1299,7 +1299,7 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({ * @param {Function} error_callback function to execute on RPC call failure * @returns {jQuery.Deferred} jquery-provided ajax deferred */ - rpc: function(url, params, success_callback, error_callback) { + rpc: function(url, params) { var self = this; // url can be an $.ajax option object if (_.isString(url)) { @@ -1358,7 +1358,7 @@ instance.web.JsonRPC = instance.web.CallbackEnabled.extend({ self.on_rpc_error(error, event); } }); - }).then(success_callback, error_callback).promise(); + }); return deferred; }, /** diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index ea160d6faee..7134c068ec3 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -19,9 +19,9 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess this.name = instance._session_id; this.qweb_mutex = new $.Mutex(); }, - rpc: function(url, params, success_callback, error_callback) { + rpc: function(url, params) { params.session_id = this.session_id; - return this._super(url, params, success_callback, error_callback); + return this._super(url, params); }, /** * Setup a sessionm diff --git a/addons/web/static/src/js/data_export.js b/addons/web/static/src/js/data_export.js index 29aea6362f7..a06e9ccb155 100644 --- a/addons/web/static/src/js/data_export.js +++ b/addons/web/static/src/js/data_export.js @@ -49,7 +49,7 @@ instance.web.DataExport = instance.web.Dialog.extend({ self.rpc("/web/export/get_fields", { model: self.dataset.model, import_compat: Boolean(import_comp) - }, function (records) { + }).then(function (records) { got_fields.resolve(); self.on_show_data(records); }); @@ -57,7 +57,7 @@ instance.web.DataExport = instance.web.Dialog.extend({ return $.when( got_fields, - this.rpc('/web/export/formats', {}, this.do_setup_export_formats), + this.rpc('/web/export/formats', {}).then(this.do_setup_export_formats), this.show_exports_list()); }, do_setup_export_formats: function (formats) { @@ -91,7 +91,7 @@ instance.web.DataExport = instance.web.Dialog.extend({ self.$el.find('#fields_list option').remove(); var export_id = self.$el.find('#saved_export_list option:selected').val(); if (export_id) { - self.rpc('/web/export/namelist', {'model': self.dataset.model, export_id: parseInt(export_id)}, self.do_load_export_field); + self.rpc('/web/export/namelist', {'model': self.dataset.model, export_id: parseInt(export_id)}).then(self.do_load_export_field); } }); self.$el.find('#delete_export_list').click(function() { @@ -181,7 +181,7 @@ instance.web.DataExport = instance.web.Dialog.extend({ import_compat: Boolean(import_comp), parent_field_type : record['field_type'], exclude: exclude_fields - }, function(results) { + }).then(function(results) { record.loaded = true; self.on_show_data(results, record.id); }); diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 01bc0c76c87..63d6574dd82 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -1693,7 +1693,7 @@ instance.web.search.Advanced = instance.web.search.Input.extend({ }); return $.when( this._super(), - this.rpc("/web/searchview/fields_get", {model: this.view.model}, function(data) { + this.rpc("/web/searchview/fields_get", {model: this.view.model}).then(function(data) { self.fields = _.extend({ id: { string: 'ID', type: 'id' } }, data.fields); diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index bf6b869482b..af11ce27bda 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4417,7 +4417,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend self.rpc('/web/session/eval_domain_and_context', { domains: [], contexts: [this.context] - }, function (results) { + }).then(function (results) { var search_defaults = {}; _.each(results.context, function (value_, key) { var match = /^search_default_(.*)$/.exec(key); @@ -4485,7 +4485,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend domains: domains || [], contexts: contexts || [], group_by_seq: groupbys || [] - }, function (results) { + }).then(function (results) { self.view_list.do_search(results.domain, results.context, results.group_by); }); }, diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index fd34ffddb7b..7457ca5ef67 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -482,7 +482,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi view_type: "tree", context: this.dataset.get_context(context), toolbar: !!this.options.$sidebar - }, callback); + }).then(callback); } }, /** diff --git a/addons/web/static/src/js/view_tree.js b/addons/web/static/src/js/view_tree.js index e0493a446e2..05760420ba8 100644 --- a/addons/web/static/src/js/view_tree.js +++ b/addons/web/static/src/js/view_tree.js @@ -45,7 +45,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie view_type: "tree", toolbar: this.view_manager ? !!this.view_manager.sidebar : false, context: this.dataset.get_context() - }, this.on_loaded); + }).then(this.on_loaded); }, /** * Returns the list of fields needed to correctly read objects. diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 2fff0e7b683..c80b111fdc8 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -648,7 +648,7 @@ instance.web.ViewManager = instance.web.Widget.extend({ domains: [this.action.domain || []].concat(domains || []), contexts: [action_context].concat(contexts || []), group_by_seq: groupbys || [] - }, function (results) { + }).then(function (results) { self.dataset._model = new instance.web.Model( self.dataset.model, results.context, results.domain); var groupby = results.group_by.length @@ -1054,7 +1054,7 @@ instance.web.Sidebar = instance.web.Widget.extend({ self.rpc("/web/action/load", { action_id: item.action.id, context: additional_context - }, function(result) { + }).then(function(result) { result.result.context = _.extend(result.result.context || {}, additional_context); result.result.flags = result.result.flags || {}; @@ -1233,7 +1233,7 @@ instance.web.View = instance.web.Widget.extend({ args.push(context); return dataset.call_button(action_data.name, args).then(handler); } else if (action_data.type=="action") { - return this.rpc('/web/action/load', { action_id: action_data.name, context: context, do_not_eval: true}, handler); + return this.rpc('/web/action/load', { action_id: action_data.name, context: context, do_not_eval: true}).then(handler); } else { return dataset.exec_workflow(record_id, action_data.name).then(handler); } diff --git a/addons/web_calendar/static/src/js/calendar.js b/addons/web_calendar/static/src/js/calendar.js index 644a35f7fad..81533413312 100644 --- a/addons/web_calendar/static/src/js/calendar.js +++ b/addons/web_calendar/static/src/js/calendar.js @@ -41,7 +41,7 @@ instance.web_calendar.CalendarView = instance.web.View.extend({ }, start: function() { this._super(); - return this.rpc("/web/view/load", {"model": this.model, "view_id": this.view_id, "view_type":"calendar", 'toolbar': false}, this.on_loaded); + return this.rpc("/web/view/load", {"model": this.model, "view_id": this.view_id, "view_type":"calendar", 'toolbar': false}).then(this.on_loaded); }, destroy: function() { scheduler.clearAll(); diff --git a/addons/web_diagram/static/src/js/diagram.js b/addons/web_diagram/static/src/js/diagram.js index 543cc6a9c12..508aeb30563 100644 --- a/addons/web_diagram/static/src/js/diagram.js +++ b/addons/web_diagram/static/src/js/diagram.js @@ -105,8 +105,7 @@ instance.web.DiagramView = instance.web.View.extend({ }); this.rpc( - '/web_diagram/diagram/get_diagram_info',params, - function(result) { + '/web_diagram/diagram/get_diagram_info',params).then(function(result) { self.draw_diagram(result); } ); From 46c83756dad86dfea2391bd33e5c5c4d09fac800 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Fri, 5 Oct 2012 16:36:06 +0200 Subject: [PATCH 3/5] [FIX] analytic: fix crash when trying to set currency_id to False in an analytic account bzr revid: qdp-launchpad@openerp.com-20121005143606-1evrpd8g3drg0v8m --- addons/analytic/analytic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index d71b480f799..1ce483a26cd 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -125,7 +125,8 @@ class account_analytic_account(osv.osv): if account.company_id: if account.company_id.currency_id.id != value: raise osv.except_osv(_('Error!'), _("If you set a company, the currency selected has to be the same as it's currency. \nYou can remove the company belonging, and thus change the currency, only on analytic account of type 'view'. This can be really usefull for consolidation purposes of several companies charts with different currencies, for example.")) - return cr.execute("""update account_analytic_account set currency_id=%s where id=%s""", (value, account.id, )) + if value: + return cr.execute("""update account_analytic_account set currency_id=%s where id=%s""", (value, account.id, )) def _currency(self, cr, uid, ids, field_name, arg, context=None): result = {} From 5e31fdf8a2684d2c645f57ce8f8baa8e79bba85b Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Mon, 8 Oct 2012 09:32:09 +0200 Subject: [PATCH 4/5] [IMP] wizard messages bzr revid: fp@tinyerp.com-20121008073209-53rvs8dp5o3vxmb8 --- addons/account/wizard/account_invoice_state_view.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/account/wizard/account_invoice_state_view.xml b/addons/account/wizard/account_invoice_state_view.xml index 11703a4f259..eb636f61b50 100644 --- a/addons/account/wizard/account_invoice_state_view.xml +++ b/addons/account/wizard/account_invoice_state_view.xml @@ -6,7 +6,12 @@ account.invoice.confirm
- +

+ Once draft invoices are confirmed, you will not be able + to modify them. The invoices will receive a unique + number and journal items will be created in your chart + of accounts. +