Odoo Help


Problem with calling object from other module

Serket Serket
on 8/13/13, 10:27 AM 1,088 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?

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


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