-
Notifications
You must be signed in to change notification settings - Fork 23k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] stock: add automated way to fix unreserve issue
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 #155910 X-original-commit: e16cd27 Signed-off-by: David Fesquet (dafr) <dafr@odoo.com> Co-authored-by: Arnold Moyaux <arm@odoo.com>
- Loading branch information
1 parent
32e35d8
commit e0e63be
Showing
5 changed files
with
201 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e0e63be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @DavidFesquet,
This commit break the update all module:
./odoo-bin -d database -u all
I just just checked out to the previous commit and the command work correctly.
In advance, thanks for your support
e0e63be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @eicher31 , thank you for the feedback !
I have been trying it on my side with a new database, and unfortunately I do not see any error ...
Here are the commands I tried to reproduce the issue:
Could I have a bit more info on this?
Thank you for your time !
e0e63be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @DavidFesquet,
I am also facing the issue when upgrade
all
.Here is my error message.
I think the issue is happening with database with data.
Thanks
e0e63be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @hieulucky111 ,
Indeed, it seems to be an issue with safe_eval in Odoo and Python 3.11.
Concretely, with python 3.11 you can't do
if value is None:
in a server action.It has been fixed for saas-16.2 and after with this PR: #136943
For now, if the issue is blocking, you can change your python version, I will check if it is possible to back port this commit to 15.0 and 16.0.
If it is not possible, I will try to edit the action so that the optcode POP_JUMP_FORWARD_IF_NOT_NONE is not used (don't think it is possible), and in the worth case, I will revert the commit ...
Thanks for your help !
e0e63be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Odoo 16 it will be fixed with this PR: #156438
For Odoo 15, it is a bit more complicated, the original PR that made Odoo support python3.11 did not target odoo 15.0, so I am unsure whether it needs to be handled or not ...
e0e63be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @DavidFesquet,
Well noted with thanks for your quick response.