42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
|
from netforce.model import Model, fields, get_model
|
||
|
|
||
|
class ImportUC(Model):
|
||
|
_name="clinic.import.uc"
|
||
|
_transient=True
|
||
|
|
||
|
_fields={
|
||
|
"payment_id": fields.Many2One("account.payment","Payment",required=True,on_delete="cascade"),
|
||
|
"file": fields.File("File", required=True),
|
||
|
'type_id': fields.Many2One("clinic.patient.type","Type", required=True),
|
||
|
}
|
||
|
|
||
|
def _get_payment_id(self,context={}):
|
||
|
payment_id=context.get("refer_id")
|
||
|
if not payment_id:
|
||
|
return None
|
||
|
return int(payment_id)
|
||
|
|
||
|
def _get_type(self,context={}):
|
||
|
st=get_model("clinic.setting").browse(1)
|
||
|
return st.imp_patient_type_id.id
|
||
|
|
||
|
_defaults={
|
||
|
'payment_id': _get_payment_id,
|
||
|
'type_id': _get_type,
|
||
|
}
|
||
|
|
||
|
def do_import(self,ids,context):
|
||
|
obj=self.browse(ids)[0]
|
||
|
|
||
|
return {
|
||
|
'next': {
|
||
|
'name': 'payment',
|
||
|
'mode': 'form',
|
||
|
'active_id': obj.payment_id.id,
|
||
|
},
|
||
|
'flash': 'Import successfully',
|
||
|
}
|
||
|
|
||
|
ImportUC.register()
|
||
|
|