I can retrieve product.pricelist, but this returns only the price lists. How do I get to the actual products and their price level prices?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
How to get product prices via JSON API in Odoo
The usual approach is:
- Use the product.pricelist to get pricelist IDs.
- Use the product.product to get product IDs.
- Call a method on the pricelist to compute the price for each product.
Key Odoo method to compute prices
product.pricelist model has a method named:
_get_product_price_rule(product, qty, partner)
or more generally:
get_product_price(product_id, quantity=1.0, partner=None)
which returns the computed price for the product in that pricelist.
Via JSON API (RPC) you can do this:
You can call the get_product_price method on product.pricelist records, passing the product ID and quantity.
Example JSON-RPC call to get product prices
Step 1 : Get pricelist IDs
{ "jsonrpc": "2.0", "method": "call", "params": { "model": "product.pricelist", "method": "search", "args": [[["active", "=", true]]], "kwargs": {} }, "id": 1 }
Step 2 : Get product IDs
{ "jsonrpc": "2.0", "method": "call", "params": { "model": "product.product", "method": "search", "args": [[["sale_ok", "=", true]]], "kwargs": {"limit": 10} }, "id": 2 }
Step 3 : Call pricelist method to get price for product
{ "jsonrpc": "2.0", "method": "call", "params": { "model": "product.pricelist", "method": "get_product_price", "args": [ [pricelist_id], // list of pricelist ids (typically 1) product_id, // id of the product 1.0, // quantity false // no partner context for now ], "kwargs": {} }, "id": 3 }
This returns the computed price for the product in the pricelist.
Python example calling from XML-RPC
price = models.execute_kw(db, uid, password, 'product.pricelist', 'get_product_price', [[pricelist_id], product_id, 1.0, False]) print(price)
Thanks & Regards,
Email: contact@datainteger.com
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
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 | |
---|---|---|---|---|
|
1
aug. 25
|
400 | ||
|
2
jul. 25
|
2835 | ||
|
3
jul. 25
|
641 | ||
|
1
jun. 25
|
2109 | ||
Original project names via the API
Opgelost
|
|
1
apr. 25
|
1664 |
This is just what I needed. Thank you!