[FIX] account: move_line_quick_add js, set the domain in the dataset (for instance, for export tool) + performance improvement (no need to re-compute journal list and period list each time a search is done)
bzr revid: dle@openerp.com-20140213180459-mln0btlduc1fox0x
This commit is contained in:
parent
07c2c5ddd8
commit
856c60d181
|
@ -22,6 +22,7 @@ openerp.account.quickadd = function (instance) {
|
|||
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() {
|
||||
|
@ -41,11 +42,17 @@ openerp.account.quickadd = function (instance) {
|
|||
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);
|
||||
mod.call("default_get", [['journal_id','period_id'],self.dataset.context]).then(function(result) {
|
||||
defs.push(mod.call("default_get", [['journal_id','period_id'],self.dataset.context]).then(function(result) {
|
||||
self.current_period = result['period_id'];
|
||||
self.current_journal = result['journal_id'];
|
||||
});
|
||||
return tmp;
|
||||
}));
|
||||
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);
|
||||
},
|
||||
do_search: function(domain, context, group_by) {
|
||||
var self = this;
|
||||
|
@ -53,34 +60,27 @@ openerp.account.quickadd = function (instance) {
|
|||
this.last_context = context;
|
||||
this.last_group_by = group_by;
|
||||
this.old_search = _.bind(this._super, this);
|
||||
var mod = new instance.web.Model("account.move.line", context, domain);
|
||||
return $.when(mod.call("list_journals", []).then(function(result) {
|
||||
self.journals = result;
|
||||
}),mod.call("list_periods", []).then(function(result) {
|
||||
self.periods = result;
|
||||
})).then(function () {
|
||||
var o;
|
||||
self.$el.parent().find('.oe_account_select_journal').children().remove().end();
|
||||
self.$el.parent().find('.oe_account_select_journal').append(new Option('', ''));
|
||||
for (var i = 0;i < self.journals.length;i++){
|
||||
o = new Option(self.journals[i][1], self.journals[i][0]);
|
||||
if (self.journals[i][0] === self.current_journal){
|
||||
self.current_journal_type = self.journals[i][2];
|
||||
self.current_journal_currency = self.journals[i][3];
|
||||
self.current_journal_analytic = self.journals[i][4];
|
||||
$(o).attr('selected',true);
|
||||
}
|
||||
self.$el.parent().find('.oe_account_select_journal').append(o);
|
||||
var o;
|
||||
self.$el.parent().find('.oe_account_select_journal').children().remove().end();
|
||||
self.$el.parent().find('.oe_account_select_journal').append(new Option('', ''));
|
||||
for (var i = 0;i < self.journals.length;i++){
|
||||
o = new Option(self.journals[i][1], self.journals[i][0]);
|
||||
if (self.journals[i][0] === self.current_journal){
|
||||
self.current_journal_type = self.journals[i][2];
|
||||
self.current_journal_currency = self.journals[i][3];
|
||||
self.current_journal_analytic = self.journals[i][4];
|
||||
$(o).attr('selected',true);
|
||||
}
|
||||
self.$el.parent().find('.oe_account_select_period').children().remove().end();
|
||||
self.$el.parent().find('.oe_account_select_period').append(new Option('', ''));
|
||||
for (var i = 0;i < self.periods.length;i++){
|
||||
o = new Option(self.periods[i][1], self.periods[i][0]);
|
||||
self.$el.parent().find('.oe_account_select_period').append(o);
|
||||
}
|
||||
self.$el.parent().find('.oe_account_select_period').val(self.current_period).attr('selected',true);
|
||||
return self.search_by_journal_period();
|
||||
});
|
||||
self.$el.parent().find('.oe_account_select_journal').append(o);
|
||||
}
|
||||
self.$el.parent().find('.oe_account_select_period').children().remove().end();
|
||||
self.$el.parent().find('.oe_account_select_period').append(new Option('', ''));
|
||||
for (var i = 0;i < self.periods.length;i++){
|
||||
o = new Option(self.periods[i][1], self.periods[i][0]);
|
||||
self.$el.parent().find('.oe_account_select_period').append(o);
|
||||
}
|
||||
self.$el.parent().find('.oe_account_select_period').val(self.current_period).attr('selected',true);
|
||||
return self.search_by_journal_period();
|
||||
},
|
||||
search_by_journal_period: function() {
|
||||
var self = this;
|
||||
|
@ -93,7 +93,9 @@ openerp.account.quickadd = function (instance) {
|
|||
self.last_context["journal_type"] = self.current_journal_type;
|
||||
self.last_context["currency"] = self.current_journal_currency;
|
||||
self.last_context["analytic_journal_id"] = self.current_journal_analytic;
|
||||
return self.old_search(new instance.web.CompoundDomain(self.last_domain, domain), self.last_context, self.last_group_by);
|
||||
var compound_domain = new instance.web.CompoundDomain(self.last_domain, domain);
|
||||
self.dataset.domain = compound_domain.eval();
|
||||
return self.old_search(compound_domain, self.last_context, self.last_group_by);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue