stock_picking.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request as req
  3. def get_pickings():
  4. purchase_orders = req.env['purchase.order'].search([('from_pop', '=', True)])
  5. purchase_orders = purchase_orders.mapped(lambda x: x.name)
  6. domain = [
  7. ('origin', 'in', purchase_orders),
  8. ('state', '=', 'assigned')
  9. ]
  10. return [
  11. {
  12. 'id': sp.id,
  13. 'name': sp.display_name,
  14. 'origin': sp.origin,
  15. 'packOperationExist': sp.pack_operation_exist,
  16. 'moveLines': [
  17. {
  18. 'id': m.id,
  19. 'name': m.display_name,
  20. 'availability': m.availability,
  21. 'origin': m.origin,
  22. 'quantity': m.product_qty,
  23. 'product': {
  24. 'id': m.product_id.id,
  25. 'name': m.product_id.display_name,
  26. 'image': m.product_id.image_medium
  27. }
  28. }
  29. for m in sp.move_lines
  30. ],
  31. 'partner': {
  32. 'id': sp.partner_id.id,
  33. 'name': sp.partner_id.display_name,
  34. 'image': sp.partner_id.image_medium or None,
  35. 'ruc': sp.partner_id.ruc or None,
  36. 'phone': sp.partner_id.phone or None,
  37. 'mobile': sp.partner_id.mobile or None,
  38. 'email': sp.partner_id.email or None
  39. }
  40. } for sp in req.env['stock.picking'].search(domain)
  41. ]
  42. def confirm_picking(stock_picking_id):
  43. stock_picking = req.env['stock.picking'].browse(stock_picking_id)
  44. stock_picking.do_transfer()