stock_warehouse.py 664 B

123456789101112131415161718192021222324252627
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request as req
  3. def get_warehouses():
  4. return [
  5. {
  6. 'id': w.id,
  7. 'name': w.display_name,
  8. 'locationStock': {
  9. 'id': w.lot_stock_id.id,
  10. 'name': w.lot_stock_id.display_name
  11. }
  12. } for w in req.env.user.store_id.warehouse_ids
  13. ]
  14. def get_location_id(warehouse_id):
  15. if not warehouse_id:
  16. return None
  17. store_id = req.env.user.store_id
  18. if len(store_id) == 0:
  19. store_id = req.env['res.store'].search([])[0]
  20. return store_id.warehouse_ids.filtered(lambda x: x.id == warehouse_id).lot_stock_id.id