-
-
Notifications
You must be signed in to change notification settings - Fork 663
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
base: 14.0
Are you sure you want to change the base?
Conversation
f93ff2d
to
988cd51
Compare
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. |
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.
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),", |
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.
"author": "Camptocamp, " "Odoo Community Association (OCA),", | |
"author": "Camptocamp, BCIM, Odoo Community Association (OCA),", |
@@ -0,0 +1 @@ | |||
* Thierry Ducrest <[email protected]> |
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.
* 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"): |
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.
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 |
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.
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: |
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.
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 |
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.
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
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.
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( |
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.
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 |
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.
Just write in DESCRIPTION you don't
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) |
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.
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 |
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.
Maybe like you did above
bom.product_id, 100, bom, filters | |
bom.product_id, max(picking.move_lines.mapped("product_qty")), bom, filters |
3489641
to
248a32e
Compare
No description provided.