Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def _init_stock_move(self):
- stock_location = self.env.ref('stock.stock_location_stock')
- for prod in self.produce_ids:
- move = self.env['stock.move'].create({
- 'name': 'IN-'+str(prod.item_id.name),
- 'location_id': stock_location.id,
- 'location_dest_id': stock_location.id,
- 'product_id': prod.item_id.id,
- 'product_uom': prod.item_id.uom_id.id,
- 'product_uom_qty': prod.produced_qty,
- 'picking_type_id': 1, # assign picking type to id of 'iRebero: Receipts'
- 'reserved_availability': prod.produced_qty,
- 'availability': prod.produced_qty,
- 'ordered_qty': prod.produced_qty
- })
- # This creates a stock.move.line record.
- # You could also do it manually using self.env['stock.move.line'].create({...})
- # move.move_line_ids.write({'qty_done': prod.produced_qty})
- move.reserved_quant_ids.write({'qty': prod.produced_qty})
- move.quant_ids.write({'qty': prod.produced_qty, 'product_qty': prod.produced_qty})
- picking = self.env['stock.picking'].create({
- 'state': 'draft',
- 'location_id': stock_location.id,
- 'location_dest_id': stock_location.id,
- 'origin': self.name,
- # 'move_lines': move,
- 'picking_type_id': 1,
- 'picking_type_code': 'incoming',
- 'quant_reserved_exist':False,
- 'min_date': datetime.today()
- })
- picking.move_lines = move
- return {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement