Skip to content

Conversation

@AungKoKoLin1997
Copy link
Contributor

@AungKoKoLin1997 AungKoKoLin1997 commented Jan 28, 2025

Supersede #1385.
This PR does the following:

  • Extend _update_available_quantity() and _update_reserved_quantity() in stock.quant
    to handle scenarios where owner_restriction should be enforced.
  • Create a separate _get_owner_restriction() method to improve clarity and extensibility for other modules.
  • Fix read_group() in stock.quant, which was incorrectly assigning the owner record
    instead of the owner ID in the domain.
  • Add compute method for restrict_partner_id to dynamically control owner assignment
    based on picking type restrictions.
  • Unlink stock.move.line records when owner_id is updated and owner_restriction is set.
  • Update test cases.

@qrtl QT4207

@AungKoKoLin1997 AungKoKoLin1997 marked this pull request as draft January 28, 2025 05:40
@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 16.0-imp-stock_owner_restriction branch from f1f757d to 3d6f6c8 Compare February 20, 2025 05:36
@AungKoKoLin1997 AungKoKoLin1997 marked this pull request as ready for review February 20, 2025 07:24
@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 16.0-imp-stock_owner_restriction branch from ed15d3e to a49fd85 Compare February 20, 2025 07:39
@rousseldenis rousseldenis added this to the 16.0 milestone Feb 20, 2025
@github-actions
Copy link

github-actions bot commented Jul 6, 2025

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jul 6, 2025
@kanda999 kanda999 force-pushed the 16.0-imp-stock_owner_restriction branch from a49fd85 to d7cc954 Compare July 7, 2025 07:07
Copy link

@kanda999 kanda999 left a comment

Choose a reason for hiding this comment

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

LGTM: This update has been used in production for a year.

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.

Could we perhaps make the intention of adding _compute_restrict_partner_id() clearer?

@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 16.0-imp-stock_owner_restriction branch 3 times, most recently from 79b9c2d to 5bdabf6 Compare July 11, 2025 06:31
@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 16.0-imp-stock_owner_restriction branch from 5bdabf6 to dfec985 Compare July 11, 2025 09:08
… logic to support owner restriction

- Extend _update_available_quantity() and _update_reserved_quantity() in stock.quant
  to handle scenarios where owner_restriction should be enforced.
- Create a separate _get_owner_restriction() method to improve clarity and extensibility for other modules.
- Fix read_group() in stock.quant, which was incorrectly assigning the owner record
  instead of the owner ID in the domain.
- Add compute method for restrict_partner_id to dynamically control owner assignment
  based on picking type restrictions.
- Unlink stock.move.line records when owner_id is updated and owner_restriction is set.
- Update test cases.
@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 16.0-imp-stock_owner_restriction branch from dfec985 to 1b873b6 Compare July 11, 2025 09:59
@api.depends("picking_type_id", "picking_id.owner_id", "move_dest_ids")
def _compute_restrict_partner_id(self):
for move in self:
if move.picking_type_id.owner_restriction == "picking_partner":
Copy link
Member

Choose a reason for hiding this comment

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

Please check the validity of this suggestion.

Suggested change
if move.picking_type_id.owner_restriction == "picking_partner":
if move.picking_type_id.owner_restriction in ("picking_partner", "partner_or_unassigned"):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is not valid. Even if we have move lines from an unassigned owner together with move lines from an assigned owner, the move will still be assigned to the partner. Therefore, we should continue allowing False for this restriction type.

@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants