[FIX] mrp_subcontracting: Don't perform subcontracting on 0 quantity

If there are several lines in the picking, and some of them are not
received, you've got an error due to the unconditional processing of
all lines.

Now we prevent those that are not received in the loop.

Closes #640
This commit is contained in:
Pedro M. Baeza
2021-05-20 18:27:45 +02:00
parent b5d9259e75
commit 4875fd46eb
2 changed files with 12 additions and 1 deletions

View File

@@ -5,7 +5,7 @@
{
'name': "Subcontract Productions",
'version': '12.0.1.0.4',
'version': '12.0.1.0.5',
"author": "Odoo S.A., Tecnativa, Odoo Community Association (OCA)",
'website': 'https://github.com/OCA/manufacture',
'category': 'Manufacturing Orders & BOMs',

View File

@@ -6,6 +6,7 @@
from datetime import timedelta
from odoo import api, fields, models
from odoo.tools import float_is_zero
class StockPicking(models.Model):
@@ -59,6 +60,11 @@ class StockPicking(models.Model):
move_finished_ids = move.move_orig_ids.filtered(
lambda m: m.state not in ('done', 'cancel'))
for ml in move.move_line_ids:
if float_is_zero(
ml.qty_done,
precision_rounding=ml.product_uom_id.rounding
):
continue
ml.copy({
'picking_id': False,
'production_id':
@@ -72,6 +78,11 @@ class StockPicking(models.Model):
})
else:
for move_line in move.move_line_ids:
if float_is_zero(
move_line.qty_done,
precision_rounding=move_line.product_uom_id.rounding
):
continue
produce = self.env['mrp.product.produce'].with_context(
default_production_id=production.id,
active_id=production.id).create({