Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] stock: add automated way to fix unreserve issue #154905

Closed

Conversation

DavidFesquet
Copy link
Contributor

@DavidFesquet DavidFesquet commented Feb 21, 2024

When there is a discrepancy of reserved quantity between stock.quant.reserved_quantity and stock.move.line.product_qty the UserError 'It is not possible to unreserve more products of %s than you have in stock' is raised.
This discrepancy can be caused by past bug, customization or direct manipulation of stock.quant or stock.move.line by the users. Once this discrepancy is present, it will not disappear by itself.

Currently, there is no functional method to fix these discrepancies, the user encountering this message is stuck until they contact the Odoo support team.

Ideally, we would fix every bug related to the reservation so that this UserError almost never appears. However, even after multiple bugs fixed (ex: #144176 , #154327 ) and multiple years of feedback, the users keep encountering this error and keep getting stuck when validating/cancelling transfers.

So the idea is to re-introduce a server action like it was done for Odoo 13 & Odoo 14 2 years ago: d99e173 to the current stable version (except the latest one Odoo 17 as we do not have enough perspectives on this version).

The server action checks all the quants and their relative move line to check if match correctly. If not, it will remove the reservation from both. It could remove the reservation from some unrelated pickings and stock.move

Co-authored-by: Arnold Moyaux arm@odoo.com

Forward-Port of #79180
Related to #62139


Demo:

unreserve-2024-02-21_15.54.42.mp4

I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@C3POdoo C3POdoo added the RD research & development, internal work label Feb 21, 2024
@robodoo
Copy link
Contributor

robodoo commented Feb 21, 2024

@C3POdoo C3POdoo requested a review from a team February 21, 2024 15:01
@DavidFesquet
Copy link
Contributor Author

DavidFesquet commented Feb 21, 2024

The error message can be adjusted.

As for the server action, it comes from this one: https://github.com/odoo/support-tools/blob/master/scripts/stock/fix_reservation_errors.py (support-tools repository, you may not have access to it)
We have been using it for more than a year now, and it works nicely).
A few adjustments have been made:

  • simplified the report message
  • remove the configuration
  • remove the version dependent code
  • reload the page with action = {'type': 'ir.actions.client', 'tag': 'reload'}

@DavidFesquet DavidFesquet force-pushed the 15.0-fix_reservation_action-dafr branch from 3798d46 to 4d98c05 Compare February 21, 2024 15:14
@DavidFesquet
Copy link
Contributor Author

@fw-bot up to saas-15.2

@fw-bot
Copy link
Contributor

fw-bot commented Feb 21, 2024

Forward-porting to 'saas-15.2'.

When there is a discrepancy of reserved quantity between `stock.quant.reserved_quantity` and `stock.move.line.product_qty` the UserError 'It is not possible to unreserve more products of %s than you
have in stock' is raised.
This discrepancy can be caused by past bug, customization or direct manipulation of `stock.quant` or `stock.move.line` by the users.
Once this discrepancy is present, it will not disappear by itself.

Currently, there is no functional method to fix these discrepancies, the user encountering this message is stuck until they contact the Odoo support team.

Ideally, we would fix every bug related to the reservation so that this UserError almost never appears.
However, even after multiple bugs fixed (ex: odoo#144176 , odoo#154327 ) and multiple years of feedback, the users keep encountering this error and keep getting stuck when validating/cancelling transfers.

So the idea is to re-introduce a server action like it was done for Odoo 13 & Odoo 14 2 years ago: d99e173 to the current stable version (except the latest one Odoo 17 as we do not have enough perspectives on this version).

The server action checks all the quants and their relative move line to check if match correctly. If not, it will remove the reservation from both.
It could remove the reservation from some unrelated `pickings` and `stock.move`

Co-authored-by: Arnold Moyaux <arm@odoo.com>

Forward-Port of odoo#79180
Related to odoo#62139
@DavidFesquet DavidFesquet force-pushed the 15.0-fix_reservation_action-dafr branch from 4d98c05 to 3ed0185 Compare February 28, 2024 15:26
@amoyaux
Copy link
Contributor

amoyaux commented Feb 28, 2024

@robodoo delegate+

@DavidFesquet
Copy link
Contributor Author

robodoo r+

robodoo pushed a commit that referenced this pull request Feb 29, 2024
When there is a discrepancy of reserved quantity between `stock.quant.reserved_quantity` and `stock.move.line.product_qty` the UserError 'It is not possible to unreserve more products of %s than you
have in stock' is raised.
This discrepancy can be caused by past bug, customization or direct manipulation of `stock.quant` or `stock.move.line` by the users.
Once this discrepancy is present, it will not disappear by itself.

Currently, there is no functional method to fix these discrepancies, the user encountering this message is stuck until they contact the Odoo support team.

Ideally, we would fix every bug related to the reservation so that this UserError almost never appears.
However, even after multiple bugs fixed (ex: #144176 , #154327 ) and multiple years of feedback, the users keep encountering this error and keep getting stuck when validating/cancelling transfers.

So the idea is to re-introduce a server action like it was done for Odoo 13 & Odoo 14 2 years ago: d99e173 to the current stable version (except the latest one Odoo 17 as we do not have enough perspectives on this version).

The server action checks all the quants and their relative move line to check if match correctly. If not, it will remove the reservation from both.
It could remove the reservation from some unrelated `pickings` and `stock.move`

Forward-Port of #79180
Related to #62139

closes #154905

Signed-off-by: David Fesquet (dafr) <dafr@odoo.com>
Co-authored-by: Arnold Moyaux <arm@odoo.com>
@robodoo robodoo closed this Feb 29, 2024
@fw-bot
Copy link
Contributor

fw-bot commented Feb 29, 2024

@DavidFesquet child PR #155839 was modified / updated and has become a normal PR. This PR (and any of its parents) will need to be merged independently as approvals won't cross.

@fw-bot
Copy link
Contributor

fw-bot commented Feb 29, 2024

Forward-porting to 'saas-16.3' (from #155839).

@fw-bot
Copy link
Contributor

fw-bot commented Mar 4, 2024

@fw-bot
Copy link
Contributor

fw-bot commented Mar 4, 2024

Forward-porting to 'saas-16.3' (from #156063).

@fw-bot
Copy link
Contributor

fw-bot commented Mar 5, 2024

@DavidFesquet this pull request has forward-port PRs awaiting action (not merged or closed):

@fw-bot fw-bot deleted the 15.0-fix_reservation_action-dafr branch March 14, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants