clinic/netforce_clinic/models/cycle_monthly_line.py

37 lines
1.2 KiB
Python

import time
from netforce.model import Model, fields
from netforce.access import get_active_company
class CycleMonthlyLine(Model):
_name="clinic.cycle.monthly.line"
_string="Cycle Monthly Line"
def _get_max_cycle(self,ids,context={}):
res={}
for obj in self.browse(ids):
staff=obj.staff_id
res[obj.id]=staff.max_cycle
return res
_fields={
"cycle_monthly_id": fields.Many2One("clinic.cycle.monthly","Cycle Monthly"),
'staff_id': fields.Many2One("clinic.staff", "Staff"),
'level_id': fields.Many2One("clinic.staff.level", "Level"),
'date': fields.Date("Date"),
'qty': fields.Integer("Qty"),
'rate': fields.Float("Rate"),
'amount': fields.Float("Amount"),
'company_id': fields.Many2One("company","Company"),
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Type",required=True),
'max_cycle': fields.Float('Max Cycle',function="_get_max_cycle"),
}
_defaults={
'company_id': lambda *a: get_active_company(),
'date': lambda *a: time.strftime("%Y-%m-%d"),
}
CycleMonthlyLine.register()