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

[16.0] stock_picking_batch_creation: Allows to split picking #932

Open
wants to merge 3 commits into
base: 16.0
Choose a base branch
from

Conversation

lmignon
Copy link
Contributor

@lmignon lmignon commented Oct 10, 2024

A new option 'Split picking exceeding the limits' on the wizard allow, when the system is not able to find a picking that fits the criteria to create the batch, to lower the criteria by removing those based on the volume, weight and number of lines. If a picking is found and you allow to split it, the system will try to split the picking so that the new picking fits the criteria and can be added to the batch.

Depends on:

A new option 'Split picking exceeding the limits' on the wizard allow, when the system is not able to find a picking that fits the criteria to create the batch, to lower the criteria by removing those based on the volume, weight and number of lines. If a picking is found and you allow to split it, the system will try to split the picking so that the new picking fits the criteria and can be added to the batch.
@lmignon lmignon force-pushed the 16.0-batch_creation_split_picking-lmi branch from 31a03d0 to 785b794 Compare October 10, 2024 10:05
When we allow pickings to be split if one of the volume, weight or number of lines criteria exceeds the set limits, we take care to select the first picking to be processed in accordance with the processing order defined in the system.
Copy link
Contributor

@jbaudoux jbaudoux left a comment

Choose a reason for hiding this comment

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

Looks good.

The device can also define a limit of bins. I'll need this feature in v18.

As commented below, this needs to be split in multiple modules to not add new dependencies

Comment on lines +273 to +281
nbr_lines, volume, weight = self._get_picking_max_dimensions()
wizard = self.env["stock.split.picking"].with_context(active_ids=picking.ids)
wizard.create(
{
"mode": "dimensions",
"max_nbr_lines": nbr_lines,
"max_volume": volume,
"max_weight": weight,
}
Copy link
Contributor

@jbaudoux jbaudoux Dec 23, 2024

Choose a reason for hiding this comment

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

Suggested change
nbr_lines, volume, weight = self._get_picking_max_dimensions()
wizard = self.env["stock.split.picking"].with_context(active_ids=picking.ids)
wizard.create(
{
"mode": "dimensions",
"max_nbr_lines": nbr_lines,
"max_volume": volume,
"max_weight": weight,
}
# In base split module
def _prepare_prepare_split_picking_wizard(self):
return {
"mode": self.split_picking_exceeding_limits_mode
}
# In split_dimension module
def _prepare_prepare_split_picking_wizard(self):
res = super()._prepare_prepare_split_picking_wizard()
if self.split_picking_exceeding_limits_mode == "dimensions":
nbr_lines, volume, weight = self._get_picking_max_dimensions()
res.update({
"mode": "dimensions",
"max_nbr_lines": nbr_lines,
"max_volume": volume,
"max_weight": weight,
})
return res
# In base split module
def _split_first_picking_for_limit(self, picking):
wizard = self.env["stock.split.picking"].with_context(active_ids=picking.ids)
wizard.create(self._prepare_split_picking_wizard())

Comment on lines +290 to +294
nbr_lines, volume, weight = self._get_picking_max_dimensions()
return (
picking.nbr_picking_lines > nbr_lines
or picking.volume > volume
or picking.weight > weight
Copy link
Contributor

@jbaudoux jbaudoux Dec 23, 2024

Choose a reason for hiding this comment

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

Suggested change
nbr_lines, volume, weight = self._get_picking_max_dimensions()
return (
picking.nbr_picking_lines > nbr_lines
or picking.volume > volume
or picking.weight > weight
# In base split module
def _is_picking_exceeding_limits(self, picking):
return False
# In split_dimension module
def _is_picking_exceeding_limits(self, picking):
if self.split_picking_exceeding_limits_mode == "dimensions":
nbr_lines, volume, weight = self._get_picking_max_dimensions()
return (
picking.nbr_picking_lines > nbr_lines
or picking.volume > volume
or picking.weight > weight
)
return super()._is_picking_exceeding_limits(picking)

Copy link
Contributor

@jbaudoux jbaudoux left a comment

Choose a reason for hiding this comment

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

Reviewing this again, I think we should split this into multiple modules.
The existing module should not depend on new modules (there are quite some modules to split by dimension).

I would move the split to a new module stock_picking_batch_creation_split defining split_picking_exceeding_limits and the mode split_picking_exceeding_limits_mode as a selection offering move and depending on stock_split_picking.
Edit: I think this move mode is useless. Maybe split_picking_exceeding_limits can be dropped and only the selection split_picking_exceeding_limits_mode kept with a default behavior as no split.

Then a module stock_picking_batch_creation_split_dimension that declares the mode by dimension and depends on stock_split_picking_dimension.

Then I can add a module stock_picking_batch_creation_split_bins that declares the mode by number of bins and would depend on stock_split_picking_nbr_bins.

Comment on lines +317 to +329
# at this stage we have the first picking to add to the batch but it could
# exceed the limits of the available devices. In this case we split the
# picking and return the picking to add to the batch. The split is done only
# if the split_picking_exceeding_limits is set to True.
if (
picking
and self.split_picking_exceeding_limits
and self._is_picking_exceeding_limits(picking)
):
split_picking = self._split_first_picking_for_limit(picking)
if not split_picking and raise_if_not_found:
raise PickingSplitNotPossibleError(picking)
picking = split_picking
Copy link
Contributor

Choose a reason for hiding this comment

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

Move to stock_picking_batch_creation_split module

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.

2 participants