-
Notifications
You must be signed in to change notification settings - Fork 21
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
[IMP] Add option to cancel merged source inventories #113
Open
azoellner
wants to merge
1
commit into
grap:12.0
Choose a base branch
from
initOS:12.0-IMP-stock_inventory_merge-cancel_merged_sources
base: 12.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hi. regarding that point, what do you think about a simple OCA module
stock_inventory_draft_no_unlink
that overwrite the functionaction_cancel_draft()
likeAnd then, here, only call
action_cancel_draft()
. I see that change quite generic and not linked to that specific module (stock_inventory_merge
)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.
Yes, that's right. But be aware that in my PR, we would like to have state
cancel
, notdraft
. But this could be easily solved.I don't know the rationale of the Odoo core team for removing the lines when resetting the inventory to
draft
.I mean, if the user wants to reset the inventory, they could always remove the lines manually afterwards.
IMHO this method violates the single-responsibility principle.
So yes, such a module "stock_inventory_draft_no_unlink" might be in order. Possibly providing also a separate method
action_cancel()
for modelstock.inventory
.Also, I agree that this module "stock_inventory_merge" itself could also make a nice addition to OCA's
stock-logistics-warehouse
.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.
Hi, thanks for your answer, and sorry again for the delay.
Indeed !
well, I think that there is a little problem on Odoo / Core :
inventories.mapped('move_ids')._action_cancel()
seems to be useless (in Odoo core I mean, inaction_cancel_draft
) because at this step, the inventory is not confirmed, so there are nomove_ids
. What do you think ?Due to 1. if we set the inventory to the "cancel" state, it is not possible to reset to draft. (except if we implement an other function "action_reset_to_draft") but we can also assume that the inventory is definitively canceled.
so i'm quite perplex !
Except of that, 👍 for that PR. Thanks !
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.
Thinking about it again, the state
'draft'
normally occurs only when initially creating a new "stock.inventory". Such an inventory does not have any lines yet. Only when starting it, which means progressing into state'confirm'
= "In Progess", the user can add lines.So it makes indeed sense to remove the lines when resetting into state draft.
However, when merging inventories, the original ones should (IMHO) keep their lines. Consequently, this would then mean to not reset them back to state
'draft'
, but rather to keep them in'confirm'
. Or set them to'cancel'
, as per the suggested option.Would you agree?
This would then mean
Regarding your second point: Yes, for confirmed, but not yet validated inventories, the
self.mapped('move_ids')._action_cancel()
is useless, since the inventory does not yet have any stock moves.However, the method may also be called on validated inventories, and in this case cancelling the stock moves is necessary.