2014-12-04 14:08:29 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
from netforce.model import Model, fields
|
|
|
|
|
|
|
|
class HDCaseExpense(Model):
|
|
|
|
_name="clinic.hd.case.expense"
|
|
|
|
_string="Expense"
|
|
|
|
_name_field="date"
|
|
|
|
_fields={
|
2014-12-04 15:26:20 +00:00
|
|
|
'date': fields.Date("Date",search=True),
|
|
|
|
'patient_id': fields.Many2One("clinic.patient","Patient",search=True),
|
|
|
|
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case",search=True),
|
|
|
|
'invoice_id': fields.Many2One("account.invoice","Invoice",search=True),
|
|
|
|
'payment_id': fields.Many2One("account.payment","Payment",search=True),
|
2014-12-04 14:08:29 +00:00
|
|
|
'amount': fields.Float("Amount"),
|
2014-12-04 15:26:20 +00:00
|
|
|
'state': fields.Selection([['draft','Draft'],['waiting_matching','Waiting Matching'],['match','Match'],['unmatch','Unmatch'],['approved','Approved']],'State'),
|
2014-12-04 14:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_defaults={
|
|
|
|
'state': 'draft',
|
|
|
|
'date': time.strftime("%Y-%m-%d"),
|
|
|
|
}
|
|
|
|
|
|
|
|
_order="date desc"
|
|
|
|
|
|
|
|
def approve(self,ids,context={}):
|
|
|
|
obj=self.browse(ids)[0]
|
|
|
|
obj.write({
|
|
|
|
'state': 'approved',
|
|
|
|
})
|
|
|
|
|
|
|
|
def to_draft(self,ids,context={}):
|
|
|
|
obj=self.browse(ids)[0]
|
|
|
|
obj.write({
|
|
|
|
'state': 'draft',
|
|
|
|
})
|
|
|
|
|
2014-12-04 15:26:20 +00:00
|
|
|
def delete(self,ids,context={}):
|
|
|
|
for obj in self.browse(ids):
|
|
|
|
if obj.state!='draft':
|
|
|
|
raise Exception("Status is not draft!")
|
|
|
|
super().delete(ids,context)
|
|
|
|
|
|
|
|
def do_match(self,ids,context={}):
|
|
|
|
obj=self.browse(ids)[0]
|
|
|
|
obj.write({
|
|
|
|
'state': 'match',
|
|
|
|
})
|
|
|
|
|
|
|
|
def do_unmatch(self,ids,context={}):
|
|
|
|
obj=self.browse(ids)[0]
|
|
|
|
obj.write({
|
|
|
|
'state': 'unmatch',
|
|
|
|
})
|
|
|
|
|
|
|
|
def cancel(self,ids,context={}):
|
|
|
|
obj=self.browse(ids)[0]
|
|
|
|
obj.write({
|
|
|
|
'state': 'cancelled',
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2014-12-04 14:08:29 +00:00
|
|
|
HDCaseExpense.register()
|