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

[14.0][ADD] Add stock_split_picking_kit #1829

Open
wants to merge 2 commits into
base: 14.0
Choose a base branch
from

Conversation

TDu
Copy link
Member

@TDu TDu commented Jan 13, 2025

No description provided.

@TDu TDu force-pushed the 14-add-stock_split_picking_kit branch from f93ff2d to 988cd51 Compare January 13, 2025 14:25
Comment on lines 3 to 5
The new mode `Quantity of kits` allows to split a transfer by a specified number of kits.
A new field on the wizard also allows specify a sort order for the stock moves before
splitting the transfer.

Choose a reason for hiding this comment

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

Suggested change
The new mode `Quantity of kits` allows to split a transfer by a specified number of kits.
A new field on the wizard also allows specify a sort order for the stock moves before
splitting the transfer.
The new mode `Quantity of kits` allows splitting a transfer by a specified number of kits.
A new field in the wizard also allows specifying a sort order for the stock moves before
splitting the transfer.

"summary": "Split a picking by a number of kits.",
"version": "14.0.1.0.0",
"category": "Inventory",
"author": "Camptocamp, " "Odoo Community Association (OCA),",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"author": "Camptocamp, " "Odoo Community Association (OCA),",
"author": "Camptocamp, BCIM, Odoo Community Association (OCA),",

@@ -0,0 +1 @@
* Thierry Ducrest <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Thierry Ducrest <[email protected]>
* Thierry Ducrest <[email protected]>
* Jacques-Etienne Baudoux (BCIM) <[email protected]>


def _apply_kit_quantity(self):
pickings = self.env["stock.picking"]
for picking in self.mapped("picking_ids"):
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for mapped, isn't it ?

used_slots = 0
max_slots = self.kit_split_quantity
for bom, bom_move_list in groupby(
move_lines, key=lambda move: move.bom_line_id.bom_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a note in DESCRIPTION that if we want to use this module on pulled move, we need this module in v14. It's standard since v15
And add a note multi level boms are not supported

# Non kit moves, their quantity is the number of slots used
for move in moves:
quantity = move.product_qty
if available_slots >= move.product_qty:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if available_slots >= move.product_qty:
if available_slots >= quantity:

new_move_vals = []
for move in moves:
new_move_vals += move._split(
move.bom_line_id.product_qty * kit_to_split
Copy link
Contributor

Choose a reason for hiding this comment

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

If you look at the bom_line_id.product_qty, why going through the complex _compute_kit_quantities ?
kit_quantity = move.product_qty / move.bom_line_id.product_qty

Copy link
Member Author

Choose a reason for hiding this comment

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

Because it makes sure that the computed kits are complete.

if moves_to_backorder:
new_picking = picking._create_split_backorder()
moves_to_backorder.write({"picking_id": new_picking.id})
moves_to_backorder.mapped("move_line_ids").write(
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for mapped, isn't it ?

cls.partner = cls.env["res.partner"].create({"name": "Test partner"})
cls.product_model = cls.env["product.product"]

# TODO: How should we handle kit with multiple level
Copy link
Contributor

Choose a reason for hiding this comment

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

Just write in DESCRIPTION you don't

Comment on lines 131 to 138
filters = {
"incoming_moves": lambda m: m.location_id.usage == "supplier",
"outgoing_moves": lambda m: m.location_id.usage != "supplier",
}
kit_quantity = picking.move_lines._compute_kit_quantities(
bom.product_id, 100, bom, filters
)
return abs(kit_quantity)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same remark as above regarding filters & abs

"outgoing_moves": lambda m: m.location_id.usage != "supplier",
}
kit_quantity = picking.move_lines._compute_kit_quantities(
bom.product_id, 100, bom, filters
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe like you did above

Suggested change
bom.product_id, 100, bom, filters
bom.product_id, max(picking.move_lines.mapped("product_qty")), bom, filters

@TDu TDu force-pushed the 14-add-stock_split_picking_kit branch from 3489641 to 248a32e Compare January 17, 2025 08:34
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