[FIX] account: multiple journal items to fix in full batch reconciling

In a batch reconciliation of journal items,
it could happen that multiple journal items
in a foreign currency required the creation
of an exchange entry
`aml_to_balance_currency |= aml`

But the statement `aml.matched_debit_ids[0] or aml.matched_credit_ids[0]`
requires a single browse record (singleton) to work

The partial  reconciliation is supposed to be the same for all
the journal items to fix, we can therefore safely do
`aml = aml_to_balance_currency[0]` to overcome this issue.

In addition, in this condition, the full reconcile must be
skipped to avoid passing multiple times in the `create_exchange_rate_entry`
method (which is called in the method `create` of `account.partial.reconcile`

This has been reviewed by qdp.

opw-680044
This commit is contained in:
Denis Ledoux
2016-06-13 17:20:48 +02:00
parent ec005af5b9
commit 3b4560cf42
+2 -2
View File
@@ -934,10 +934,10 @@ class AccountMoveLine(models.Model):
if aml.currency_id and aml.currency_id == currency:
total_amount_currency += aml.amount_currency
if currency and aml_to_balance_currency:
aml = aml_to_balance_currency
aml = aml_to_balance_currency[0]
#eventually create journal entries to book the difference due to foreign currency's exchange rate that fluctuates
partial_rec = aml.credit and aml.matched_debit_ids[0] or aml.matched_credit_ids[0]
aml_id, partial_rec_id = partial_rec.create_exchange_rate_entry(aml, 0.0, total_amount_currency, currency, maxdate)
aml_id, partial_rec_id = partial_rec.with_context(skip_full_reconcile_check=True).create_exchange_rate_entry(aml_to_balance_currency, 0.0, total_amount_currency, currency, maxdate)
@api.multi
def remove_move_reconcile(self):