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
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
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
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
2
Aug 25
|
288 | ||
|
2
Jul 25
|
2746 | ||
|
3
Jul 25
|
568 | ||
|
1
Jun 25
|
2023 | ||
|
1
Apr 25
|
1612 |
This is just what I needed. Thank you!