diff --git a/addons/account/static/src/js/reconciliation/reconciliation_action.js b/addons/account/static/src/js/reconciliation/reconciliation_action.js index f9f588a59df..b2c79471929 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_action.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_action.js @@ -257,19 +257,18 @@ var ManualAction = StatementAction.extend({ var handle = event.target.handle; var method = event.name.indexOf('auto_reconciliation') === -1 ? 'validate' : 'autoReconciliation'; this.model[method](handle).then(function (result) { - self.renderer.update({ - 'valuenow': self.model.valuenow, - 'valuemax': self.model.valuemax, - 'title': self.title, - 'time': Date.now()-self.time, - 'notifications': result.notifications, - }); _.each(result.reconciled, function (handle) { self._getWidget(handle).destroy(); }); _.each(result.updated, function (handle) { self._getWidget(handle).update(self.model.getLine(handle)); }); + self.renderer.update({ + valuenow: _.compact(_.invoke(self.widgets, 'isDestroyed')).length, + valuemax: self.widgets.length, + title: self.title, + time: Date.now()-self.time, + }); self._openFirstLine(); }); }, diff --git a/addons/account/static/src/js/reconciliation/reconciliation_model.js b/addons/account/static/src/js/reconciliation/reconciliation_model.js index f1ef79108c2..f1c6a16cd67 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_model.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_model.js @@ -131,7 +131,7 @@ var StatementModel = BasicModel.extend({ */ autoReconciliation: function () { var self = this; - var ids = _.pluck(_.filter(_.values(this.lines), {'reconciled': false}), 'id'); + var ids = _.pluck(_.filter(this.lines, {'reconciled': false}), 'id'); return this._rpc({ model: 'account.bank.statement.line', method: 'reconciliation_widget_auto_reconcile', @@ -247,7 +247,7 @@ var StatementModel = BasicModel.extend({ var line = this.getLine(handle); var prop = _.filter(line.reconciliation_proposition, '__focus'); var last = prop[prop.length-1]; - if (last && (!last.account_id || !last.label.length || !last.amount)) { + if (last && !this._isValid(last)) { return $.Deferred().reject(); } @@ -379,10 +379,12 @@ var StatementModel = BasicModel.extend({ var self = this; var line = this.getLine(handle); var prop = _.find(line.reconciliation_proposition, {'id' : id}); - line.reconciliation_proposition = _.filter(line.reconciliation_proposition, function (p) { - return p.id !== prop.id && p.id !== prop.link && p.link !== prop.id && (!p.link || p.link !== prop.link); - }); - line.mode = isNaN(id) && !this.avoidCreate ? 'create' : 'match'; + if (prop) { + line.reconciliation_proposition = _.filter(line.reconciliation_proposition, function (p) { + return p.id !== prop.id && p.id !== prop.link && p.link !== prop.id && (!p.link || p.link !== prop.link); + }); + } + line.mode = (id || line.mode !== "create") && isNaN(id) && !this.avoidCreate ? 'create' : 'match'; var def = this._computeLine(line); if (line.mode === 'create') { return def.then(function () { @@ -870,6 +872,10 @@ var StatementModel = BasicModel.extend({ var ManualModel = StatementModel.extend({ quickCreateFields: ['account_id', 'journal_id', 'amount', 'analytic_account_id', 'label', 'tax_id'], + //-------------------------------------------------------------------------- + // Public + //-------------------------------------------------------------------------- + /** * load data from * - 'account.move.line' fetch the lines to reconciliate diff --git a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js index 003f1a768d8..c082d92764b 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js @@ -102,7 +102,7 @@ var StatementRenderer = Widget.extend(FieldManagerMixin, { .attr('aria-valuemax', state.valuemax) .css('width', (state.valuenow/state.valuemax*100) + '%'); - if (state.valuenow === state.valuemax) { + if (state.valuenow === state.valuemax && !this.$('.done_message').length) { var dt = Date.now()-this.time; var $done = $(qweb.render("reconciliation.done", { 'duration': moment(dt).utc().format(time.strftime_to_moment_format(_t.database.parameters.time_format)), @@ -129,6 +129,7 @@ var StatementRenderer = Widget.extend(FieldManagerMixin, { * @param {[object]} notifications */ _renderNotifications: function(notifications) { + this.$(".notification_area").empty(); for (var i=0; i o_manual_statement - +

Good Job! There is nothing to reconcile.

diff --git a/addons/account/static/tests/reconciliation_tests.js b/addons/account/static/tests/reconciliation_tests.js index b44c82d6b80..3d87f97cca9 100644 --- a/addons/account/static/tests/reconciliation_tests.js +++ b/addons/account/static/tests/reconciliation_tests.js @@ -909,7 +909,7 @@ QUnit.module('account', { QUnit.test('Reconciliation manual', function (assert) { - assert.expect(9); + assert.expect(8); var clientAction = new ReconciliationClientAction.ManualAction(null, this.params.options); @@ -928,8 +928,6 @@ QUnit.module('account', { clientAction.$('.accounting_view:first .o_reconcile:visible').trigger('click'); - assert.strictEqual(clientAction.$('.progress .progress-bar').attr('aria-valuenow'), "1", "should display a progress bar with 1 reconciled line"); - assert.strictEqual(clientAction.$('.accounting_view:first thead').text().replace(/[\n\r\s]+/g, ' '), " Agrolait 101200 ", "should display the partner and the account code as title"); @@ -943,34 +941,5 @@ QUnit.module('account', { clientAction.destroy(); }); - - - QUnit.test('Reconciliation manual validate all', function (assert) { - assert.expect(6); - - var clientAction = new ReconciliationClientAction.ManualAction(null, this.params.options); - - testUtils.addMockEnvironment(clientAction, { - 'data': this.params.data, - session: this.params.session, - }); - - clientAction.prependTo($('#qunit-fixture')); - - assert.strictEqual(clientAction.$('.o_reconciliation_line[data-mode="match"]').length, 0, "should have every widgets in 'inactive' mode"); - assert.strictEqual(clientAction.$('.o_reconciliation_line').length, 5, "should have 5 widgets to reconciled"); - assert.strictEqual(clientAction.$('.o_reconciliation_line button.o_reconcile:visible').length, 3, "should have 3 widgets who display 'reconcile' button"); - - var e = $.Event("keyup"); - e.which = 13; // # Enter code value - e.ctrlKey = true; // Ctrl key pressed - $("body").trigger(e); - - assert.strictEqual(clientAction.$('.o_reconciliation_line').length, 3, "should have 2 already reconciled widgets"); - assert.strictEqual(clientAction.$('.progress .progress-bar').attr('aria-valuenow'), "2", "should display a progress bar with 2 reconciled line"); - assert.strictEqual(clientAction.$('.o_reconciliation_line[data-mode="match"]').length, 1, "should display the 'match' mode for the first line"); - - clientAction.destroy(); - }); }); });