account-financial-tools icon indicating copy to clipboard operation
account-financial-tools copied to clipboard

account_journal_lock_date should only look at posted moves

Open dannyadair opened this issue 3 years ago • 3 comments

Module

account_journal_lock_date

Describe the bug

Unlike Odoo's _check_fiscalyear_lock_date(), the override does not filter the moves to only look at posted ones. This leads to the unreasonable restriction that you cannot duplicate posted entries if their date is on or before the lock date.

To Reproduce

v13 and v14:

Steps to reproduce the behavior:

  1. Create a customer invoice
  2. Lock the sales journal with a date on or after the invoice date
  3. Try to duplicate this (now locked) invoice

Expected behavior I expect a duplicate of the original invoice but in draft state. Instead, I get the addon's error message of not being allowed to write because of the lock date. However, the duplicate is a draft invoice - I'd expect that error only if I tried to post it with that date.

Odoo's check with for move in self.filtered(lambda move: move.state == 'posted'): https://github.com/odoo/odoo/blob/13.0/addons/account/models/account_move.py#L1585

vs. account_journal_lock_date's check with just for move in self: https://github.com/OCA/account-financial-tools/blob/13.0/account_journal_lock_date/models/account_move.py#L25

dannyadair avatar Nov 30 '21 00:11 dannyadair