[FIX] account: avoid duplicated move name
Commits9365482df0and8fc81b871dattempted 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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user