view_mode = action_attrs.view_mode;
if (action_attrs.context) {
- action.context = action_attrs.context;
+ action.context = _.extend((action.context || {}), action_attrs.context);
}
if (action_attrs.domain) {
- action.domain = action_attrs.domain;
+ action.domain = action.domain || [];
+ action.domain.unshift.apply(action.domain, action_attrs.domain);
}
- var action_orig = _.extend({}, action);
+ var action_orig = _.extend({ flags : {} }, action);
if (view_mode && view_mode != action.view_mode) {
var action_view_mode = action.view_mode.split(',');
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 action_id = parseInt(action_attrs.creatable, 10);
+ $action.parent().find('button.oe_dashboard_button_create').click(function() {
+ if (isNaN(action_id)) {
+ action_orig.flags.default_view = 'form';
+ self.do_action(action_orig);
+ } else {
+ self.rpc('/web/action/load', {
+ action_id: action_id
+ }, function(result) {
+ result.result.flags = result.result.flags || {};
+ result.result.flags.default_view = 'form';
+ self.do_action(result.result);
+ });
+ }
+ });
+ }
if (am.inner_viewmanager) {
am.inner_viewmanager.on_mode_switch.add(function(mode) {
var new_views = [];
template: 'ConfigOverview',
init: function (parent) {
this._super(parent);
- this.dataset = new openerp.web.DataSetSearch(
- this, 'ir.actions.todo');
- this.dataset.domain = [['type', '!=', 'automatic']];
+ this.user = _.extend(new openerp.web.DataSet(this, 'res.users'), {
+ index: 0,
+ ids: [this.session.uid]
+ });
+ this.dataset = new openerp.web.DataSetSearch(this, 'ir.actions.todo');
},
start: function () {
this._super();
- $.when(this.dataset.read_slice(['state', 'action_id', 'category_id']),
- this.dataset.call('progress'))
- .then(this.on_records_loaded);
- },
- on_records_loaded: function (read_response, progress_response) {
- var records = read_response,
- progress = progress_response[0];
+ var self = this;
+ return this.user.read_index(['groups_id']).pipe(function (record) {
+ var todos_filter = [
+ ['type', '!=', 'automatic'],
+ '|', ['groups_id', '=', false],
+ ['groups_id', 'in', record['groups_id']]];
+ return $.when(
+ self.dataset.read_slice(['state', 'action_id', 'category_id'],{
+ domain: todos_filter }),
+ self.dataset.call('progress').pipe(
+ function (arg) { return arg; }, null))
+ }, null).then(this.on_records_loaded);
+ },
+ on_records_loaded: function (records, progress) {
var grouped_todos = _(records).chain()
.map(function (record) {
return {
},
start: function() {
var self = this;
- var domain = [['is_application','=',true], ['state','=','installed'], ['name', '!=', 'base']];
+ openerp.webclient.menu.do_hide_secondary();
+ var domain = [['application','=',true], ['state','=','installed'], ['name', '!=', 'base']];
var ds = new openerp.web.DataSetSearch(this, 'ir.module.module',{},domain);
ds.read_slice(['id'], {}, function(result) {
if(result.length) {
openerp.web_dashboard.ApplicationInstaller = openerp.web.Widget.extend({
template: 'web_dashboard.ApplicationInstaller',
start: function () {
+ // TODO menu hide
var r = this._super();
- //$('.secondary_menu', this.$element.closest('.openerp')).hide();
this.action_manager = new openerp.web.ActionManager(this);
this.action_manager.appendTo(this.$element.find('.oe_installer'));
this.action_manager.do_action({
type: 'ir.actions.act_window',
res_model: 'ir.module.module',
+ domain: [['application','=',true]],
views: [[false, 'kanban']],
flags: {
display_title:false,
action_buttons: false,
sidebar: false,
pager: false
- },
+ }
});
return r;
},
stop: function() {
this.action_manager.stop();
return this._super();
- },
+ }
});