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();
     }
 };
 do_action_object: function ($action) {
     var button_attrs = $action.data();
     var node_context = button_attrs.context || {};
     var context = new data.CompoundContext(node_context);
     context.set_eval_context({
         active_id: this.id,
         active_ids: [this.id],
         active_model: this.view.dataset.model
     });
     var action_data = _.extend({}, button_attrs, {context: context});
     this.view.do_execute_action(action_data, this.view.dataset, this.id, this.do_reload);
 },
Exemple #3
0
 open_action: function (event) {
     var self = this;
     var node_context = event.data.context || {};
     var context = new data.CompoundContext(node_context);
     context.set_eval_context({
         active_id: event.target.id,
         active_ids: [event.target.id],
         active_model: this.model,
     });
     this.do_execute_action(event.data, this.dataset, event.target.id).then(function () {
         self.reload_record(event.target);
     });
 },
Exemple #4
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"));
                }
            });
    },