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

Displaying price of product

By
charlesraj
on 6/3/13, 9:28 AM 586 views

hi i created a module it has two fields product and price. My need is to display the price in the price field when i select the product . Any one please give the corresponding code for this in python.. Thanks in advance...

0
Clément THOMAS
On 6/3/13, 12:55 PM

First way :

  1. your price field can be fields.function(_get_price_from_product...) (read documentation about it)
  2. Add an on_change event in your module view on the product field (read also documentation about it)
  3. This on_change function can call directly the _get_price_from_product function to return the good price.

Second way :

  1. Your price field can be a fields.related('product_id', 'list_price', ...) (read doc)
  2. I think depending your version, it will be re-calculated automaticaly when product_id change (to check). Else Do the same as previous 2. and 3..

Last way :

  1. If you want to change price independently than the product price, price must be a fields.float()
  2. In on_change method of product field, change the price

Good luck

thank... for information.

charlesraj
on 6/4/13, 6:07 AM

i have made this but selcting product will cause an error like this........Client Traceback (most recent call last): File "C:\Program Files\OpenERP 7.0-20130509-231040\Server\server\openerp\addons\web\http.py", line 204, in dispatch File "C:\Program Files\OpenERP 7.0-20130509-231040\Server\server\openerp\addons\web\controllers\main.py", line 1129, in call_kw Server Traceback (most recent call last): File "C:\Program Files\OpenERP 7.0-20130509-231040\Server\server\openerp\addons\web\session.py", line 90, in send AttributeError: 'test_base' object has no attribute 'onchange_code'...

charlesraj
on 6/4/13, 7:24 AM

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

0 follower(s)

Stats

Asked: 6/3/13, 9:28 AM
Seen: 586 times
Last updated: 3/16/15, 8:10 AM