clinic/netforce_clinic/models/cycle_dialy.py

28 lines
783 B
Python

import time
from netforce.model import Model, fields
from netforce.access import get_active_company
class CycleDialy(Model):
_name="clinic.cycle.dialy"
_string="Cycle Diay"
_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()