Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
7932 มุมมอง
 self.env['product.product'].with_context(warehouse=self.warehouse_id.id)
self.env['product.product'].search([('warehouse_id', '=', self.warehouse_id.id)]))
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi, Mostafa

.with_context() helps to send some extra context along with current environment. For more info please refer to the below link

https://www.odoo.com/documentation/9.0/reference/orm.html#openerp.models.Model.with_context 

https://www.odoo.com/documentation/13.0/reference/orm.html#altering-the-environment 

.search([]) is a orm method which helps to return list of record sets on the basis of domain. For more info please refer to the below link,

https://www.odoo.com/documentation/13.0/reference/orm.html#odoo.models.Model.search 


Thanks,
Ashish Singh (Team Lead)
Webkul Software Private Limited  
อวตาร
ละทิ้ง
ผู้เขียน

in my example which one should I use

Hi, Mostafa

You can use the first one. If you want to fetch the stock from the particular warehouse.

Thanks,

Ashish Singh

ผู้เขียน

thanks

Hi, Mostafa

Thanks for your appreciation.

Now if my solution helps you to fix your query and If you liked my assistance then I would really appreciate if you can take out a few minutes out of your busy schedule and put a google review for us here -

https://www.google.com/search?q=webkul&oq=webkul+&aqs=chrome..69i57j69i60l3j0l2.4182j0j7&sourceid=chrome&ie=UTF-8#lrd=0x390ce561c5555555:0xcfb40ae166ce6c21,1

Thanks

Ashish Singh