Hello!
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,
}
hr_config_settings()
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?