Odoo Help


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.


Problem with calling object from other module

Serket Serket
on 8/13/13, 10:27 AM 656 views


I've recently started working with OpenERP, I'm also new to Python and XML.

I have problem with calling value configured in one .py file from another .py. Both are in one module. First one is adding some new float fields to HR module configuration file -> res_config.py:

from openerp.osv import fields, osv

class hr_config_settings(osv.osv_memory): _inherit = 'hr.config.settings'

_columns = {
    'hr_kmless_value': fields.float('Value when less than 900km', digits=(1,4)),
    'hr_kmmore_value': fields.float('Value when more than 900km', digits=(1,4)),
    'hr_breakfast_value': fields.float('Value of breakfast'),
    'hr_lunch_value': fields.float('Value of lunch'),
    'hr_dinner_value': fields.float('Value of dinner'),
_defaults = {
    'hr_kmless_value': 0.5214,
    'hr_kmmore_value': 0.8358,
    'hr_breakfast_value': 0.25,
    'hr_lunch_value': 0.5,
    'hr_dinner_value': 0.25,


Until this point everything works fine - xml is right, fields are visible and I see values when browsing PostgreSQL

I need use all of above values in other .py file created by former worker to count something. To be specific - I need to replace constant values with values configured in res_config.py. One of the lines is:

(a) result[prod.id] = prod.kilomtr * 0.5214

I imported res_config file and changed it to:

(b) result[prod.id] = prod.kilomtr * res_config.hr_config_settings._columns['hr_kmless_value']

but it gets me error: "TypeError: unsupported operand type(s) for *: 'float' and 'float' ". With (a) everything works perfect.

My questions is: Am I calling it right? If no, what will be correct way?

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)


Asked: 8/13/13, 10:27 AM
Seen: 656 times
Last updated: 3/16/15, 8:10 AM