Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to get price of a product from price list

By
Simon Lee
on 5/2/16, 7:45 AM 367 views

I am using price lists for the sales price of the products in my odoo set up. The price lists are working. Now, when opening a product form, I would like to show the "Sale Price" (list_price) of the product by getting it through my price lists so that when I update my sales price lists, the "Sale Price" field in the product form will automatically show the updated sales price (getting from the updated price lists). I cannot figure out how to do it.

Here's the code I tried:

from openerp import models, fields, api
from addons.decimal_precision import decimal_precision as dp
class my_product_template(models.Model):
     _name='product.template'
     _inherit='product.template'
    @api.one
    @api.depends('list_price')
    def _set_sales_price(self):
         self.list_price = [not sure how to write this part???]
   
    list_price=fields.Float('Sale Price', compute='_set_sales_price', digits_compute=dp.get_precision('Product Price'),
            help="Base price to compute the customer price. Sometimes called the catalog price.")


i have the following questions:

1) Is the above the right way to overwrite an existing field (list_price) in product.template?

2) Please advise how to write the part [not sure how to write this part???]. I tried to find how to do this in odoo's source code and found something like

self.pool.get('product.pricelist').price_get(...)

but cannot figure out what I should put for the parameters when calling price_get.

Thank you.

Simon Lee

 

}



Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/2/16, 7:45 AM
Seen: 367 times
Last updated: 5/2/16, 8:17 AM