Skip to content

Commit

Permalink
Merge pull request #153 from agaldona/8.0-operation_extension_load_wo…
Browse files Browse the repository at this point in the history
…rkorder

[IMP] mrp_operations_extension: load workorder in new stock_moves
  • Loading branch information
anajuaristi committed Nov 2, 2016
2 parents 78f999d + b0b7543 commit 0da310b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
11 changes: 11 additions & 0 deletions mrp_operations_extension/models/mrp_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ def _make_production_consume_line(self, line):
move.work_order = line.work_order.id
return move_id

@api.model
def _make_consume_line_from_data(self, production, product, uom_id, qty,
uos_id, uos_qty):
move_id = super(MrpProduction, self)._make_consume_line_from_data(
production, product, uom_id, qty, uos_id, uos_qty)
work_order = self.env.context.get('default_work_order', False)
if work_order:
move = self.env['stock.move'].browse(move_id)
move.work_order = work_order
return move_id


class MrpProductionProductLine(models.Model):
_inherit = 'mrp.production.product.line'
Expand Down
13 changes: 9 additions & 4 deletions mrp_operations_extension/wizard/mrp_work_order_produce.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,27 @@ def _get_track(self):
def do_consume(self, cr, uid, ids, context=None):
work_line = self.pool['mrp.production.workcenter.line'].browse(
cr, uid, context.get("active_id"), context=context)
new_context = context.copy()
new_context.update({'default_work_order': work_line.id})
production_id = work_line.production_id.id
assert production_id
data = self.browse(cr, uid, ids[0], context=context)
data = self.browse(cr, uid, ids[0], context=new_context)
self.pool['mrp.production'].action_produce(
cr, uid, production_id, False, 'consume', data, context=context)
cr, uid, production_id, False, 'consume', data,
context=new_context)
return {}

def do_consume_produce(self, cr, uid, ids, context=None):
work_line = self.pool['mrp.production.workcenter.line'].browse(
cr, uid, context.get("active_id"), context=context)
new_context = context.copy()
new_context.update({'default_work_order': work_line.id})
production_id = work_line.production_id.id
assert production_id
data = self.browse(cr, uid, ids[0], context=context)
data = self.browse(cr, uid, ids[0], context=new_context)
self.pool['mrp.production'].action_produce(
cr, uid, production_id, data.product_qty, 'consume_produce', data,
context=context)
context=new_context)
return {}

def on_change_qty(self, cr, uid, ids, product_qty, consume_lines,
Expand Down

0 comments on commit 0da310b

Please sign in to comment.