self.env['product.product'].with_context(warehouse=self.warehouse_id.id)
self.env['product.product'].search([('warehouse_id', '=', self.warehouse_id.id)]))
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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 -
Thanks
Ashish Singh
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up