From 37d31e6f1863d44125207747ff798524f40b97f2 Mon Sep 17 00:00:00 2001 From: federico Date: Thu, 13 Oct 2016 15:15:02 -0500 Subject: [PATCH] feat(mrp_production): add automatically a lot even if there is not a wizard action_produce function is call too in mrp_operations at the moment of starting an order work. The problem is if we want to be able of continuing adding automatically a lot_id, write it in the wizard is not possible because there is not a wizard --- mrp_final_product_lot/models/mrp_production.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mrp_final_product_lot/models/mrp_production.py b/mrp_final_product_lot/models/mrp_production.py index ca174666..853d7636 100644 --- a/mrp_final_product_lot/models/mrp_production.py +++ b/mrp_final_product_lot/models/mrp_production.py @@ -21,12 +21,12 @@ class MrpProduction(models.Model): def action_produce( self, production_id, production_qty, production_mode, wiz=False): lot_obj = self.env['stock.production.lot'] - if production_mode == 'consume_produce' and wiz and not wiz.lot_id: + lot = wiz.lot_id if wiz else False + if production_mode == 'consume_produce' and not lot: production = self.browse(production_id) if (production.product_id.track_all or production.product_id.track_production or production.product_id.track_incoming): - lot = False for line in production.move_created_ids2: if (line.product_id.id == production.product_id.id and line.restrict_lot_id): @@ -35,7 +35,7 @@ def action_produce( if not lot: code = (production.manual_production_lot or production.name or '') - if production.concatenate_lots_components: + if production.concatenate_lots_components and wiz: lots = wiz.mapped('consume_lines.lot_id') lots += production.mapped( 'move_lines2.restrict_lot_id') @@ -43,6 +43,7 @@ def action_produce( vals = {'name': code, 'product_id': production.product_id.id} lot = lot_obj.create(vals) - wiz.lot_id = lot + for produce_product in production.move_created_ids: + produce_product.write({'prodlot_id': lot.id}) return super(MrpProduction, self).action_produce( production_id, production_qty, production_mode, wiz=wiz)