2014-12-09 07:29:30 +00:00
|
|
|
from netforce.model import Model, fields, get_model
|
2014-12-08 11:35:39 +00:00
|
|
|
from netforce.access import get_active_company
|
|
|
|
|
|
|
|
class LaborCostLine(Model):
|
|
|
|
_name="clinic.labor.cost.line"
|
2014-12-09 00:11:39 +00:00
|
|
|
_string="Labor Cost Item"
|
2014-12-08 11:35:39 +00:00
|
|
|
_name_field="labor_cost_id"
|
|
|
|
|
|
|
|
_fields={
|
2015-01-18 10:31:54 +00:00
|
|
|
"labor_cost_id": fields.Many2One("clinic.labor.cost","Cycle Item",required=True,on_delete="cascade"),
|
2014-12-09 07:29:30 +00:00
|
|
|
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Type",required=True,search=True),
|
2014-12-09 00:11:39 +00:00
|
|
|
'staff_id': fields.Many2One("clinic.staff", "Staff",search=True),
|
|
|
|
'level_id': fields.Many2One("clinic.staff.level", "Level",search=True),
|
|
|
|
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
|
2015-01-19 16:11:57 +00:00
|
|
|
'qty': fields.Integer("#HDCase"),
|
2014-12-08 14:54:25 +00:00
|
|
|
'rate': fields.Float("Rate",scale=2),
|
2014-12-08 11:35:39 +00:00
|
|
|
'amount': fields.Float("Amount",scale=2),
|
2014-12-09 00:11:39 +00:00
|
|
|
'date': fields.Date("Date",search=True),
|
2014-12-09 07:29:30 +00:00
|
|
|
'description': fields.Char("Description"),
|
2014-12-08 11:35:39 +00:00
|
|
|
'company_id': fields.Many2One('company','Company'),
|
2015-02-08 08:48:08 +00:00
|
|
|
'categ_id': fields.Many2One("clinic.staff.categ", "Category",domain=[['type','=','nurse']],search=True),
|
2014-12-08 11:35:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_defaults={
|
|
|
|
"company_id": lambda *a: get_active_company(),
|
|
|
|
}
|
2014-12-08 14:54:25 +00:00
|
|
|
|
|
|
|
_order="cycle_id,level_id"
|
2014-12-09 07:29:30 +00:00
|
|
|
|
|
|
|
def create(self,vals,**kw):
|
|
|
|
staff_id=vals['staff_id']
|
|
|
|
staff=get_model("clinic.staff").browse(staff_id)
|
|
|
|
if staff.type=='doctor':
|
|
|
|
vals['type']='doctor'
|
|
|
|
elif staff.type=='nurse':
|
|
|
|
vals['type']='nurse'
|
|
|
|
else:
|
|
|
|
vals['type']='staff'
|
|
|
|
new_id=super().create(vals,**kw)
|
|
|
|
return new_id
|
2014-12-08 11:35:39 +00:00
|
|
|
|
|
|
|
LaborCostLine.register()
|