Example #1
0
    on_search: function (domains) {
        var result = pyeval.sync_eval_domains_and_contexts({
            domains: domains
        });

        this.domain = result.domain;
        this.fetch_and_render_thread();
    },
Example #2
0
 save_favorite: function () {
     var self = this,
         filter_name = this.$inputs[0].value,
         default_filter = this.$inputs[1].checked,
         shared_filter = this.$inputs[2].checked;
     if (!filter_name.length){
         this.do_warn(_t("Error"), _t("Filter name is required."));
         this.$inputs.first().focus();
         return;
     }
     if (_.chain(this.filters)
             .pluck('name')
             .contains(filter_name).value()) {
         this.do_warn(_t("Error"), _t("Filter with same name already exists."));
         this.$inputs.first().focus();
         return;
     }
     var search = this.searchview.build_search_data(),
         view_manager = this.findAncestor(function (a) {
             // HORRIBLE HACK. PLEASE SAVE ME FROM MYSELF (BUT IN A PAINLESS WAY IF POSSIBLE)
             return 'active_view' in a;
         }),
         view_context = view_manager ? view_manager.active_view.controller.get_context() : {},
         results = pyeval.sync_eval_domains_and_contexts({
             domains: search.domains,
             contexts: search.contexts.concat(view_context || []),
             group_by_seq: search.groupbys || [],
         });
     if (!_.isEmpty(results.group_by)) {
         results.context.group_by = results.group_by;
     }
     // Don't save user_context keys in the custom filter, otherwise end
     // up with e.g. wrong uid or lang stored *and used in subsequent
     // reqs*
     var ctx = results.context;
     _(_.keys(session.user_context)).each(function (key) {
         delete ctx[key];
     });
     var filter = {
         name: filter_name,
         user_id: shared_filter ? false : session.uid,
         model_id: this.target_model,
         context: results.context,
         domain: results.domain,
         sort: JSON.stringify(this.searchview.dataset._sort),
         is_default: default_filter,
         action_id: this.action_id,
     };
     return data_manager.create_filter(filter).done(function (id) {
         filter.id = id;
         self.toggle_save_menu(false);
         self.$save_name.find('input').val('').prop('checked', false);
         self.add_filter(filter);
         self.append_filter(filter);
         self.toggle_filter(filter, true);
     });
 },
Example #3
0
    open: function() {
        if(this.options.initial_view !== "search") {
            return this.create_edit_record();
        }

        this._super();
        this.init_dataset();
        var context = pyeval.sync_eval_domains_and_contexts({
            domains: [],
            contexts: [this.context]
        }).context;
        var search_defaults = {};
        _.each(context, function (value_, key) {
            var match = /^search_default_(.*)$/.exec(key);
            if (match) {
                search_defaults[match[1]] = value_;
            }
        });
        this.setup(search_defaults);
        return this;
    },
Example #4
0
 get_domain: function (selected_ids) {
     var group_domain = [], domain;
     if (this.$('.o_list_record_selector input').prop('checked')) {
         if (this.view_list.grouped) {
             var group_domain = _.chain(_.values(this.view_list.groups.children))
                                     .filter(function (child) { return child.records.length; })
                                     .map(function (c) { return c.datagroup.domain;})
                                     .value();
             group_domain = _.flatten(group_domain, true);
             group_domain = _.times(group_domain.length - 1, _.constant('|')).concat(group_domain);
         }
         var search_data = this.searchview.build_search_data();
         domain = pyeval.sync_eval_domains_and_contexts({
             domains: search_data.domains,
             contexts: search_data.contexts,
             group_by_seq: search_data.groupbys || []
         }).domain;
     }
     else {
         domain = [["id", "in", selected_ids]];
     }
     return this.dataset.domain.concat(group_domain).concat(domain || []);
 },