monthly
parent
4a3b4da09a
commit
66a0901fdb
|
@ -1,4 +1,4 @@
|
||||||
<form model="clinic.cycle.daily">
|
<form model="clinic.cycle.daily" attrs='{"readonly":[["state","in",["confirmed"]]]}' show_company="1">
|
||||||
<head>
|
<head>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="1">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<form model="clinic.cycle.monthly">
|
<form model="clinic.cycle.monthly" attrs='{"readonly":[["state","in",["approved"]]]}' show_company="1">
|
||||||
<head>
|
<head>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="1">
|
||||||
|
@ -7,14 +7,13 @@
|
||||||
</head>
|
</head>
|
||||||
<tabs>
|
<tabs>
|
||||||
<tab string="General">
|
<tab string="General">
|
||||||
<field name="month"/>
|
<field name="month" mode="month"/>
|
||||||
<field name="lines" nolabel="1">
|
<field name="lines" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="staff_id"/>
|
<field name="staff_id"/>
|
||||||
<field name="level_id"/>
|
<field name="level_id"/>
|
||||||
<field name="type"/>
|
<field name="type"/>
|
||||||
<field name="qty" onchange="onchange_line"/>
|
<field name="qty" onchange="onchange_line"/>
|
||||||
<field name="rate" onchange="onchange_line"/>
|
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
</list>
|
</list>
|
||||||
<form>
|
<form>
|
||||||
|
@ -22,7 +21,6 @@
|
||||||
<field name="level_id"/>
|
<field name="level_id"/>
|
||||||
<field name="type"/>
|
<field name="type"/>
|
||||||
<field name="qty"/>
|
<field name="qty"/>
|
||||||
<field name="rate"/>
|
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<header string="LABOR COST"/>
|
<header string="LABOR COST"/>
|
||||||
<item string="Nurse Fee Summary" action="clinic_report_nurse_fee_sum"/>
|
<item string="Nurse Fee Summary" action="clinic_report_nurse_fee_sum"/>
|
||||||
<item string="Nurse Fee Detail" action="clinic_report_nurse_fee_detail"/>
|
<item string="Nurse Fee Detail" action="clinic_report_nurse_fee_detail"/>
|
||||||
<item string="Special Nurse" action="clinic_report_nurse_special"/>
|
<!--<item string="Special Nurse" action="clinic_report_nurse_special"/>-->
|
||||||
</item>
|
</item>
|
||||||
<item string="Settings">
|
<item string="Settings">
|
||||||
<item string="Departments" action="clinic_department"/>
|
<item string="Departments" action="clinic_department"/>
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from netforce.model import Model, fields
|
from netforce.model import Model, fields, get_model
|
||||||
from netforce.access import get_active_company, get_active_user
|
from netforce.access import get_active_company, get_active_user
|
||||||
from netforce.utils import get_data_path
|
from netforce.utils import get_data_path
|
||||||
|
from netforce.database import get_connection
|
||||||
|
|
||||||
class CycleDaily(Model):
|
class CycleDaily(Model):
|
||||||
_name="clinic.cycle.daily"
|
_name="clinic.cycle.daily"
|
||||||
|
@ -49,13 +50,55 @@ class CycleDaily(Model):
|
||||||
obj.write({
|
obj.write({
|
||||||
'state': 'confirmed',
|
'state': 'confirmed',
|
||||||
})
|
})
|
||||||
|
# TODO create cycle monthly
|
||||||
|
all_vals={}
|
||||||
|
for line in obj.lines:
|
||||||
|
staff=line.staff_id
|
||||||
|
level=line.level_id
|
||||||
|
qty=line.qty
|
||||||
|
amt=line.amount
|
||||||
|
if not all_vals.get(staff.id):
|
||||||
|
all_vals[staff.id]={
|
||||||
|
'level_id': level.id,
|
||||||
|
'type': line.type,
|
||||||
|
'qty': 0,
|
||||||
|
'amount': 0,
|
||||||
|
}
|
||||||
|
all_vals[staff.id]['qty']+=qty
|
||||||
|
all_vals[staff.id]['amount']+=amt
|
||||||
|
lines=[]
|
||||||
|
for staff_id, vals in all_vals.items():
|
||||||
|
vals.update({'staff_id': staff_id})
|
||||||
|
lines.append(('create',vals))
|
||||||
|
|
||||||
|
m=int(obj.date[5:7])
|
||||||
|
db=get_connection()
|
||||||
|
res=db.query("select id from clinic_cycle_monthly where extract(month from month)=%s"%m)
|
||||||
|
mobj=get_model("clinic.cycle.monthly")
|
||||||
|
mid=None
|
||||||
|
monthly=None
|
||||||
|
if res:
|
||||||
|
mid=res[0]['id']
|
||||||
|
monthly=mobj.browse(mid)
|
||||||
|
for line in monthly.lines:
|
||||||
|
line.delete()
|
||||||
|
monthly.write({
|
||||||
|
'lines': lines,
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
mid=mobj.create({
|
||||||
|
'lines': lines,
|
||||||
|
})
|
||||||
|
monthly=mobj.browse(mid)
|
||||||
|
if not monthly:
|
||||||
|
return
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
'name': 'clinic_cycle_daily',
|
'name': 'clinic_cycle_monthly',
|
||||||
'mode': 'form',
|
'mode': 'form',
|
||||||
'active_id': obj.id,
|
'active_id': monthly.id,
|
||||||
},
|
},
|
||||||
'flash':'Confirmed',
|
'flash':'Cycle %s has been confirmed and %s has been updated'%(obj.name,monthly.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
def recheck_item(self,ids,context={}):
|
def recheck_item(self,ids,context={}):
|
||||||
|
|
|
@ -94,4 +94,18 @@ class CycleMonthly(Model):
|
||||||
data['total']=total
|
data['total']=total
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def to_draft(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
obj.write({
|
||||||
|
'state': 'draft',
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
'next': {
|
||||||
|
'name': 'clinic_cycle_monthly',
|
||||||
|
'mode': 'form',
|
||||||
|
'active_id': obj.id,
|
||||||
|
},
|
||||||
|
'flash': '%s has been set to draft'%obj.name
|
||||||
|
}
|
||||||
|
|
||||||
CycleMonthly.register()
|
CycleMonthly.register()
|
||||||
|
|
Loading…
Reference in New Issue