Skip to content

Conversation

@peregrine-2024
Copy link

: Resolves duplicate journal entry generation during interbank transfers caused by sequence naming conflicts in the OCA journal entry sequence module. This fix implements a migration task that updates the sequence logic to prevent duplicate naming conflicts, addressing the 'entry with the same name already exists' error. Reference: OCA Ticket #67312 (https://pm.opensourceintegrators.com/web#menu_id=218&cids=1&action=324&model=helpdesk.ticket&view_type=form&id=67312)

Implemented solution using Cursor CLI automation
@peregrine-2024
Copy link
Author

🛠️ Automated Fix: Account Move Name Sequence Duplicate Handling

This pull request implements a fix for Bug: Interbank Transfers & Reconciliation Process Error (Ticket #67312) by addressing duplicate journal entry name conflicts that occur during concurrent posting scenarios.

🔧 Changes Overview

The following files were added and modified to resolve the issue:

  • account_move_name_sequence_fix/__init__.py

    • Added module initialization to include models.
  • account_move_name_sequence_fix/__manifest__.py

    • Created manifest file defining the module:
      • Name: Account Move Name Sequence Fix
      • Version: 17.0.1.0.0
      • Category: Accounting
      • Dependencies: account, account_move_name_sequence
      • Description: Explains the purpose of fixing duplicate names in concurrent posting.
      • Installable: True
  • account_move_name_sequence_fix/models/__init__.py

    • Imported the account_move model to ensure proper module structure.
  • account_move_name_sequence_fix/models/account_move.py

    • New Model Override: Inherited account.move to override _compute_name_by_sequence.
    • Key Logic Added:
      • Duplicate Detection: Before assigning a sequence name, checks if the name has already been assigned within the current batch.
      • Database Conflict Check: Ensures no duplicate name exists in the database (excluding the current move).
      • Retry Mechanism: Implements up to 10 retries when a conflict is detected, allowing concurrent operations to resolve without failure.
      • Thread-Safe Assignment: Processes journal entries grouped by journal, date, and move type to reduce race conditions.
      • Graceful Error Handling: Uses try/except blocks and logging to manage integrity errors and retries effectively.

📌 How It Fixes the Issue

This change specifically addresses the root cause of duplicate journal entry names when multiple entries are created concurrently — such as during interbank transfers. By introducing:

  • A duplicate detection step in memory before checking the DB,
  • A retry loop with logging to resolve transient conflicts,
  • And a grouped processing approach, it ensures that each journal entry gets a unique name even under high concurrency.

✅ Testing & Review Notes

  • This fix should be tested in environments simulating concurrent journal entry creation.
  • Ensure that the account_move_name_sequence module is properly installed and configured.
  • Verify that no regressions occur in standard journal entry workflows.
  • Consider edge cases like very high concurrency or large batches of moves.

Please review and test thoroughly before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants