diff options
| author | Fabien Meghazi <fme@openerp.com> | 2011-12-08 17:10:14 +0100 |
|---|---|---|
| committer | Fabien Meghazi <fme@openerp.com> | 2011-12-08 17:10:14 +0100 |
| commit | 4ab671d3fc69ccf6e6a13f522dacde6fb703f7bf (patch) | |
| tree | 3ce23b58d21bf5eb370735058a4e47a5986ec2a1 /addons/web_dashboard/static/src | |
| parent | cf6fedf5bbb666ca1d9bb72f665cda1f2e2246ba (diff) | |
[ADD] Dashboard: support for @creatable attribute in dashboard's actions
bzr revid: fme@openerp.com-20111208161014-itkek0cct619i8fh
Diffstat (limited to 'addons/web_dashboard/static/src')
| -rw-r--r-- | addons/web_dashboard/static/src/js/dashboard.js | 20 | ||||
| -rw-r--r-- | addons/web_dashboard/static/src/xml/web_dashboard.xml | 1 |
2 files changed, 19 insertions, 2 deletions
diff --git a/addons/web_dashboard/static/src/js/dashboard.js b/addons/web_dashboard/static/src/js/dashboard.js index 07c9f83ef1f..49217cdb984 100644 --- a/addons/web_dashboard/static/src/js/dashboard.js +++ b/addons/web_dashboard/static/src/js/dashboard.js @@ -182,13 +182,29 @@ openerp.web.form.DashBoard = openerp.web.form.Widget.extend({ selectable: false } }; - var am = new openerp.web.ActionManager(this); + var am = new openerp.web.ActionManager(this), + // FIXME: ideally the dashboard view shall be refactored like kanban. + $action = $('#' + this.view.element_id + '_action_' + index); this.action_managers.push(am); - am.appendTo($('#' + this.view.element_id + '_action_' + index)); + am.appendTo($action); am.do_action(action); am.do_action = function(action) { self.do_action(action); } + if (action_attrs.creatable && action_attrs.creatable !== 'false') { + var form_id = parseInt(action_attrs.creatable, 10); + $action.parent().find('button.oe_dashboard_button_create').click(function() { + var create_action = _.extend({}, action_orig, { + views : [[(isNaN(form_id) ? false : form_id), 'form']] + }); + _.each(action.views, function(v) { + if (v[1] !== 'form') { + create_action.views.push(v); + } + }); + self.do_action(create_action); + }); + } if (am.inner_viewmanager) { am.inner_viewmanager.on_mode_switch.add(function(mode) { var new_views = []; diff --git a/addons/web_dashboard/static/src/xml/web_dashboard.xml b/addons/web_dashboard/static/src/xml/web_dashboard.xml index 038bccd606a..974ce9b393b 100644 --- a/addons/web_dashboard/static/src/xml/web_dashboard.xml +++ b/addons/web_dashboard/static/src/xml/web_dashboard.xml @@ -29,6 +29,7 @@ <span class='ui-icon ui-icon-minusthick oe-dashboard-fold' t-if="!action.attrs.fold"></span> <span class='ui-icon ui-icon-plusthick oe-dashboard-fold' t-if="action.attrs.fold"></span> </h2> + <button t-if="action.attrs.creatable and action.attrs.creatable !== 'false'" class="oe_dashboard_button_create">Create</button> <div t-attf-id="#{view.element_id}_action_#{column_index}_#{action_index}" class="oe-dashboard-action-content" t-att-style="action.attrs.fold ? 'display: none' : null"></div> </div> </t> |
