diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-01-28 13:58:11 +0000 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-01-28 13:58:11 +0000 |
| commit | cf52a04979d7634908c2f0d8eb6a83b7dd614f64 (patch) | |
| tree | 2f8c25f3fab45268400c4ac6addfa15f1f2d37f0 /addons/account/models/account_move.py | |
| parent | cd1f57e9ded2e8ca81d7290e4b5b95a8776045c6 (diff) | |
| parent | d3b8422c9c44557256836bdc0da5480f553eec4d (diff) | |
[MERGE] forward port branch saas-12.1 up to d3b8422c9c4
closes odoo/odoo#30614
Diffstat (limited to 'addons/account/models/account_move.py')
| -rw-r--r-- | addons/account/models/account_move.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 7b038433905..b19485674a4 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -775,7 +775,7 @@ class AccountMoveLine(models.Model): (multiple_currency and float_compare(total_debit, total_credit, precision_rounding=digits_rounding_precision) == 0): exchange_move_id = False # Eventually create a journal entry to book the difference due to foreign currency's exchange rate that fluctuates - if to_balance and any([residual for aml, residual in to_balance.values()]): + if to_balance and any([not float_is_zero(residual, precision_rounding=digits_rounding_precision) for aml, residual in to_balance.values()]): exchange_move = self.env['account.move'].create( self.env['account.full.reconcile']._prepare_exchange_diff_move(move_date=maxdate, company=amls[0].company_id)) part_reconcile = self.env['account.partial.reconcile'] @@ -804,7 +804,7 @@ class AccountMoveLine(models.Model): (debit_moves + credit_moves).read([field]) to_create = [] cash_basis = debit_moves and debit_moves[0].account_id.internal_type in ('receivable', 'payable') or False - cash_basis_percentage_before_rec = [] + cash_basis_percentage_before_rec = {} while (debit_moves and credit_moves): debit_move = debit_moves[0] credit_move = credit_moves[0] @@ -839,7 +839,7 @@ class AccountMoveLine(models.Model): if cash_basis: tmp_set = debit_move | credit_move - cash_basis_percentage_before_rec.append(tmp_set._get_matched_percentage()) + cash_basis_percentage_before_rec.update(tmp_set._get_matched_percentage()) to_create.append({ 'debit_move_id': debit_move.id, @@ -850,14 +850,12 @@ class AccountMoveLine(models.Model): }) part_rec = self.env['account.partial.reconcile'] - index = 0 with self.env.norecompute(): for partial_rec_dict in to_create: new_rec = self.env['account.partial.reconcile'].create(partial_rec_dict) part_rec += new_rec if cash_basis: - new_rec.create_tax_cash_basis_entry(cash_basis_percentage_before_rec[index]) - index += 1 + new_rec.create_tax_cash_basis_entry(cash_basis_percentage_before_rec) self.recompute() return debit_moves+credit_moves @@ -1468,10 +1466,14 @@ class AccountPartialReconcile(models.Model): #move_date is the max of the 2 reconciled items if move_date < move.date: move_date = move.date + percentage_before = percentage_before_rec[move.id] + percentage_after = move.line_ids[0]._get_matched_percentage()[move.id] + # update the percentage before as the move can be part of + # multiple partial reconciliations + percentage_before_rec[move.id] = percentage_after + for line in move.line_ids: if not line.tax_exigible: - percentage_before = percentage_before_rec[move.id] - percentage_after = line._get_matched_percentage()[move.id] #amount is the current cash_basis amount minus the one before the reconciliation amount = line.balance * percentage_after - line.balance * percentage_before rounded_amt = self._get_amount_tax_cash_basis(amount, line) @@ -1543,6 +1545,7 @@ class AccountPartialReconcile(models.Model): 'amount_currency': self.amount_currency and line.currency_id.round(-line.amount_currency * amount / line.balance) or 0.0, 'partner_id': line.partner_id.id, }) + if newly_created_move: if move_date > (self.company_id.period_lock_date or date.min) and newly_created_move.date != move_date: # The move date should be the maximum date between payment and invoice (in case |
