I need sum the field "Hours" of all lines on a treeview and store the result in other field ("total_hours") on main table. The main Table have a one2many field linked to second table (treeview).
How can i do this?
Main Table:
class main_table(osv.osv):
_name = 'sat.main'
_columns = {
'name' : fields.char('name', size=256, required=True),
'total_hours' : fields.float('Producto'),
'hours_id': fields.one2many('sat.hours', 'hour_id', 'Horas'),
}
Second Table:
class hours(osv.osv):
_name = 'sat.hours'
_columns = {
'hour_id': fields.many2one('sat.main', 'mainwork'),
'concept': fields.char('Concept', size=128, required=True),
'hours': fields.float('hours'),
}