Skip to content

Commit

Permalink
feat(mrp_production): add automatically a lot even if there is not a …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
federico committed Oct 13, 2016
1 parent 726e710 commit 6decbc7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mrp_final_product_lot/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -35,14 +35,15 @@ 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')
code = '-'.join(lots.mapped('name'))
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)

0 comments on commit 6decbc7

Please sign in to comment.