Skip to content

Conversation

@kanda999
Copy link
Contributor

@kanda999 kanda999 commented Dec 6, 2024

5016
Reflect OCA updates

Copy link
Member

@yostashiro yostashiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kanda999 It wasn't clear to me whether negative stock would really be created before this update. Can you please confirm on this point?

Copy link
Member

@yostashiro yostashiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this handle the following scenario well?

Process a receipt picking with the following content:

  • Subcontracted product: demand x2, done x1
  • Normal product: demand x2, done x1

Generated backorder picking:

  • Subcontracted product: demand x1
  • Normal product: demand x1

Looking at the code, I suppose it works in this manner. Please confirm.

If it works OK, please add comments explaining the design rationale.

Comment on lines +72 to +73
moves_with_check = self - moves_with_no_check
res = super(StockMove, moves_with_check.with_context(no_backorder=True))._action_done(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the current code doesn't handle the case well where partial receipt is processed for a picking which only contains subcontracted products.

Suggested change
moves_with_check = self - moves_with_no_check
res = super(StockMove, moves_with_check.with_context(no_backorder=True))._action_done(
# Assign `no_backorder=True` context to the first batch of moves for _action_done()
# to avoid generation of a backorder during the process, in case there are two batches
# of moves (with negative check and without) to be processed in _action_done().
if moves_with_no_check != self:
moves_with_no_check = moves_with_no_check.with_context(no_backorder=True)
res = super(StockMove, moves_with_no_check)._action_done(
cancel_backorder=cancel_backorder
)
res += super(StockMove, self - moves_with_no_check)._action_done(
cancel_backorder=cancel_backorder
)

@kanda999 kanda999 marked this pull request as draft February 4, 2025 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants