Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions mrp_show_finished_moves/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,32 @@ This module extends the Manufacturing (MRP) functionality to improve the visibil
- **Enhanced Finished Move Form**
- Replaces reserved availability with **product quantity** for better tracking.
- Improves integration with immediate transfers.

- **Serial Number Automation**
- Computes the **last manufactured lot/serial** for the product and stores it in a new field `last_manufactured_lot`.
- Automatically calculates the **next serial number** by incrementing the last manufactured one.
- Propagates the next serial number to finished moves (`next_serial`, `next_serial_count`).
- Automatically triggers serial assignment and line generation for serial‑tracked products.

- **Improved Behavior for Serial‑Tracked Products**
- Ensures `qty_producing` is always aligned with `product_qty` when splitting serial‑tracked MOs.
- Adjusts unit‑of‑measure conversions to respect the serial quantity through context (`qty_twith_serial`).

- **Automatic Lot Name Propagation**
- When the MO’s `lot_producing_id` changes, all related finished move lines automatically update their `lot_name`.
- New move lines created for lot‑tracked products inherit the MO’s lot name.

- **Move Line Enhancements**
- Automatically clears `reserved_uom_qty` for finished move lines to avoid misleading reservations.
- Ensures lot names are assigned when appropriate during move line creation.

- **Improved Move Details Behavior**
- The “Show Details” action opens in the **current window** instead of a popup.
- For finished moves of tracked products, the form displays **lot name instead of lot ID** for clarity.

- **Package Visibility Improvements**
- Adds actions to show **origin packages**, **result packages**, or both, directly from the move.


Bug Tracker
===========
Expand Down
1 change: 1 addition & 0 deletions mrp_show_finished_moves/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import wizard
61 changes: 38 additions & 23 deletions mrp_show_finished_moves/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def _increment_serial_number(self, serial):

def _update_move_next_serial(self):
for production in self:
production._compute_last_manufactured_lot()
if production.last_manufactured_lot:
next_serial = self._increment_serial_number(
production.last_manufactured_lot
Expand All @@ -54,14 +55,16 @@ def _update_move_next_serial(self):
moves_to_update = production.move_finished_ids.filtered(
lambda m: m.product_id == production.product_id
)
moves_to_update.write(
{
"next_serial": next_serial,
"next_serial_count": production.product_qty,
}
)
moves_to_update.action_clear_lines_show_details()
moves_to_update.action_assign_serial_show_details()
for move in moves_to_update:
move.write(
{
"next_serial": next_serial,
"next_serial_count": production.product_qty,
}
)
move.action_clear_lines_show_details()
move.action_assign_serial_show_details()
production.qty_producing = move.quantity_done

def action_show_finished_move_lines(self):
self.ensure_one()
Expand Down Expand Up @@ -179,7 +182,24 @@ def button_mark_done(self):
yes_label=_("Yes, adjust quantities and proceed"),
no_label=_("No, review data first"),
)
return super().button_mark_done()
res = super().button_mark_done()

for production in self:
partials = self.env["mrp.production"].search(
[
("procurement_group_id", "=", production.procurement_group_id.id),
("id", "!=", production.id),
("state", "!=", "done"),
]
)
for partial in partials:
partial._compute_last_manufactured_lot()
if (
partial.last_manufactured_lot
and partial.product_id.tracking == "serial"
):
partial._update_move_next_serial()
return res

def _launch_qty_warning(self, production, message, yes_label, no_label):
"""Launches the generic quantity warning wizard with context-specific text."""
Expand Down Expand Up @@ -210,15 +230,15 @@ def update_quantity_done(self):
wo.qty_producing = quantity_done
wo.qty_produced = quantity_done

@api.model
def create(self, vals):
production = super().create(vals)
if (
production.last_manufactured_lot
and production.product_id.tracking == "serial"
):
production._update_move_next_serial()
return production
def action_confirm(self):
res = super().action_confirm()
for production in self:
if (
production.last_manufactured_lot
and production.product_id.tracking == "serial"
):
production._update_move_next_serial()
return res

def write(self, vals):
res = super().write(vals)
Expand Down Expand Up @@ -252,11 +272,6 @@ def write(self, vals):
)
)
move.move_line_ids = ml_cmds
if (
"last_manufactured_lot" in vals
and production.product_id.tracking == "serial"
):
production._update_move_next_serial()
return res


Expand Down
8 changes: 6 additions & 2 deletions mrp_show_finished_moves/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def action_show_details(self):
@api.onchange("quantity_done")
def _on_change_quantity_done(self):
for move in self:
if move.production_id.qty_producing == 0.0:
move.production_id.qty_producing = move.quantity_done
move.production_id.qty_producing = move.quantity_done

@api.depends(
"has_tracking",
Expand Down Expand Up @@ -55,3 +54,8 @@ def action_show_move_lines_packages(self):
"res_model": "stock.quant.package",
"domain": [("id", "in", all_packages.ids)],
}

def action_clear_lines_show_details(self):
res = super().action_clear_lines_show_details()
self._on_change_quantity_done()
return res
1 change: 1 addition & 0 deletions mrp_show_finished_moves/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import change_production_qty
19 changes: 19 additions & 0 deletions mrp_show_finished_moves/wizard/change_production_qty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from odoo import models


class ChangeProductionQty(models.TransientModel):

_inherit = "change.production.qty"

def change_prod_qty(self):
for wizard in self:
production = wizard.mo_id
if production.product_id.tracking == "serial":
production.move_finished_ids.filtered(
lambda m: m.product_id == production.product_id
).action_clear_lines_show_details()
res = super().change_prod_qty()
production._update_move_next_serial()
else:
res = super().change_prod_qty()
return res