This question has been flagged
5 Replies
4361 Views

Hi!

I'm trying to replace period and journal default filter from journal entries ( Menu Account/Journal entries/Journal items) by blank.

These default filters are defined in addons/account/static/src/js/account_move_line_quickadd.js

45:            defs.push(mod.call("default_get", [['journal_id','period_id'],self.dataset.context]).then(function(result) {
46: self.current_period = result['period_id'];
47: self.current_journal = result['journal_id'];
48: }));

I'm not already comfortable with javascript. But, if I remove line 46 and 47, it works fine.

Now, I want to do that without modify account module. So I tried to make a module and I read this doc page: https://doc.odoo.com/trunk/training/web_framework/

Here is my code:

openerp.mymodule.quickadd = function (instance) {
instance.mymodule.quickadd = instance.web.account.QuickAddListView.extend({
start:function(){
var tmp = this._super.apply(this, arguments);
var self = this;
var defs = [];
this.$el.parent().prepend(QWeb.render("AccountMoveLineQuickAdd", {widget: this}));

this.$el.parent().find('.oe_account_select_journal').change(function() {
self.current_journal = this.value === '' ? null : parseInt(this.value);
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.$el.parent().find('.oe_account_select_period').change(function() {
self.current_period = this.value === '' ? null : parseInt(this.value);
self.do_search(self.last_domain, self.last_context, self.last_group_by);
});
this.on('edit:after', this, function () {
self.$el.parent().find('.oe_account_select_journal').attr('disabled', 'disabled');
self.$el.parent().find('.oe_account_select_period').attr('disabled', 'disabled');
});
this.on('save:after cancel:after', this, function () {
self.$el.parent().find('.oe_account_select_journal').removeAttr('disabled');
self.$el.parent().find('.oe_account_select_period').removeAttr('disabled');
});
var mod = new instance.web.Model("account.move.line", self.dataset.context, self.dataset.domain);
defs.push(mod.call("default_get", [['journal_id','period_id'],self.dataset.context]).then(function(result) {
}));
defs.push(mod.call("list_journals", []).then(function(result) {
self.journals = result;
}));
defs.push(mod.call("list_periods", []).then(function(result) {
self.periods = result;
}));
return $.when(tmp, defs);
},
});
};

But, that doesn't work.

Is someone can help me please?


Avatar
Discard

You mean you totally want to remove both selection from there? you want all the journal items to be display?

Author

Just want no period and no journal pre-selected. Thanks for your answer …

Best Answer

Have you seen that a module has already been created to address this?

https://www.odoo.com/apps/modules/8.0/account_move_line_no_default_search/

OpenERP 7.0 implements a custom javascript search view for move lines. This search view shows dropdowns for period and journal. By default, these are set to the default journal and (current) period.

This module leaves the search view extension for move lines intact, but disables the default search values for the dropdowns so that you do not have to disable these before entering your own search queries.

Avatar
Discard
Author

Great. This is that I wanted to do. It's a regrettable that no one has showned me that before. Thanks.

Author Best Answer

I've made a module to override javascript file

static/src/js/account_move_line_quickadd.js of account module to remove selectable fields (period and journal).

The module is here:

http://git.heureux-cyclage.org/?p=burette/account_move_line_nofilters.git;a=summary


Avatar
Discard
Author

OK. I've just made this module: http://git.heureux-cyclage.org/?p=burette/account_move_line_nofilters.git;a=summary But, when I go to Account/Journal entries/Journal items , no records appear. I have to select a period and a journal to begin to see them. I would all record to be listed by default when we click to this menu. Can someone help me please?