Skip to Content
Menu
This question has been flagged
1 Reply
6956 Views
 self.env['product.product'].with_context(warehouse=self.warehouse_id.id)
self.env['product.product'].search([('warehouse_id', '=', self.warehouse_id.id)]))
Avatar
Discard
Best Answer

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  
Avatar
Discard
Author

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

Author

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