clinic/netforce_clinic/models/cycle_dialy.py

28 lines
784 B
Python
Raw Normal View History

2014-11-17 00:59:19 +00:00
import time
from netforce.model import Model, fields
from netforce.access import get_active_company
class CycleDialy(Model):
_name="clinic.cycle.dialy"
2014-11-21 02:39:26 +00:00
_string="Cycle Dialy"
2014-11-17 00:59:19 +00:00
_fields={
"name": fields.Char("Name"),
'date': fields.Date("Date", required=True, search=True),
'cycle_items': fields.One2Many("clinic.cycle.item","cycle_dialy_id", "Cycle Items"),
'company_id': fields.Many2One("company","Company"),
}
_defaults={
'company_id': lambda *a: get_active_company(),
'date': lambda *a: time.strftime("%Y-%m-%d"),
'name': lambda *a: time.strftime("%Y-%m-%d"),
}
def write(self,ids,vals,**kw):
vals['name']=vals['date']
super().write(ids,vals,**kw)
CycleDialy.register()