Skip to content

Commit

Permalink
[FIX] account: reconciliation, error when changing partner
Browse files Browse the repository at this point in the history
Traceback by pressing enter when changing partner which should not occur as keyUp event is
in place for other M2O fields and not for the partner.

In some case, if the line is balanced (marked as reconciled) and we change the user for one that does
not have any move lines, we removed the selected proposition but we did not changed the line balance, resulting
in a widget that is marked as inactive and no way to do something with it.
  • Loading branch information
csnauwaert committed Sep 19, 2017
1 parent 90a253b commit 73bec3d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Expand Up @@ -235,6 +235,7 @@ var StatementModel = BasicModel.extend({
return $.when(partner && this._changePartner(handle, partner.id))
.then(function() {
line.reconciliation_proposition = [];
self._computeLine(line);
return self.changeMode(handle, 'match');
})
.then(function () {
Expand Down
Expand Up @@ -600,6 +600,10 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
* @param {keyup event} event
*/
_onInputKeyup: function (event) {
var target_partner_id = $(event.target).parents('[name="partner_id"]');
if (target_partner_id.length === 1) {
return;
}
if(event.keyCode === 13) {
if (_.findWhere(this.model.lines, {mode: 'create'}).balance.amount) {
this._onCreateProposition();
Expand Down
16 changes: 15 additions & 1 deletion addons/account/static/tests/reconciliation_tests.js
Expand Up @@ -741,7 +741,7 @@ QUnit.module('account', {
});

QUnit.test('Reconciliation change partner', function (assert) {
assert.expect(13);
assert.expect(17);

var clientAction = new ReconciliationClientAction.StatementAction(null, this.params.options);

Expand All @@ -759,6 +759,20 @@ QUnit.module('account', {
var widget = clientAction.widgets[0];
assert.strictEqual(widget.$('.o_input_dropdown input').val(), "Agrolait", "the partner many2one should display agrolait");
assert.strictEqual(widget.$('.match table tr').length, 2, "agrolait should have 2 propositions for reconciliation");

// Adding the two propositions
// This is in order to try that after changing partner the propositions are emptied
widget.$('.match .cell_account_code:first').trigger('click');
widget.$('.match .cell_account_code:first').trigger('click');
assert.strictEqual(widget.$('.accounting_view tbody tr').length, 2, "Both proposition should be selected");

// Similate changing partner to one that does not have propositions to see if create mode is open after
widget.$('.o_input_dropdown input').trigger('click');
$('.ui-autocomplete .ui-menu-item a:contains(partner 1)').trigger('mouseenter').trigger('click');
clientAction._onAction({target: widget, name: 'change_partner', data: {data: {display_name: 'partner 1', id: 1}}, stopped: false});
assert.strictEqual(widget.$('.o_input_dropdown input').val(), "partner 1", "the partner many2one should display partner 1");
assert.strictEqual(widget.$('.match table tr.mv_line').length, 0, "partner 1 should have 0 propositions for reconciliation");
assert.strictEqual(widget.$el.data('mode'), 'create', "widget should be in create mode");

// Simulate changing partner
widget.$('.o_input_dropdown input').trigger('click');
Expand Down

0 comments on commit 73bec3d

Please sign in to comment.