in a many2many field i try to get the sum of a column but it still 0, her s my code ;
in my classe : hr.expense.expense:
.........
def _get_expense_from_linemm(self, cr, uid, ids, context=None):
return [line.expense1_id.id for line in self.pool.get('hr.expense.line').browse(cr, uid, ids, context=context)]
def _amountmm(self, cr, uid, ids, field_name, arg, context=None):
res= {}
for expense in self.browse(cr, uid, ids, context=context):
total = 0.0
for line in expense.line_ids:
total += line.unit_amount * line.unit_quantity
res[expense.id] = total
return res
........
_column{
.......
'line1_ids': fields.many2many('hr.expense.line','hr_expense_rap','expenses_id','expense_line_id', string='expense'),
'amountmm': fields.function(_amountmm, string='Total Amount', digits_compute=dp.get_precision('Account'),
store={
'hr.expense.line': (_get_expense_from_linemm, ['unit_amount','unit_quantity'], 10)
}),
..........
}
in my class hr.expense.line :
_column{
'expense1_id': fields.many2many('hr.expense.expense','hr_expense_rap','expense_line_id','expenses_id', string='expense'),
}
any idea