Exemple #1
0
 var handler = function (action) {
     if (action && action.constructor === Object) {
         // filter out context keys that are specific to the current action.
         // Wrong default_* and search_default_* values will no give the expected result
         // Wrong group_by values will simply fail and forbid rendering of the destination view
         var ncontext = new data.CompoundContext(
             _.object(_.reject(_.pairs(dataset.get_context().eval()), function(pair) {
               return pair[0].match('^(?:(?:default_|search_default_|show_).+|.+_view_ref|group_by|group_by_no_leaf|active_id|active_ids)$') !== null;
             }))
         );
         ncontext.add(action_data.context || {});
         ncontext.add({active_model: dataset.model});
         if (record_id) {
             ncontext.add({
                 active_id: record_id,
                 active_ids: [record_id],
             });
         }
         ncontext.add(action.context || {});
         action.context = ncontext;
         return self.do_action(action, {
             on_close: result_handler,
         });
     } else {
         self.do_action({"type":"ir.actions.act_window_close"});
         return result_handler();
     }
 };
Exemple #2
0
    add_dashboard: function () {
        var self = this;

        var search_data = this.searchview.build_search_data(),
            context = new data.CompoundContext(this.searchview.dataset.get_context() || []),
            domain = new data.CompoundDomain(this.searchview.dataset.get_domain() || []);
        _.each(search_data.contexts, context.add, context);
        _.each(search_data.domains, domain.add, domain);

        context.add({
            group_by: pyeval.eval('groupbys', search_data.groupbys || [])
        });
        context.add(this.view_manager.active_view.controller.get_context());
        var c = pyeval.eval('context', context);
        for(var k in c) {
            if (c.hasOwnProperty(k) && /^search_default_/.test(k)) {
                delete c[k];
            }
        }
        this.toggle_dashboard_menu(false);
        c.dashboard_merge_domains_contexts = false;
        var d = pyeval.eval('domain', domain),
            board = new Model('board.board'),
            name = self.$add_dashboard_input.val();
        
        board.call('list', [board.context()])
            .then(function (board_list) {
                return self.rpc('/board/add_to_dashboard', {
                    menu_id: board_list[0].id,                    
                    action_id: self.action_id,
                    context_to_save: c,
                    domain: d,
                    view_mode: self.view_manager.active_view.type,
                    name: name,
                });
            }).then(function (r) {
                if (r) {
                    self.do_notify(_.str.sprintf(_t("'%s' added to dashboard"), name), '');
                } else {
                    self.do_warn(_t("Could not add filter to dashboard"));
                }
            });
    },