refactor
parent
28d405bf73
commit
35c1f4d516
|
@ -20,7 +20,9 @@
|
|||
</list>
|
||||
</field>
|
||||
</tab>
|
||||
<tab string="Other">
|
||||
<tab string="Others">
|
||||
</tab>
|
||||
<tab string="Validation">
|
||||
<field name="user_id"/>
|
||||
<field name="cycle_daily_id" domain="[['date','=',date]]"/>
|
||||
</tab>
|
||||
|
|
|
@ -97,6 +97,7 @@
|
|||
</list>
|
||||
</field>
|
||||
<group span="9" form_layout="stacked">
|
||||
<field name="cycle_item_id"/>
|
||||
</group>
|
||||
<group span="3" columns="1">
|
||||
</group>
|
||||
|
|
|
@ -33,11 +33,12 @@
|
|||
<field name="total" span="6" offset="6"/>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Staff Earning">
|
||||
<field name="lines" nolabel="1">
|
||||
<tab string="Nurses">
|
||||
<field name="nurse_lines" nolabel="1">
|
||||
<list>
|
||||
<field name="cycle_id"/>
|
||||
<field name="staff_id"/>
|
||||
<field name="staff_id" domain="[['type','=','nurse']]"/>
|
||||
<field name="description"/>
|
||||
<field name="level_id"/>
|
||||
<field name="qty" onchange="onchange_cost_line"/>
|
||||
<field name="rate" onchange="onchange_cost_line"/>
|
||||
|
@ -46,13 +47,60 @@
|
|||
<form>
|
||||
<field name="cycle_id"/>
|
||||
<field name="staff_id"/>
|
||||
<field name="description"/>
|
||||
<field name="level_id"/>
|
||||
<field name="qty"/>
|
||||
<field name="rate"/>
|
||||
<field name="amount"/>
|
||||
</form>
|
||||
</field>
|
||||
<field name="total_cost" span="3" offset="9"/>
|
||||
<field name="total_ncost" span="3" offset="9"/>
|
||||
</tab>
|
||||
<tab string="Doctors">
|
||||
<field name="doctor_lines" nolabel="1">
|
||||
<list>
|
||||
<field name="cycle_id"/>
|
||||
<field name="staff_id" domain="[['type','=','doctor']]"/>
|
||||
<field name="description"/>
|
||||
<field name="level_id"/>
|
||||
<field name="qty" onchange="onchange_cost_line"/>
|
||||
<field name="rate" onchange="onchange_cost_line"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
<form>
|
||||
<field name="cycle_id"/>
|
||||
<field name="staff_id"/>
|
||||
<field name="description"/>
|
||||
<field name="level_id"/>
|
||||
<field name="qty"/>
|
||||
<field name="rate"/>
|
||||
<field name="amount"/>
|
||||
</form>
|
||||
</field>
|
||||
<field name="total_dcost" span="3" offset="9"/>
|
||||
</tab>
|
||||
<tab string="Others">
|
||||
<field name="staff_lines" nolabel="1">
|
||||
<list>
|
||||
<field name="cycle_id"/>
|
||||
<field name="staff_id" domain="[['type','=','staff']]"/>
|
||||
<field name="description"/>
|
||||
<field name="level_id"/>
|
||||
<field name="qty" onchange="onchange_cost_line"/>
|
||||
<field name="rate" onchange="onchange_cost_line"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
<form>
|
||||
<field name="cycle_id"/>
|
||||
<field name="staff_id"/>
|
||||
<field name="description"/>
|
||||
<field name="level_id"/>
|
||||
<field name="qty"/>
|
||||
<field name="rate"/>
|
||||
<field name="amount"/>
|
||||
</form>
|
||||
</field>
|
||||
<field name="total_stcost" span="3" offset="9"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
<foot>
|
||||
|
|
|
@ -31,6 +31,7 @@ from . import dialyzer
|
|||
from . import cycle
|
||||
from . import cycle_item
|
||||
from . import cycle_item_nurse
|
||||
from . import cycle_item_other
|
||||
from . import cycle_item_line
|
||||
from . import cycle_daily
|
||||
from . import cycle_daily_line
|
||||
|
|
|
@ -137,12 +137,18 @@ class CycleItem(Model):
|
|||
schedule_id=None
|
||||
if schd_ids:
|
||||
schedule_id=schd_ids[0]
|
||||
if not schedule_id:
|
||||
schedule_id=get_model('clinic.schedule').create({
|
||||
'date': date,
|
||||
'time_start': '%s 08:00:00'%date, #XXX
|
||||
'time_stop': '%s 21:00:00'%date, #XXX
|
||||
})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_schedule',
|
||||
'mode': 'form',
|
||||
'active_id': schedule_id,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
def view_cycle_daily(self,ids,context={}):
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company
|
||||
|
||||
class CycleItemOther(Model):
|
||||
_name="clinic.cycle.item.other"
|
||||
_string="Cycle Item Other"
|
||||
|
||||
_fields={
|
||||
'cycle_item_id': fields.Many2One("clinic.cycle.item", "Cycle Item",required=True),
|
||||
'level_id': fields.Many2One("clinic.staff.level", "Level",),
|
||||
'staff_id': fields.Many2One("clinic.staff",'Staff'),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
}
|
||||
|
||||
CycleItemOther.register()
|
|
@ -108,7 +108,7 @@ class HDCase(Model):
|
|||
'note': fields.Text("Note"),
|
||||
'complication': fields.Text("Complication"),
|
||||
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
||||
'cycle_item_id': fields.Many2One("clinic.cycle.item","Nurse Schedule"), # on_delete="cascade" -> will rm visit from cycle item
|
||||
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), # on_delete="cascade" -> will rm visit from cycle item
|
||||
'pay_amount': fields.Float("Amount",function="_get_pay_amount"),
|
||||
'pay_date': fields.Date("Pay Date"),
|
||||
'pay_account_id': fields.Many2One("account.account","Account"),
|
||||
|
@ -213,7 +213,13 @@ class HDCase(Model):
|
|||
data['fee_partner_id']=None
|
||||
data['patient_type']=patient.type_id.name or ""
|
||||
data['dialyzers']=[]
|
||||
|
||||
doctor=patient.doctor_id
|
||||
data['staffs']=[] # XXX
|
||||
data['staffs'].append({
|
||||
'staff_id': doctor.id,
|
||||
'type': 'doctor',
|
||||
'priop': 'owner',
|
||||
})
|
||||
return data
|
||||
|
||||
def onchange_line(self,context={}):
|
||||
|
|
|
@ -7,7 +7,7 @@ class HdCaseStaff(Model):
|
|||
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
|
||||
"staff_id": fields.Many2One("clinic.staff","Staff",search=True),
|
||||
"type": fields.Selection([("doctor","Doctor"),('nurse','Nurse'),("staff","Staff")],"Type",required=True),
|
||||
"priop": fields.Selection([("owner","Owner"),('second','Second')],"Priority"),
|
||||
"priop": fields.Selection([("owner","Owner"),('second','Secondary'),('other','Other')],"Priority"),
|
||||
'note': fields.Char("Note"),
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,17 @@ class LaborCost(Model):
|
|||
if total_a:
|
||||
var_x=eval('(%s%s)/%s'%(var_ptx,total_bstr,total_a))
|
||||
|
||||
total_cost=0.0
|
||||
for line in obj.lines:
|
||||
total_cost+=line.amount or 0.0
|
||||
total_ncost=0.0
|
||||
for line in obj.nurse_lines:
|
||||
total_ncost+=line.amount or 0.0
|
||||
|
||||
total_dcost=0.0
|
||||
for line in obj.doctor_lines:
|
||||
total_dcost+=line.amount or 0.0
|
||||
|
||||
total_stcost=0.0
|
||||
for line in obj.staff_lines:
|
||||
total_stcost+=line.amount or 0.0
|
||||
|
||||
res[obj.id]={
|
||||
'var_pt': total_case,
|
||||
|
@ -39,7 +47,9 @@ class LaborCost(Model):
|
|||
'var_fml3': '(%s%s)/%s'%(var_ptx,total_bstr,total_a),
|
||||
'var_x': round(var_x,2),
|
||||
'total': total,
|
||||
'total_cost': total_cost,
|
||||
'total_ncost': total_ncost,
|
||||
'total_dcost': total_dcost,
|
||||
'total_stcost': total_stcost,
|
||||
}
|
||||
|
||||
return res
|
||||
|
@ -54,11 +64,14 @@ class LaborCost(Model):
|
|||
'var_fml3': fields.Char("X:",function="_get_all",function_multi=True),
|
||||
'var_x': fields.Char("X:",function="_get_all",function_multi=True),
|
||||
'total': fields.Float("Total",function="_get_all",function_multi=True),
|
||||
'total_cost': fields.Float("Total",function="_get_all",function_multi=True),
|
||||
'total_ncost': fields.Float("Total",function="_get_all",function_multi=True),
|
||||
'total_dcost': fields.Float("Total",function="_get_all",function_multi=True),
|
||||
'total_stcost': fields.Float("Total",function="_get_all",function_multi=True),
|
||||
'manual': fields.Boolean("Manual"),
|
||||
"formulars": fields.One2Many("clinic.labor.cost.formular", "labor_cost_id", "Formulars"),
|
||||
"staffs": fields.One2Many("clinic.labor.cost.staff", "labor_cost_id", "Staffs"),
|
||||
"lines": fields.One2Many("clinic.labor.cost.line", "labor_cost_id", "Lines"),
|
||||
"nurse_lines": fields.One2Many("clinic.labor.cost.line", "labor_cost_id", "Nurse Lines",domain=[['type','=','nurse']]),
|
||||
"doctor_lines": fields.One2Many("clinic.labor.cost.line", "labor_cost_id", "Doctor Lines",domain=[['type','=','doctor']]),
|
||||
"staff_lines": fields.One2Many("clinic.labor.cost.line", "labor_cost_id", "staff Lines",domain=[['type','=','staff']]),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
}
|
||||
|
||||
|
@ -260,10 +273,13 @@ class LaborCost(Model):
|
|||
if not staff_total.get(staff.id):
|
||||
staff_total[staff.id]={
|
||||
'base': 0,
|
||||
'type': staff.type,
|
||||
'level_id': staff.level_id.id,
|
||||
'type': ps.type,
|
||||
'qty': 0,
|
||||
}
|
||||
if staff.type!='doctor':
|
||||
base=0
|
||||
staff_total[staff.id]['description']=hd_case.number
|
||||
staff_total[staff.id]['base']=base
|
||||
staff_total[staff.id]['qty']+=1
|
||||
|
||||
|
@ -279,10 +295,13 @@ class LaborCost(Model):
|
|||
'rate': base,
|
||||
'qty': qty,
|
||||
'type': type,
|
||||
'description': value.get('description',"")
|
||||
}))
|
||||
|
||||
# clear cost line
|
||||
for line in obj.lines:
|
||||
for line in obj.nurse_lines:
|
||||
line.delete()
|
||||
for line in obj.doctor_lines:
|
||||
line.delete()
|
||||
|
||||
# group staff and cycle date
|
||||
|
@ -298,16 +317,18 @@ class LaborCost(Model):
|
|||
if not key in glines.keys():
|
||||
glines[key]={
|
||||
'amount': amount,
|
||||
'type': vals['type'],
|
||||
'level_id': vals['level_id'],
|
||||
'rate': rate,
|
||||
'qty': qty,
|
||||
'type': vals['type'],
|
||||
'description': vals.get("description",""),
|
||||
}
|
||||
continue
|
||||
glines[key]['amount']+=amount
|
||||
glines[key]['qty']+=qty
|
||||
|
||||
lines=[]
|
||||
nurse_lines=[]
|
||||
doctor_lines=[]
|
||||
for key,vals in glines.items():
|
||||
cycle_id,staff_id=key
|
||||
line={
|
||||
|
@ -316,10 +337,15 @@ class LaborCost(Model):
|
|||
'date': item.date,
|
||||
}
|
||||
line.update(vals)
|
||||
lines.append(('create',line))
|
||||
st_type=vals['type']
|
||||
if st_type=='doctor':
|
||||
doctor_lines.append(('create',line))
|
||||
else:
|
||||
nurse_lines.append(('create',line))
|
||||
|
||||
obj.write({
|
||||
'lines': lines,
|
||||
'doctor_lines': doctor_lines,
|
||||
'nurse_lines': nurse_lines,
|
||||
})
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from netforce.model import Model, fields
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company
|
||||
|
||||
class LaborCostLine(Model):
|
||||
|
@ -8,14 +8,15 @@ class LaborCostLine(Model):
|
|||
|
||||
_fields={
|
||||
"labor_cost_id": fields.Many2One("clinic.labor.cost","Cycle Item",required=True),
|
||||
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Type",required=True,search=True),
|
||||
'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),
|
||||
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Type",search=True),
|
||||
'qty': fields.Integer("Qty"),
|
||||
'rate': fields.Float("Rate",scale=2),
|
||||
'amount': fields.Float("Amount",scale=2),
|
||||
'date': fields.Date("Date",search=True),
|
||||
'description': fields.Char("Description"),
|
||||
'company_id': fields.Many2One('company','Company'),
|
||||
}
|
||||
|
||||
|
@ -24,5 +25,17 @@ class LaborCostLine(Model):
|
|||
}
|
||||
|
||||
_order="cycle_id,level_id"
|
||||
|
||||
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
|
||||
|
||||
LaborCostLine.register()
|
||||
|
|
|
@ -46,11 +46,15 @@ class Schedule(Model):
|
|||
'state': fields.Selection([['draft','Draft'],['confirmed', 'Confirmed']],'State',search=True),
|
||||
'user_id': fields.Many2One("base.user","Confirm By"),
|
||||
}
|
||||
|
||||
def _get_date(self,context={}):
|
||||
datenow=datetime.now().strftime("%Y-%m-%d")
|
||||
return datenow
|
||||
|
||||
_defaults={
|
||||
'user_id': lambda *a: get_active_user(),
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
'date': lambda *a: datetime.now().strftime("%Y-%m-%d"),
|
||||
'date': _get_date,
|
||||
'time_start': lambda *a: datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||
'time_stop': lambda *a: (datetime.now()+timedelta(seconds=3600)).strftime("%Y-%m-%d %H:%M:%S"),
|
||||
'state': 'draft',
|
||||
|
|
Loading…
Reference in New Issue