stock_picking.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request
  3. _MODEL = 'stock.picking'
  4. def pick_assign(sale_order_id, picking_done=True):
  5. sale_order = request.env['sale.order'].browse(sale_order_id)
  6. for picking in sale_order.picking_ids:
  7. picking.force_assign()
  8. if picking_done:
  9. picking.action_done()
  10. def get_pickings():
  11. sale_orders = request.env['sale.order'].search([('from_pos', '=', True)])
  12. sale_orders = sale_orders.mapped(lambda x: x.name)
  13. domain = [
  14. ('origin', 'in', sale_orders),
  15. ('state', '=', 'assigned')
  16. ]
  17. return [
  18. {
  19. 'id': sp.id,
  20. 'name': sp.display_name,
  21. 'origin': sp.origin,
  22. 'packOperationExist': sp.pack_operation_exist,
  23. 'moveLines': [
  24. {
  25. 'id': move.id,
  26. 'name': move.display_name,
  27. 'availability': move.availability,
  28. 'origin': move.origin,
  29. 'quantity': move.product_qty,
  30. 'product': {
  31. 'id': move.product_id.id,
  32. 'name': move.product_id.display_name,
  33. 'image': move.product_id.image_medium
  34. }
  35. }
  36. for move in sp.move_lines
  37. ],
  38. 'partner': {
  39. 'id': sp.partner_id.id,
  40. 'name': sp.partner_id.display_name,
  41. 'image': sp.partner_id.image_medium or None,
  42. 'ruc': sp.partner_id.ruc or None,
  43. 'phone': sp.partner_id.phone or None,
  44. 'mobile': sp.partner_id.mobile or None,
  45. 'email': sp.partner_id.email or None
  46. }
  47. } for sp in request.env[_MODEL].search(domain)
  48. ]
  49. def confirm_picking(stock_picking_id, user_id):
  50. stock_picking = request.env[_MODEL].browse(stock_picking_id)
  51. stock_picking.write({
  52. 'partner_id': user_id
  53. })
  54. stock_picking.do_transfer()