diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2017-06-07 15:49:32 +0200 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2017-06-08 14:11:26 +0200 |
| commit | 77be3d8b396f31adfa11d2cd10a22ee3a7f27883 (patch) | |
| tree | 542cd472321e99b0a86c4c9d7df3c51bf759ff86 | |
| parent | c4c9347b9986f60f1b8a534b805e248b25e3eef8 (diff) | |
[FIX] account: avoid duplicated move name
Commits 9365482df05 and 8fc81b871debc2 attempted to prevent the creation
of two moves with the same name during reconciliation. It works in most
cases, but it is still possible to reconcile the same statement line
with more than one line.
We add an extra check to make sure duplicate never happen.
opw-742018
| -rw-r--r-- | addons/account/models/account_bank_statement.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index c9634d5f270..e49546e31e7 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -891,6 +891,10 @@ class AccountBankStatementLine(models.Model): # Create the move self.sequence = self.statement_id.line_ids.ids.index(self.id) + 1 move_name = (self.statement_id.name or self.name) + "/" + str(self.sequence) + # Ensure no duplicate is created + if self.env['account.move'].search([('name', '=', move_name)]): + count = self.env['account.move'].search_count([('name', '=like', move_name + '/%')]) + move_name = u'{}/{}'.format(move_name, count + 1) move_vals = self._prepare_reconciliation_move(move_name) move = self.env['account.move'].create(move_vals) counterpart_moves = (counterpart_moves | move) |
