diff options
| author | Denis Ledoux dle@openerp.com <> | 2012-11-05 09:41:52 +0100 |
|---|---|---|
| committer | Denis Ledoux dle@openerp.com <> | 2012-11-05 09:41:52 +0100 |
| commit | 9e56b3b6a8a761e02099146b338225d29dbc8c8a (patch) | |
| tree | 295d0a6092852f4ae1b94a77bbb648fb80c50751 /addons/account/static/src | |
| parent | 848cb19302613bfdf332721eb4346ffbad23381e (diff) | |
[ADD]QuickAdd Move Line View
bzr revid: dle@openerp.com-20121105084152-35bvurqkvuv4k0ow
Diffstat (limited to 'addons/account/static/src')
| -rw-r--r-- | addons/account/static/src/js/account_move_reconciliation.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/addons/account/static/src/js/account_move_reconciliation.js b/addons/account/static/src/js/account_move_reconciliation.js index 8e72e24eb22..c0d97fc554b 100644 --- a/addons/account/static/src/js/account_move_reconciliation.js +++ b/addons/account/static/src/js/account_move_reconciliation.js @@ -126,4 +126,65 @@ openerp.account = function (instance) { }, }); + instance.web.views.add('tree_account_move_line_quickadd', 'instance.web.account.QuickAddListView'); + instance.web.account.QuickAddListView = instance.web.ListView.extend({ + init: function() { + this._super.apply(this, arguments); + var self = this; + this.current_journal = null; + this.current_period = null; + }, + load_list: function() { + var self = this; + var tmp = this._super.apply(this, arguments); + if (this.journals) { + this.$el.prepend(QWeb.render("AccountMoveLineQuickAdd", {widget: this})); + } + return tmp; + }, + do_search: function(domain, context, group_by) { + var self = this; + this.last_domain = domain; + 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 mod.call("list_journals", []).pipe(function(result) { + var current = self.current_journal !== null ? self.journals[self.current_journal][0] : null; + self.journals = result; + var index = _.find(_.range(self.journals.length), function(el) { + if (current === self.journals[el][0]) + return true; + }); + if (index !== undefined) + self.current_journal = index; + else + self.current_journal = self.journals.length == 0 ? null : 0; + self.search_by_journal(); + }); + }, + search_by_journal: function() { + var self = this; + var fct = function() { + return self.old_search(new instance.web.CompoundDomain(self.last_domain, + [["journal_id", "in", self.current_journal === null ? [] : + [self.journals[self.current_journal][0]] ]]), self.last_context, self.last_group_by); + }; + return fct(); + }, + search_by_period: function() { + var self = this; + var fct = function() { + return self.old_search(new instance.web.CompoundDomain(self.last_domain, + [["period_id", "in", self.current_period === null ? [] : + [self.periods[self.current_period][0]] ]]), self.last_context, self.last_group_by); + }; + return fct(); + }, + do_select: function (ids, records) { + this.trigger('record_selected') + this._super.apply(this, arguments); + }, + }); + }; |
