[FIX] mrp_subcontracting: block all components = 0 qty_done

Same issue as odoo/odoo#71068 but for subcontracting rather than a MO.

Steps to reproduce:
- create a subcontracted product w/tracked component
- create receipt with subcontracted product (don't forget to set
  "Receive From" = subcontractor
- fill in Detailed Operations with tracked component lot/sn, but Done=0
- Try to record production

Expected Result: Subcontract production is done + window closes
Actual Result: nonsensical "The quantity to produce must be positive"
               validation error

Discovered during task: 2695173

closes odoo/odoo#81649

X-original-commit: 646789811c1f874160318badfe8105d84057b8bd
Related: odoo/enterprise#22998
Signed-off-by: Arnold Moyaux <arm@odoo.com>
This commit is contained in:
Tiffany Chang (tic)
2021-12-20 15:09:50 +00:00
parent 631b111ead
commit b8d2a07e3f
@@ -46,6 +46,8 @@ class MrpProduction(models.Model):
for sml in self.move_raw_ids.move_line_ids:
if sml.tracking != 'none' and not sml.lot_id:
raise UserError(_('You must enter a serial number for each line of %s') % sml.product_id.display_name)
if self.move_raw_ids and not any(self.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()
if consumption_issues:
return self._action_generate_consumption_wizard(consumption_issues)