Hello, I've seen multiple posts where it's answered how to get OnHand quantity on a warehouse within python code, but I want to know how to get it using the External API, can you give me a hint?
Thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello, I've seen multiple posts where it's answered how to get OnHand quantity on a warehouse within python code, but I want to know how to get it using the External API, can you give me a hint?
Thanks
Hi,
Please try the following code.
@http.route('/stock', auth='user')Regards
def stock(self, **kw):
product = request.env['product.template'].search([('id', '=', kw['product_id'])])
warehouse = request.env['stock.warehouse'].search([])
stock = []
for variant in products.product_variant_ids:
"""Looping through the product variants"""
wh_qty = {}
for j in warehouse:
wh_qty[j.name] = variant.with_context(
{'warehouse': j.id}).qty_available
"""Getting the qty from the current warehouse"""
item = {
'size': variant.attribute_value_ids.name,
'total': variant.qty_available,
}
for k in wh_qty:
item[k] = wh_qty[k]
stock.append(item)
return Response(json.dumps(stock))
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
2
jan. 23
|
3448 | ||
|
0
mrt. 22
|
1562 | ||
|
1
jul. 21
|
2725 | ||
|
1
mrt. 21
|
3756 | ||
|
1
dec. 20
|
2245 |
@Cybrosys how would i call that from the external API? external API uses RPC, but afaik this adds an endpoint to be consumed with HTTP