是否可以从warehouse_id
获取location_id
。
感谢。
答案 0 :(得分:3)
Odoo 10和11
location = self.env['stock.location'].browse(1) # or any other location
warehouse = location.get_warehouse()
@api.multi
@api.returns('stock.warehouse', lambda value: value.id)
def get_warehouse(self):
""" Returns warehouse id of warehouse that contains location """
return self.env['stock.warehouse'].search([
('view_location_id.parent_left', '<=', self.parent_left),
('view_location_id.parent_right', '>=', self.parent_left)], limit=1)