2014-12-15 17:46:43 +00:00
|
|
|
from datetime import datetime
|
|
|
|
|
2014-11-27 15:14:31 +00:00
|
|
|
from netforce.model import Model, fields
|
|
|
|
|
|
|
|
class PeriodLine(Model):
|
|
|
|
_name="clinic.period.line"
|
|
|
|
_string="Period Line"
|
2014-12-15 17:46:43 +00:00
|
|
|
|
|
|
|
def _get_total(self,ids,context={}):
|
|
|
|
res={}
|
|
|
|
fmt='%Y-%m-%d'
|
|
|
|
for obj in self.browse(ids):
|
|
|
|
start=datetime.strptime(obj.date_start,fmt)
|
|
|
|
stop=datetime.strptime(obj.date_stop,fmt)
|
|
|
|
days=(stop-start).days
|
|
|
|
res[obj.id]=days
|
|
|
|
return res
|
2014-11-27 15:14:31 +00:00
|
|
|
|
|
|
|
_fields={
|
|
|
|
"period_id": fields.Many2One("clinic.period", "Period"),
|
2014-12-15 17:46:43 +00:00
|
|
|
'date_start': fields.Date("Date Start"),
|
|
|
|
'date_stop': fields.Date("Date Stop"),
|
|
|
|
'day_total': fields.Integer("Total Day",function="_get_total"),
|
2014-11-27 15:14:31 +00:00
|
|
|
'state': fields.Selection([['draft','Draft'],['done','Done']],"State"),
|
2014-12-15 17:46:43 +00:00
|
|
|
'close': fields.Boolean("Close"),
|
2014-11-27 15:14:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_defaults={
|
|
|
|
'state': 'draft',
|
2014-12-15 17:46:43 +00:00
|
|
|
'close': False,
|
2014-11-27 15:14:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PeriodLine.register()
|