diff options
| author | Christophe Simonis <chs@odoo.com> | 2015-01-19 17:15:56 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2015-01-19 17:15:56 +0100 |
| commit | 18e22be138f4d273ce8f63c0ff2c8a437cf6ce5d (patch) | |
| tree | 63bd658de7b6fa0e91d521ca19322dd68bdc1492 /addons/account/static/src | |
| parent | f6e5bf847b1a7107c09b009a757823b0f9514fa4 (diff) | |
| parent | 0aab81cd3ac6881b2b64ccedb901b55badd421d4 (diff) | |
[MERGE] forward port of branch 8.0 up to 0aab81c
Diffstat (limited to 'addons/account/static/src')
4 files changed, 83 insertions, 39 deletions
diff --git a/addons/account/static/src/css/account_bank_statement_reconciliation.css b/addons/account/static/src/css/account_bank_statement_reconciliation.css index 3543360fb26..a5710c2e0b1 100644 --- a/addons/account/static/src/css/account_bank_statement_reconciliation.css +++ b/addons/account/static/src/css/account_bank_statement_reconciliation.css @@ -55,6 +55,10 @@ top: 2px; z-index: 10; text-shadow: -1px -1px 0 #f5f5f5, 1px -1px 0 #f5f5f5, -1px 1px 0 #f5f5f5, 1px 1px 0 #f5f5f5; } + .openerp .oe_bank_statement_reconciliation .show_more_container { + text-align: center; } + .openerp .oe_bank_statement_reconciliation .show_more_container .show_more { + display: none; } .openerp .oe_bank_statement_reconciliation .notification_area { margin: 0 15px; } .openerp .oe_bank_statement_reconciliation .interface_options { diff --git a/addons/account/static/src/css/account_bank_statement_reconciliation.scss b/addons/account/static/src/css/account_bank_statement_reconciliation.scss index 1b4acdb2ee5..a773e20b4f4 100644 --- a/addons/account/static/src/css/account_bank_statement_reconciliation.scss +++ b/addons/account/static/src/css/account_bank_statement_reconciliation.scss @@ -92,6 +92,13 @@ $aestetic_animation_speed: 300ms; } } + .show_more_container { + text-align: center; + + .show_more { + display: none; + } + } .notification_area { margin: 0 $actionColWidth; } diff --git a/addons/account/static/src/js/account_widgets.js b/addons/account/static/src/js/account_widgets.js index 126ceaa6d94..136c571f495 100644 --- a/addons/account/static/src/js/account_widgets.js +++ b/addons/account/static/src/js/account_widgets.js @@ -15,11 +15,13 @@ openerp.account = function (instance) { "click .statement_name span": "statementNameClickHandler", "keyup .change_statement_name_field": "changeStatementNameFieldHandler", "click .change_statement_name_button": "changeStatementButtonClickHandler", + "click .show_more": "showMoreButtonClickHandler", }, init: function(parent, context) { this._super(parent); - this.max_reconciliations_displayed = 10; + // Number of reconciliations loaded initially and by clicking 'show more' + this.num_reconciliations_fetched_in_batch = 10; if (context.context.statement_id) this.statement_ids = [context.context.statement_id]; if (context.context.statement_ids) this.statement_ids = context.context.statement_ids; this.single_statement = this.statement_ids !== undefined && this.statement_ids.length === 1; @@ -237,7 +239,7 @@ openerp.account = function (instance) { total_lines: self.already_reconciled_lines+self.st_lines.length })); self.updateProgressbar(); - var reconciliations_to_show = self.st_lines.slice(0, self.max_reconciliations_displayed); + var reconciliations_to_show = self.st_lines.slice(0, self.num_reconciliations_fetched_in_batch); self.last_displayed_reconciliation_index = reconciliations_to_show.length; self.$(".reconciliation_lines_container").css("opacity", 0); @@ -251,6 +253,7 @@ openerp.account = function (instance) { $.when.apply($, child_promises).then(function(){ self.$(".reconciliation_lines_container").animate({opacity: 1}, self.aestetic_animation_speed); self.getChildren()[0].set("mode", "match"); + self.updateShowMoreButton(); if (self.notifications) { self.displayNotifications(self.notifications); } @@ -340,7 +343,7 @@ openerp.account = function (instance) { var child = reconciliations[i]; data.push([child.st_line_id, child.makeMoveLineDicts()]); } - var deferred_animation = self.$(".reconciliation_lines_container").fadeOut(self.aestetic_animation_speed); + var deferred_animation = self.$(".reconciliation_lines_container, .show_more_container").fadeOut(self.aestetic_animation_speed); deferred_rpc = self.model_bank_statement_line.call("process_reconciliations", [data]); return $.when(deferred_animation, deferred_rpc) .done(function() { @@ -359,48 +362,25 @@ openerp.account = function (instance) { // Display new line if there are left if (self.last_displayed_reconciliation_index < self.st_lines.length) { - var begin = self.last_displayed_reconciliation_index; - var end = Math.min((begin+self.max_reconciliations_displayed), self.st_lines.length); - var reconciliations_to_show = self.st_lines.slice(begin, end); - - return self.model_bank_statement_line - .call("get_data_for_reconciliations", [reconciliations_to_show]) - .then(function (data) { - var child_promises = []; - var datum; - while ((datum = data.shift()) !== undefined) { - var context = { - st_line_id: datum.st_line.id, - mode: 'inactive', - animate_entrance: false, - initial_data_provided: true, - st_line: datum.st_line, - reconciliation_proposition: datum.reconciliation_proposition, - }; - var widget = new instance.web.account.bankStatementReconciliationLine(self, context); - child_promises.push(widget.appendTo(self.$(".reconciliation_lines_container"))); + return self.displayReconciliations(self.num_reconciliations_fetched_in_batch).then(function() { + // Put the first line in match mode + if (self.reconciled_lines !== self.st_lines.length) { + var first_child = self.getChildren()[0]; + if (first_child.get("mode") === "inactive") { + first_child.set("mode", "match"); } - self.last_displayed_reconciliation_index += reconciliations_to_show.length; - return $.when.apply($, child_promises).then(function() { - // Put the first line in match mode - if (self.reconciled_lines !== self.st_lines.length) { - var first_child = self.getChildren()[0]; - if (first_child.get("mode") === "inactive") { - first_child.set("mode", "match"); - } - } - self.$(".reconciliation_lines_container").fadeIn(self.aestetic_animation_speed); - }); - }); + } + self.$(".reconciliation_lines_container, .show_more_container").fadeIn(self.aestetic_animation_speed); + }); } else if (self.reconciled_lines === self.st_lines.length) { // Congratulate the user if the work is done self.displayDoneMessage(); } else { // Some lines weren't persisted because they were't valid - self.$(".reconciliation_lines_container").fadeIn(self.aestetic_animation_speed); + self.$(".reconciliation_lines_container, .show_more_container").fadeIn(self.aestetic_animation_speed); } }).fail(function() { - self.$(".reconciliation_lines_container").fadeIn(self.aestetic_animation_speed); + self.$(".reconciliation_lines_container, .show_more_container").fadeIn(self.aestetic_animation_speed); }); }, @@ -433,7 +413,8 @@ openerp.account = function (instance) { // Update children if needed _.each(self.getChildren(), function(child){ - if ((child.partner_id === partner_id || child.st_line.has_no_partner) && child !== source_child) { + if (child === source_child || child.st_line === undefined) return; + if (child.partner_id === partner_id || child.st_line.has_no_partner) { if (contains_lines(child.get("mv_lines_selected"), line_ids)) { child.set("mv_lines_selected", _.filter(child.get("mv_lines_selected"), function(o){ return line_ids.indexOf(o.id) === -1 })); } else if (contains_lines(child.mv_lines_deselected, line_ids)) { @@ -457,6 +438,7 @@ openerp.account = function (instance) { // Update children if needed _.each(self.getChildren(), function(child){ + if (child.st_line === undefined) return; if (child.partner_id === partner_id && child !== source_child && (child.get("mode") === "match" || child.$el.hasClass("no_match"))) child.updateMatches(); if (child.st_line.has_no_partner && child.get("mode") === "match" || child.$el.hasClass("no_match")) @@ -464,6 +446,42 @@ openerp.account = function (instance) { }); }, + displayReconciliations: function(number) { + var self = this; + var begin = self.last_displayed_reconciliation_index; + var end = Math.min((begin+number), self.st_lines.length); + var reconciliations_to_show = self.st_lines.slice(begin, end); + + // Get ids of selected move lines (to exclude them from reconciliation proposition) + var excluded_move_lines_ids = []; + _.each(self.excluded_move_lines_ids, function(o){ + excluded_move_lines_ids = excluded_move_lines_ids.concat(o); + }); + + return self.model_bank_statement_line + .call("get_data_for_reconciliations", [reconciliations_to_show, excluded_move_lines_ids]) + .then(function (data) { + var child_promises = []; + var datum; + while ((datum = data.shift()) !== undefined) { + var context = { + st_line_id: datum.st_line.id, + mode: 'inactive', + animate_entrance: false, + initial_data_provided: true, + st_line: datum.st_line, + reconciliation_proposition: datum.reconciliation_proposition, + }; + var widget = new instance.web.account.bankStatementReconciliationLine(self, context); + child_promises.push(widget.appendTo(self.$(".reconciliation_lines_container"))); + } + self.last_displayed_reconciliation_index += reconciliations_to_show.length; + return $.when.apply($, child_promises).then(function(){ + self.updateShowMoreButton(); + }); + }); + }, + displayReconciliation: function(st_line_id, mode, animate_entrance, initial_data_provided, st_line, reconciliation_proposition) { var self = this; animate_entrance = (animate_entrance === undefined ? true : animate_entrance); @@ -489,7 +507,7 @@ openerp.account = function (instance) { self.doReloadMenuReconciliation(); // Display new line if there are left - if (self.last_displayed_reconciliation_index < self.st_lines.length) { + if (self.last_displayed_reconciliation_index < self.st_lines.length && self.getChildren().length < self.num_reconciliations_fetched_in_batch) { self.displayReconciliation(self.st_lines[self.last_displayed_reconciliation_index++], 'inactive'); } // Congratulate the user if the work is done @@ -504,6 +522,7 @@ openerp.account = function (instance) { first_child.set("mode", "match"); } } + self.updateShowMoreButton(); }, goBackToStatementsTreeView: function() { @@ -557,6 +576,7 @@ openerp.account = function (instance) { // Render it self.$(".protip").hide(); + self.updateShowMoreButton(); self.$(".oe_form_sheet").append(QWeb.render("bank_statement_reconciliation_done_message", { title: title, time_taken: time_taken, @@ -606,7 +626,19 @@ openerp.account = function (instance) { }); } }, + + showMoreButtonClickHandler: function() { + this.displayReconciliations(this.num_reconciliations_fetched_in_batch); + }, + updateShowMoreButton: function() { + var items_remaining = this.st_lines.length - this.last_displayed_reconciliation_index; + if (items_remaining > 0) + this.$(".show_more").show().find(".num_items_remaining").text(items_remaining); + else + this.$(".show_more").hide(); + }, + updateProgressbar: function() { var self = this; var done = self.already_reconciled_lines + self.reconciled_lines; diff --git a/addons/account/static/src/xml/account_bank_statement_reconciliation.xml b/addons/account/static/src/xml/account_bank_statement_reconciliation.xml index 415be5dde94..9d3ec4a67a4 100644 --- a/addons/account/static/src/xml/account_bank_statement_reconciliation.xml +++ b/addons/account/static/src/xml/account_bank_statement_reconciliation.xml @@ -34,6 +34,7 @@ <div class="oe_clear"></div> <div class="notification_area"></div> <div class="reconciliation_lines_container"></div> + <div class="show_more_container"><button class="show_more">Show more... (<span class="num_items_remaining"></span> remaining)</button></div> <p class='protip'>Tip : Hit ctrl-enter to validate the whole sheet.</p> </div></div> </t> |
