diff --git a/addons/mrp/wizard/mrp_consumption_warning.py b/addons/mrp/wizard/mrp_consumption_warning.py
index c4bb7edb941..d2944a895a9 100644
--- a/addons/mrp/wizard/mrp_consumption_warning.py
+++ b/addons/mrp/wizard/mrp_consumption_warning.py
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from odoo import fields, models, api
+from odoo import _, fields, models, api
+from odoo.exceptions import UserError
+from odoo.tools import float_compare, float_round
class MrpConsumptionWarning(models.TransientModel):
@@ -38,6 +40,21 @@ class MrpConsumptionWarning(models.TransientModel):
action_from_mark_done = self.mrp_production_ids.with_context(ctx, skip_consumption=True).button_mark_done()
return action_from_do_finish or action_from_mark_done
+ def action_set_qty(self):
+ self.mrp_production_ids.action_assign()
+ for production in self.mrp_production_ids:
+ for move in production.move_raw_ids:
+ rounding = move.product_uom.rounding
+ if float_compare(move.quantity_done, move.should_consume_qty, precision_rounding=rounding) == 0:
+ continue
+ new_qty = float_round((production.qty_producing - production.qty_produced) * move.unit_factor, precision_rounding=move.product_uom.rounding)
+ if move.has_tracking in ('lot', 'serial'):
+ if not (production.use_auto_consume_components_lots and
+ float_compare(move.reserved_availability, new_qty, precision_rounding=move.product_uom.rounding) >= 0):
+ raise UserError(_('You need to supply Lot/Serial Number'))
+ move.quantity_done = new_qty
+ return self.action_confirm()
+
def action_cancel(self):
if self.env.context.get('from_workorder') and len(self.mrp_production_ids) == 1:
return {
diff --git a/addons/mrp/wizard/mrp_consumption_warning_views.xml b/addons/mrp/wizard/mrp_consumption_warning_views.xml
index 36f3095a512..f0f6bc3c31e 100644
--- a/addons/mrp/wizard/mrp_consumption_warning_views.xml
+++ b/addons/mrp/wizard/mrp_consumption_warning_views.xml
@@ -38,6 +38,7 @@
colspan="1" type="object" class="btn-primary"/>
+