46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
from netforce.model import Model, fields, get_model
|
|
|
|
class MatchingPayment(Model):
|
|
_name="clinic.matching.payment"
|
|
_transient=True
|
|
|
|
_fields={
|
|
'file': fields.File("File"),
|
|
'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type",required=True),
|
|
'hcode_id': fields.Many2One("clinic.hospital","HCode",required=True),
|
|
'expenes': fields.Many2Many("clinic.hd.case.expense","Expenses"),
|
|
}
|
|
|
|
def _get_ptype(self,context={}):
|
|
tids=get_model('clinic.patient.type').search([['default','=',True]])
|
|
tid=None
|
|
if tids:
|
|
tid=tids[0]
|
|
return tid
|
|
|
|
_defaults={
|
|
'patient_type_id': _get_ptype,
|
|
}
|
|
|
|
def match(self,ids,context={}):
|
|
obj=self.browse(ids)[0]
|
|
for exp in obj.expenes:
|
|
exp.delete()
|
|
exp_ids=[]
|
|
for exp in get_model('clinic.hd.case.expense').search_browse([]):
|
|
exp_ids.append(exp.id)
|
|
#TODO Checking
|
|
obj.write({
|
|
'expenes': [('add',exp_ids)]
|
|
})
|
|
return {
|
|
'next': {
|
|
'name': 'clinic_matching_payment',
|
|
'mode': 'form',
|
|
'active_id': obj.id,
|
|
},
|
|
'flash': 'Succesfully',
|
|
}
|
|
|
|
MatchingPayment.register()
|