cycle item
parent
e129ccf370
commit
90cc5bcf8f
|
@ -12,14 +12,20 @@
|
|||
<list>
|
||||
<field name="cycle_id"/>
|
||||
<field name="personal_id"/>
|
||||
<field name="level_id"/>
|
||||
<field name="type"/>
|
||||
<field name="paid_amount"/>
|
||||
<field name="qty"/>
|
||||
<field name="rate"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
<form>
|
||||
<field name="cycle_id"/>
|
||||
<field name="personal_id"/>
|
||||
<field name="level_id"/>
|
||||
<field name="type"/>
|
||||
<field name="paid_amount"/>
|
||||
<field name="qty"/>
|
||||
<field name="rate"/>
|
||||
<field name="amount"/>
|
||||
</form>
|
||||
</field>
|
||||
<group span="12">
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
<head>
|
||||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="Compute Labor Cost" method="compute"/>
|
||||
<item string="Load Nurses" method="load_nurse_from_schedule" states='draft'/>
|
||||
<item string="Compute Labor Cost" method="compute" states='draft'/>
|
||||
<item string="View Schedule" method="view_schedule"/>
|
||||
</button>
|
||||
</head>
|
||||
|
|
|
@ -12,7 +12,7 @@ class CycleDialy(Model):
|
|||
for obj in self.browse(ids):
|
||||
total=0.0
|
||||
for line in obj.lines:
|
||||
total+=(line.paid_amount or 0)
|
||||
total+=(line.amount or 0)
|
||||
res[obj.id]={
|
||||
'total': total,
|
||||
}
|
||||
|
|
|
@ -9,7 +9,10 @@ class CycleDialyLine(Model):
|
|||
"cycle_dialy_id": fields.Many2One("clinic.cycle.dialy","Cycle Dialy"),
|
||||
'cycle_id': fields.Many2One("clinic.cycle", "Cycle"),
|
||||
'personal_id': fields.Many2One("clinic.personal", "Personal"),
|
||||
'paid_amount': fields.Float("Paid Amount"),
|
||||
'level_id': fields.Many2One("clinic.personal.level", "Level"),
|
||||
'qty': fields.Integer("Qty"),
|
||||
'rate': fields.Float("Rate"),
|
||||
'amount': fields.Float("Amount"),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
"type": fields.Selection([("doctor","Doctor"),('nurse','Nurse'),("personal","Personal")],"Type",required=True),
|
||||
}
|
||||
|
|
|
@ -129,8 +129,10 @@ class CycleItem(Model):
|
|||
lines.append(('create',{
|
||||
'cycle_id': obj.cycle_id.id,
|
||||
'personal_id': nurse.id,
|
||||
'paid_amount': levels[level.id] or 0.0,
|
||||
'level_id': nurse.level_id.id,
|
||||
'rate': levels[level.id] or 0.0,
|
||||
'type': 'nurse',
|
||||
'qty': 1,
|
||||
}))
|
||||
|
||||
# cost's doctor
|
||||
|
@ -147,17 +149,24 @@ class CycleItem(Model):
|
|||
if not personal_total.get(personal.id):
|
||||
personal_total[personal.id]={
|
||||
'base': 0,
|
||||
'level_id': personal.level_id.id,
|
||||
'type': ps.type,
|
||||
'qty': 0,
|
||||
}
|
||||
personal_total[personal.id]['base']+=base
|
||||
personal_total[personal.id]['base']=base
|
||||
personal_total[personal.id]['qty']+=1
|
||||
|
||||
for doctor_id, value in personal_total.items():
|
||||
base=value['base']
|
||||
type=value['type']
|
||||
qty=value['qty']
|
||||
level_id=value['level_id']
|
||||
lines.append(('create',{
|
||||
'cycle_id': obj.cycle_id.id,
|
||||
'personal_id': doctor_id,
|
||||
'paid_amount': base,
|
||||
'level_id': level_id,
|
||||
'rate': base,
|
||||
'qty': qty,
|
||||
'type': type,
|
||||
}))
|
||||
|
||||
|
@ -174,15 +183,22 @@ class CycleItem(Model):
|
|||
mode,vals=line
|
||||
cycle_id=vals['cycle_id']
|
||||
personal_id=vals['personal_id']
|
||||
paid_amount=vals['paid_amount'] or 0
|
||||
#amount=vals['amount'] or 0
|
||||
rate=vals['rate'] or 0
|
||||
qty=vals['qty'] or 0
|
||||
amount=qty*rate
|
||||
key=(cycle_id,personal_id)
|
||||
if not key in glines.keys():
|
||||
glines[key]={
|
||||
'paid_amount': paid_amount,
|
||||
'amount': amount,
|
||||
'type': vals['type'],
|
||||
'level_id': vals['level_id'],
|
||||
'rate': rate,
|
||||
'qty': qty,
|
||||
}
|
||||
continue
|
||||
glines[key]['paid_amount']+=paid_amount
|
||||
glines[key]['amount']+=amount
|
||||
glines[key]['qty']+=qty
|
||||
|
||||
lines=[]
|
||||
for key,vals in glines.items():
|
||||
|
@ -286,6 +302,8 @@ class CycleItem(Model):
|
|||
var_pt=len(obj.hd_cases)
|
||||
var_ptx=var_pt*(obj.var_k or 0)
|
||||
total_bstr=total_b < 0 and "+%s"%(abs(total_b)) or "-%s"%total_b
|
||||
var_x=0
|
||||
if total_a:
|
||||
var_x=eval('(%s%s)/%s'%(var_ptx,total_bstr,total_a))
|
||||
for line in lines:
|
||||
vals=line[1]
|
||||
|
@ -378,4 +396,34 @@ class CycleItem(Model):
|
|||
}
|
||||
}
|
||||
|
||||
def load_nurse_from_schedule(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
#TODO check cycle number & date from schedule
|
||||
schedules=get_model("clinic.schedule").search_browse([['date','=',obj.date]])
|
||||
nurses=[]
|
||||
for schedule in schedules:
|
||||
for line in schedule.lines:
|
||||
cycle=line.cycle_id
|
||||
if obj.cycle_id.id==cycle.id:
|
||||
nurse=line.nurse_id
|
||||
level=line.level_id
|
||||
nurses.append(('create',{
|
||||
'nurse_id': nurse.id,
|
||||
'level_id': level.id,
|
||||
}))
|
||||
for nurse in obj.nurses:
|
||||
nurse.delete()
|
||||
obj.write({
|
||||
'nurses': nurses,
|
||||
})
|
||||
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_cycle_item',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash': 'Load nurse from schedule to cycle item successfully',
|
||||
}
|
||||
|
||||
CycleItem.register()
|
||||
|
|
Loading…
Reference in New Issue