[FIX] mrp: allow validation when no components

Conflicting fixes for unusual cases of MO validation when no components
assigned and when components assigned all with 0 consumed made it so we
cannot validate an MO with no components despite there being a
confirmation popup that makes it seem like you can. This fix makes it
so we can validate a MO when no components are assigned (ideally we
would allow validating both cases, but fix for 0 consumed is much more
difficult + an extremely unlikely use case).

closes odoo/odoo#72343

Task: 2422698
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
Tiffany Chang (tic)
2021-06-18 07:37:19 +00:00
parent 405cdd6388
commit 03aede0a2c
+1 -1
View File
@@ -1528,7 +1528,7 @@ class MrpProduction(models.Model):
for production in self:
if float_is_zero(production.qty_producing, precision_rounding=production.product_uom_id.rounding):
raise UserError(_('The quantity to produce must be positive!'))
if not any(production.move_raw_ids.mapped('quantity_done')):
if production.move_raw_ids and not any(production.move_raw_ids.mapped('quantity_done')):
raise UserError(_("You must indicate a non-zero amount consumed for at least one of your components"))
consumption_issues = self._get_consumption_issues()