Contributors mailing list archives

Browse archives


cancel state on account.move

Alexinux, Alexis de Lattre
- 06/10/2022 15:53:01
Dear OCA friends,

Up to Odoo v12, the "state" of an account.move had 2 possible values : "draft" and "posted".
Starting from Odoo v13, the "state" field has one more possible value : "cancel". I hate that, but it's a fact :(

The problem is : how should we handle these "cancel" moves. In several wizards/models, we give the user the choice between "posted moves only" and "all moves" ; does "all moves" means draft+posted or draft+posted+cancel ? Maybe a developer would consider that "all moves" means draft+posted+cancel, but a user often considers that cancelled moves should never be taken into account and "all moves" means draft+posted.

Here is a summary of the situation on Odoo v14 in different modules :
  • account_financial_report : when the user selects "All entries", Odoo takes draft+posted
  • sale and purchase : the "Invoiced qty" on the sale.order.line/purchase.order.line doesn't take into account the cancelled invoices (it only takes draft and posted invoices)
  • l10n_fr_fec : when the user selects "Non-official FEC report (posted and unposted entries)", Odoo takes draft+posted+cancel
  • lock dates : odoo allows to have moves with state="cancel" in a locked period (but moves in draft state are not allowed)
So the majority of modules considers that "all moves" means "draft + posted" and excludes "cancel" state. The fact that Odoo accepts cancel entries in a locked period confirms that cancelled moves should always be ignored, even when Odoo says "all entries".

I think l10n_fr_fec should be fixed to adopt this behavior (I can make a PR for l10n_fr_fec_oca).
The OCA modules account_cutoff_xxx from don't even have a field to say if you should select "all moves" (draft + posted) or "posted moves only" (at the moment, it takes all moves including cancelled moves). I'll make a PR to fix this.

Do you know other modules that should be fixed on this ?

For v16, maybe we should switch from the term "All entries" to "Draft and Posted entries"... what do you think ?

Alexis de Lattre