From 259892f837588c7b47c81cfe513d245e4526226f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 25 Aug 2011 12:33:36 +0200 Subject: [PATCH 1/6] [FIX] selector for config overview widget: widget root has moved, .oe-dashboard-config-overview is now on this. so don't include it bzr revid: xmo@openerp.com-20110825103336-nwyybou1hghaudud --- addons/base_dashboard/static/src/js/dashboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/base_dashboard/static/src/js/dashboard.js b/addons/base_dashboard/static/src/js/dashboard.js index 8cf94a43362..e5b06a13461 100644 --- a/addons/base_dashboard/static/src/js/dashboard.js +++ b/addons/base_dashboard/static/src/js/dashboard.js @@ -321,7 +321,7 @@ openerp.base_dashboard.ConfigOverview = openerp.base.View.extend({ $progress.progressbar({value: $progress.data('completion')}); var self = this; - this.$element.find('div.oe-dashboard-config-overview ul') + this.$element.find('dl') .delegate('input', 'click', function (e) { // switch todo status e.stopImmediatePropagation(); From b5a429d008536f6410e82b24ee12ec481b6d6397 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 25 Aug 2011 14:30:49 +0200 Subject: [PATCH 2/6] [FIX] fnct_inv in client actions params, fix docstring for fnct_inv (fnct_inv only takes a single record id, not a sequence of ids) bzr revid: xmo@openerp.com-20110825123049-bmvebm86gqgr6w43 --- openerp/addons/base/ir/ir_actions.py | 5 ++--- openerp/osv/fields.py | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openerp/addons/base/ir/ir_actions.py b/openerp/addons/base/ir/ir_actions.py index 0b60d389287..67c36b277dd 100644 --- a/openerp/addons/base/ir/ir_actions.py +++ b/openerp/addons/base/ir/ir_actions.py @@ -936,10 +936,9 @@ class act_client(osv.osv): for record in self.browse(cr, uid, ids, context=context) ]) - def _set_params(self, cr, uid, ids, field_name, field_value, arg, context): + def _set_params(self, cr, uid, id, field_name, field_value, arg, context): assert isinstance(field_value, dict), "params can only be dictionaries" - for record in self.browse(cr, uid, ids, context=context): - record.write({field_name: repr(field_value)}) + self.write(cr, uid, id, {'params_store': repr(field_value)}, context=context) _columns = { 'tag': fields.char('Client action tag', size=64, required=True, diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index 782cc8e796a..fb973d2e521 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -852,12 +852,13 @@ class function(_column): This callable implements the write operation for the function field and must have the following signature: - .. function:: fnct_inv(model, cr, uid, ids, field_name, field_value, fnct_inv_arg, context) + .. function:: fnct_inv(model, cr, uid, id, field_name, field_value, fnct_inv_arg, context) Callable that implements the ``write`` operation for the function field. :param orm_template model: model to which the field belongs (should be ``self`` for a model method) + :param int id: the identifier of the object to write on :param str field_name: name of the field to set :param fnct_inv_arg: arbitrary value passed when declaring the function field :return: True From b8cd28fb355de91b9ec736be4f42d77afef0a137 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 25 Aug 2011 14:34:45 +0200 Subject: [PATCH 3/6] [FIX] widgets client action handler: one action per widget bzr revid: xmo@openerp.com-20110825123445-ayhaeipasl4imvqt --- .../base_dashboard/static/src/js/dashboard.js | 61 +++++++++---------- .../static/src/xml/base_dashboard.xml | 9 ++- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/addons/base_dashboard/static/src/js/dashboard.js b/addons/base_dashboard/static/src/js/dashboard.js index e5b06a13461..3f9da51b157 100644 --- a/addons/base_dashboard/static/src/js/dashboard.js +++ b/addons/base_dashboard/static/src/js/dashboard.js @@ -372,39 +372,36 @@ openerp.base_dashboard.ApplicationTiles = openerp.base.View.extend({ } }); openerp.base.client_actions.add( - 'board.home.widgets', 'openerp.base_dashboard.Widgets'); -openerp.base_dashboard.Widgets = openerp.base.View.extend({ - template: 'HomeWidgets', - start: function () { - return new openerp.base.DataSetSearch( - this, 'res.widget.user', null, - ['|', ['user_id', '=', false], - ['user_id', '=', parseInt(this.session.uid, 10)]]) - .read_slice(['widget_id', 'user_id'], {}, this.on_widgets_list_loaded); + 'board.home.widgets', 'openerp.base_dashboard.Widget'); +openerp.base_dashboard.Widget = openerp.base.View.extend(/** @lends openerp.base_dashboard.Widgets# */{ + template: 'HomeWidget', + /** + * Initializes a "HomeWidget" client widget: handles the display of a given + * res.widget objects in an OpenERP view (mainly a dashboard). + * + * @constructs + * @extends openerp.base.View + * @param {Object} parent + * @param {Object} options + * @param {Number} options.widget_id + */ + init: function (parent, options) { + this._super(parent); + this.widget_id = options.widget_id; }, - on_widgets_list_loaded: function (user_widgets) { - var self = this; - var widget_user = {}; - _(user_widgets).each(function (widget) { - widget['widget_id'] = widget['widget_id'][0]; - widget_user[widget['widget_id']] = { - removable: widget['user_id'] !== false, - user_widget_id: widget['id'] - }; - }); - new openerp.base.DataSetSearch(this, 'res.widget') - .read_ids(_(user_widgets).pluck('widget_id'), ['title'], function (widgets) { - _(widgets).each(function (widget) { - _.extend(widget, widget_user[widget['id']]); - }); - var url = _.sprintf( - '/base_dashboard/widgets/content?session_id=%s&widget_id=', - self.session.session_id); - self.$element.html(QWeb.render('HomeWidgets', { - widgets: widgets, - url: url - })); - }); + start: function () { + return new openerp.base.DataSet(this, 'res.widget').read_ids( + [this.widget_id], ['title'], this.on_widget_loaded); + }, + on_widget_loaded: function (widgets) { + var widget = widgets[0]; + var url = _.sprintf( + '/base_dashboard/widgets/content?session_id=%s&widget_id=%d', + this.session.session_id, widget.id); + this.$element.html(QWeb.render('HomeWidget.content', { + widget: widget, + url: url + })); } }); }; diff --git a/addons/base_dashboard/static/src/xml/base_dashboard.xml b/addons/base_dashboard/static/src/xml/base_dashboard.xml index 51657dfd068..b60e466964b 100644 --- a/addons/base_dashboard/static/src/xml/base_dashboard.xml +++ b/addons/base_dashboard/static/src/xml/base_dashboard.xml @@ -107,10 +107,9 @@ -
-
+
+

-