clinic/netforce_clinic/models/hd_case_expense.py

41 lines
1.1 KiB
Python
Raw Normal View History

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={
'date': fields.Date("Date"),
'patient_id': fields.Many2One("clinic.patient","Patient"),
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case"),
'invoice_id': fields.Many2One("account.invoice","Invoice"),
'payment_id': fields.Many2One("account.payment","Payment"),
'amount': fields.Float("Amount"),
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
'match': fields.Boolean("Match"),
}
_defaults={
'state': 'draft',
'date': time.strftime("%Y-%m-%d"),
'match': False,
}
_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',
})
HDCaseExpense.register()