跳至内容
菜单
此问题已终结

Hi all. Like the title, I am wondering how I can get delivery orders from stock.picking based on the warehouse_id in Odoo 12. My code is currently like this:

delivery_orders = self.env['stock.picking'].search(['&', ('state', '=', 'assigned'), ('warehouse_id', '=', warehouse_id)]).mapped('id')

But of course it does not work because there is no warehouse_id field in stock.picking. If anyone knows the answer, please let me know and many thanks in advance.

形象
丢弃
编写者

Thanks a lot

最佳答案

Hello

warehouse id is available on the stock picking type.

so instead of use warehouse_id in stock picking use the picking_type_id.warehouse_id in your search.

like 

self.env['stock.picking'].search(['&', ('state', '=', 'assigned'), ('picking_type_id.warehouse_id', '=', warehouse_id)]).mapped('id')

Hope this will helps you.

形象
丢弃
相关帖文 回复 查看 活动
0
4月 19
2587
0
10月 23
1510
1
3月 23
2326
1
1月 25
1575
4
2月 25
17867