Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
7925 Weergaven
 self.env['product.product'].with_context(warehouse=self.warehouse_id.id)
self.env['product.product'].search([('warehouse_id', '=', self.warehouse_id.id)]))
Avatar
Annuleer
Beste antwoord

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
Annuleer
Auteur

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

Auteur

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