[FIX] sale_mrp: allow production without finished products

Have a mrp.production that you cancel, and delete the finished products lines

Before this commit, the computation of the sale_name crashed because we did
an index selection on an empty recordset

After this commit, there is no crash

opw 1851217
closes #24923
This commit is contained in:
Lucas Perais (lpe)
2018-05-30 14:14:09 +02:00
parent 2288a89564
commit 16a8459a2e
+1 -1
View File
@@ -18,7 +18,7 @@ class MrpProduction(models.Model):
return get_parent_move(move.move_dest_id)
return move
for production in self:
move = get_parent_move(production.move_finished_ids[0])
move = get_parent_move(production.move_finished_ids[:1])
production.sale_name = move.procurement_id and move.procurement_id.sale_line_id and move.procurement_id.sale_line_id.order_id.name or False
production.sale_ref = move.procurement_id and move.procurement_id.sale_line_id and move.procurement_id.sale_line_id.order_id.client_order_ref or False