[FIX] account: remove automatic reconciliation button for manual reconciliation
Functionality deprecated since v9 Add also some small rendering fixes for manual reconciliation: * display congrats only once * display journal_id as required * use isValid to create a new proposition line * Can erase all proposition lines in manual reconciliation
This commit is contained in:
@@ -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();
|
||||
});
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<notifications.length; i++) {
|
||||
var $notification = $(qweb.render("reconciliation.notification", {
|
||||
type: notifications[i].type,
|
||||
@@ -706,6 +707,7 @@ var ManualLineRenderer = LineRenderer.extend({
|
||||
_renderCreate: function (state) {
|
||||
this._super(state);
|
||||
this.$('.create .create_journal_id').show();
|
||||
this.$('.create .create_journal_id .o_input').addClass('o_required_modifier');
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<t t-jquery="div:first" t-operation="attributes">
|
||||
<attribute name="class">o_manual_statement</attribute>
|
||||
</t>
|
||||
<t t-jquery="h1:last" t-operation="replace"></t>
|
||||
<t t-jquery="h1:last, .progress, .o_automatic_reconciliation" t-operation="replace"></t>
|
||||
<t t-jquery=".o_view_nocontent p" t-operation="replace"></t>
|
||||
<t t-jquery=".o_view_nocontent" t-operation="append">
|
||||
<p><b>Good Job!</b> There is nothing to reconcile.</p>
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user