2014-10-26 08:48:51 +00:00
|
|
|
import time
|
|
|
|
|
2014-11-01 08:49:27 +00:00
|
|
|
from netforce.model import Model, fields
|
2014-10-26 08:48:51 +00:00
|
|
|
from netforce.access import get_active_company
|
|
|
|
|
|
|
|
class CycleItem(Model):
|
|
|
|
_name="clinic.cycle.item"
|
|
|
|
_string="Cycle Item"
|
2014-10-26 10:11:19 +00:00
|
|
|
_name_field="name"
|
2014-10-26 08:48:51 +00:00
|
|
|
|
|
|
|
def _get_all(self,ids,context):
|
|
|
|
res={}
|
|
|
|
for obj in self.browse(ids):
|
2014-10-26 10:11:19 +00:00
|
|
|
name="%s-%s"%(obj.cycle_id.name,obj.date)
|
2014-10-26 08:48:51 +00:00
|
|
|
res[obj.id]={
|
2014-10-26 10:11:19 +00:00
|
|
|
'name': name,
|
2014-10-26 08:48:51 +00:00
|
|
|
}
|
|
|
|
return res
|
|
|
|
|
|
|
|
_fields={
|
2014-10-26 10:11:19 +00:00
|
|
|
'name': fields.Char("Name", function="_get_all",function_multi=True), # need to field related in journal
|
2014-10-26 08:48:51 +00:00
|
|
|
'company_id': fields.Many2One("company", "Company"),
|
|
|
|
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
|
|
|
|
'date': fields.Date("Date",search=True),
|
|
|
|
"state": fields.Selection([("draft","Draft"),("done","Done")],"Status",required=True),
|
|
|
|
'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"),
|
2014-11-01 08:49:27 +00:00
|
|
|
'visits': fields.One2Many("clinic.visit","cycle_item_id", "Visits"),
|
2014-10-26 08:48:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_defaults={
|
|
|
|
'state': 'draft',
|
|
|
|
'company_id': lambda *a: get_active_company(),
|
|
|
|
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
|
|
|
}
|
|
|
|
|
2014-11-01 17:30:48 +00:00
|
|
|
_order="date asc"
|
|
|
|
|
2014-10-26 08:48:51 +00:00
|
|
|
CycleItem.register()
|