from netforce.model import Model, fields class MatchingPaymentGroupLine(Model): _name="clinic.matching.payment.group.line" _string="Matching Payment Group Line" def _get_all(self,ids,context={}): res={} for obj in self.browse(ids): fee=obj.fee or 0 epo=obj.epo or 0 srv=obj.srv or 0 amount=fee+epo+srv res[obj.id]={ 'amount': amount, } return res _fields={ 'group_matching_id': fields.Many2One("clinic.matching.payment.group","Group Matching",required=True,on_delete="cascade"), 'matching_id': fields.Many2One("clinic.matching.payment","Group Matching"), 'fee': fields.Float("Fee"), 'srv': fields.Float("Service"), 'epo': fields.Float("EPO"), 'amount': fields.Float("Amount", function="_get_all", function_multi=True), } MatchingPaymentGroupLine.register()