diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py
index eea3e743663..0ff2bd4e7b1 100644
--- a/addons/mrp/models/mrp_production.py
+++ b/addons/mrp/models/mrp_production.py
@@ -234,6 +234,7 @@ class MrpProduction(models.Model):
('available', 'Available'),
('expected', 'Expected'),
('late', 'Late')], compute='_compute_components_availability')
+ production_capacity = fields.Float(compute='_compute_production_capacity', help="Quantity that can be produced with the current stock of components")
show_lot_ids = fields.Boolean('Display the serial number shortcut on the moves', compute='_compute_show_lot_ids')
forecasted_issue = fields.Boolean(compute='_compute_forecasted_issue')
show_serial_mass_produce = fields.Boolean('Display the serial mass produce wizard action', compute='_compute_show_serial_mass_produce')
@@ -356,6 +357,15 @@ class MrpProduction(models.Model):
if production.bom_id and production._origin.bom_id != production.bom_id:
production.product_qty = production.bom_id.product_qty
+ @api.depends('move_raw_ids')
+ def _compute_production_capacity(self):
+ for production in self:
+ production.production_capacity = production.product_qty
+ moves = production.move_raw_ids.filtered(lambda move: move.unit_factor and move.product_id.type != 'consu')
+ if moves:
+ production_capacity = min(moves.mapped(lambda move: move.product_id.uom_id._compute_quantity(move.product_id.qty_available, move.product_uom) / move.unit_factor))
+ production.production_capacity = min(production.product_qty, float_round(production_capacity, precision_rounding=production.product_id.uom_id.rounding))
+
@api.depends('move_finished_ids.date_deadline')
def _compute_date_deadline(self):
for production in self:
diff --git a/addons/mrp/wizard/mrp_production_split.py b/addons/mrp/wizard/mrp_production_split.py
index 6d60a5521cf..2752cff97d8 100644
--- a/addons/mrp/wizard/mrp_production_split.py
+++ b/addons/mrp/wizard/mrp_production_split.py
@@ -21,6 +21,7 @@ class MrpProductionSplit(models.TransientModel):
product_id = fields.Many2one(related='production_id.product_id')
product_qty = fields.Float(related='production_id.product_qty')
product_uom_id = fields.Many2one(related='production_id.product_uom_id')
+ production_capacity = fields.Float(related='production_id.production_capacity')
counter = fields.Integer(
"Split #", default=0, compute="_compute_counter",
store=True, readonly=False)
diff --git a/addons/mrp/wizard/mrp_production_split.xml b/addons/mrp/wizard/mrp_production_split.xml
index 6603b8e0333..2442e9d6199 100644
--- a/addons/mrp/wizard/mrp_production_split.xml
+++ b/addons/mrp/wizard/mrp_production_split.xml
@@ -13,7 +13,8 @@
-
+
+
@@ -35,12 +36,22 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+