[FIX] stock_picking_batch_custom: validar collected solo en operaciones detalladas
This commit is contained in:
parent
2237cba034
commit
05a8908007
4 changed files with 63 additions and 27 deletions
|
|
@ -140,29 +140,39 @@ class StockPickingBatch(models.Model):
|
|||
else:
|
||||
batch.summary_line_ids = [fields.Command.clear()]
|
||||
|
||||
def _check_all_products_collected(self, product_ids=None):
|
||||
"""Ensure collected is checked for processed products only.
|
||||
def _check_all_products_collected(self, pickings=None):
|
||||
"""Validate only Detailed Operations collected flags.
|
||||
|
||||
The product summary remains informative until Odoo knows which products
|
||||
are actually being validated after the backorder decision.
|
||||
Product Summary checkboxes are informative and must not block the flow.
|
||||
The blocking validation applies to stock.move.line.is_collected in the
|
||||
detailed operations tab for lines with processed quantity.
|
||||
"""
|
||||
|
||||
for batch in self:
|
||||
not_collected_lines = batch.summary_line_ids.filtered(
|
||||
batch_pickings = (
|
||||
pickings.filtered(lambda p, batch=batch: p.batch_id == batch)
|
||||
if pickings
|
||||
else batch.picking_ids
|
||||
)
|
||||
if not batch_pickings:
|
||||
continue
|
||||
|
||||
not_collected_move_lines = batch_pickings.move_line_ids.filtered(
|
||||
lambda line: (
|
||||
line.qty_done > 0
|
||||
line.move_id.state not in ("cancel", "done")
|
||||
and line.product_id
|
||||
and line.move_id.quantity > 0
|
||||
and not line.is_collected
|
||||
and (not product_ids or line.product_id.id in product_ids)
|
||||
)
|
||||
)
|
||||
if not not_collected_lines:
|
||||
if not not_collected_move_lines:
|
||||
continue
|
||||
|
||||
product_names = ", ".join(
|
||||
not_collected_lines.mapped("product_id.display_name")
|
||||
sorted(set(not_collected_move_lines.mapped("product_id.display_name")))
|
||||
)
|
||||
message = batch.env._(
|
||||
"You must mark all product lines as collected before validating the batch."
|
||||
"You must mark detailed operation lines as collected before validating the batch."
|
||||
)
|
||||
if product_names:
|
||||
message += "\n" + batch.env._(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue