nurse category

conv_bal
watcha.h 2015-02-08 15:48:08 +07:00
parent 03341f26ac
commit ab9920aab5
23 changed files with 138 additions and 100 deletions

View File

@ -1,8 +0,0 @@
<action>
<field name="string">Report Labor Cost</field>
<field name="view_cls">report</field>
<field name="model">clinic.report.labor.cost</field>
<field name="report_template">report_labor_cost</field>
<field name="report_template_xls">report_labor_cost</field>
<field name="menu">account_menu</field>
</action>

View File

@ -0,0 +1,8 @@
<action>
<field name="string">Report Labor Cost Summary</field>
<field name="view_cls">report</field>
<field name="model">clinic.report.labor.cost.summary</field>
<field name="report_template">report_labor_cost_summary</field>
<field name="report_template_xls">report_labor_cost_summary</field>
<field name="menu">account_menu</field>
</action>

View File

@ -22,7 +22,8 @@
<list>
<field name="nurse_id" domain='[["type","=","nurse"]]' onchange="onchange_nurse"/>
<field name="level_id"/>
<field name="state"/>
<field name="categ_id"/>
<!--<field name="state"/>-->
</list>
</field>
</tab>

View File

@ -12,7 +12,7 @@
<field name="date_to" span="2"/>
<field name="branch_id" onchange="onchange_branch" span="2"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
<field name="work_state" span="2"/>
<field name="categ_id" span="2"/>
</group>
<tabs>
<tab string="Doctors">
@ -20,7 +20,7 @@
<list>
<field name="staff_id"/>
<field name="department_id"/>
<field name="state"/>
<field name="categ_id"/>
<field name="qty" string="Qty" onchange="onchange_line"/>
<field name="rate" onchange="onchange_line"/>
<field name="amount"/>
@ -34,7 +34,7 @@
<list>
<field name="staff_id"/>
<field name="department_id"/>
<field name="state"/>
<field name="categ_id"/>
<field name="max_cycle" />
<field name="qty" onchange="onchange_line"/>
<field name="over_cycle" />

View File

@ -5,12 +5,6 @@
</head>
<group form_layout="stacked">
<field name="cycle_item_id" span="3"/>
<!--
<field name="date" span="3"/>
<field name="cycle_id" span="3"/>
<field name="branch_id" span="3"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
-->
</group>
<tabs>
<tab string="Computation">
@ -46,9 +40,7 @@
<field name="staff_id" domain="[['type','=','nurse']]"/>
<field name="description"/>
<field name="level_id"/>
<field name="state"/>
<!--<field name="qty" onchange="onchange_cost_line"/>-->
<!--<field name="rate" onchange="onchange_cost_line"/>-->
<field name="categ_id"/>
<field name="amount"/>
</list>
</field>
@ -61,7 +53,7 @@
<field name="staff_id" domain="[['type','=','doctor']]"/>
<field name="description"/>
<field name="level_id"/>
<field name="state"/>
<field name="categ_id"/>
<field name="qty" onchange="onchange_cost_line"/>
<field name="rate" onchange="onchange_cost_line"/>
<field name="amount"/>

View File

@ -2,14 +2,12 @@
<item string="Settings" position="before">
<item string="Ratchawat">
<item string="Labor Costs" action="clinic_labor_cost"/>
<!--<item string="Labor Cost Items" action="clinic_labor_cost_item" perm="clinic_labor_cost_item"/>-->
<item string="Labor Cost Entries" action="clinic_labor_cost_entry"/>
<!--<item string="Matching Payment(Old)" action="clinic_report_payment_matching"/>-->
<item string="Matching Payments" action="clinic_matching_payment"/>
<item string="HD Case Expenses" action="clinic_hd_case_expense"/>
<divider/>
<header string="REPORTS"/>
<item string="Labor Cost" action="clinic_report_labor_cost"/>
<item string="Labor Cost Summary" action="clinic_report_labor_cost_summary"/>
<item string="Staff" action="clinic_report_staff"/>
<item string="Staff Fee" action="clinic_report_staff_fee"/>
<item string="Staff Fee Detail" action="clinic_report_staff_fee_detail"/>

View File

@ -1,4 +1,4 @@
<form model="clinic.report.labor.cost">
<form model="clinic.report.labor.cost.summary">
<field name="date" mode="month" onchange="onchange_date" span="2"/>
<field name="date_from" required="1" span="2"/>
<field name="date_to" required="1" span="2"/>

View File

@ -1,6 +1,6 @@
<form model="clinic.staff" show_company="1">
<head>
<field name="state"/>
<field name="type"/>
<button string="Options" dropdown="1">
<item string="Copy"/>
</button>
@ -22,7 +22,7 @@
<field name="birthday"/>
<field name="nation_id"/>
<field name="categ_id" domain="[['type','=',type]]"/>
<field name="state"/>
<!--<field name="state"/>-->
</group>
<group span="6" columns="1">
<field name="image"/>

View File

@ -15,5 +15,5 @@
<field name="level_id"/>
<field name="categ_id"/>
<field name="image" preview="1"/>
<field name="state"/>
<!--<field name="state"/>-->
</list>

View File

@ -74,7 +74,7 @@ from . import report_staff_fee
from . import report_staff_fee_detail
from . import report_staff_fee_sum
from . import report_payment_matching
from . import report_labor_cost
from . import report_labor_cost_summary
from . import branch
from . import period
from . import period_line

View File

@ -108,7 +108,33 @@ class AccountPayment(Model):
'credit': rvals['credit'],
"track_id": track_id,
}))
lines=lines1+lines2 #debit, credit
if obj.type=="in":
rate_type="sell"
else:
rate_type="buy"
adjust_lines=[]
adjust_amt=0
for jline in obj.adjust_lines:
cur_amt=get_model("currency").convert(line.amount,obj.currency_id.id,settings.currency_id.id,date=obj.date,rate_type=rate_type)
tax_base=get_model("currency").convert(line.tax_base or 0,obj.currency_id.id,settings.currency_id.id,date=obj.date,rate_type=rate_type)
cur_amt=abs(cur_amt)
adjust_lines.append(('create',{
"move_id": move_id,
"description": desc,
"account_id": line.account_id.id,
"tax_comp_id": line.tax_comp_id.id,
"tax_base": tax_base,
"track_id": line.track_id.id,
"partner_id": obj.partner_id.id,
"credit":0,
"debit": cur_amt,
}))
#XXX
adjust_amt+=cur_amt
lines1[0][1]['debit']-=cur_amt
lines=lines1+adjust_lines+lines2 #debit, debit, credit
move=get_model("account.move").browse(move_id)
move.write({
'lines': lines,

View File

@ -139,6 +139,7 @@ class CycleItem(Model):
nurse_id=line['nurse_id']
nurse=get_model('clinic.staff').browse(nurse_id)
line['level_id']=nurse.level_id.id
line['categ_id']=nurse.categ_id.id
return data
def view_schedule(self,ids,context={}):
@ -201,6 +202,7 @@ class CycleItem(Model):
lines.append(('create',{
'nurse_id': nurse.id,
'level_id': level.id,
'categ_id': nurse.categ_id.id,
}))
for line in obj.lines:
line.delete()

View File

@ -84,7 +84,7 @@ class CycleItemCopy(Model):
lines.append(('create', {
'nurse_id': nr.id,
'level_id': nr.level_id.id,
'state': nr.state,
'categ_id': nr.categ_id.id,
}))
item.write({
'lines': lines,

View File

@ -10,6 +10,7 @@ class CycleItemLine(Model):
'nurse_id': fields.Many2One("clinic.staff",'Nurse',domain=[['type','=','nurse']]),
'department_id': fields.Many2One("clinic.department","Department"),
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
'categ_id': fields.Many2One("clinic.staff.categ",'Category',domain=[['type','=','nurse']]),
}
CycleItemLine.register()

View File

@ -269,7 +269,7 @@ class LaborCost(Model):
'cycle_id': item.cycle_id.id,
'staff_id': nurse.id,
'level_id': level_id,
'state': nurse.state,
'categ_id': nurse.categ_id.id,
'rate': rate,
'type': 'nurse',
'qty': 1,
@ -292,7 +292,7 @@ class LaborCost(Model):
staff_total[staff.id]={
'base': 0,
'type': staff.type,
'state': staff.state,
'categ_id': staff.categ_id.id,
'level_id': staff.level_id.id,
'qty': 0,
}
@ -307,12 +307,12 @@ class LaborCost(Model):
type=value['type']
qty=value['qty']
level_id=value['level_id']
state=value['state']
categ_id=value['categ_id']
lines.append(('create',{
'cycle_id': item.cycle_id.id,
'staff_id': doctor_id,
'level_id': level_id,
'state': state,
'categ_id': categ_id,
'rate': base,
'qty': qty,
'type': type,
@ -333,7 +333,7 @@ class LaborCost(Model):
staff_id=vals['staff_id']
rate=vals['rate'] or 0
qty=vals['qty'] or 0
state=vals['state']
categ_id=vals['categ_id']
amount=qty*rate
key=(cycle_id,staff_id)
if not key in glines.keys():
@ -344,7 +344,7 @@ class LaborCost(Model):
'qty': qty,
'type': vals['type'],
'description': vals.get("description",""),
'state': state,
'categ_id': categ_id,
}
continue
glines[key]['amount']+=amount

View File

@ -49,7 +49,8 @@ class LaborCostEntry(Model):
"lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Lines"),
"nurse_lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Nurse Lines",domain=[['type','=','nurse']]),
"doctor_lines": fields.One2Many("clinic.labor.cost.entry.line", "entry_id", "Doctor Lines",domain=[['type','=','doctor']]),
"work_state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
#"work_state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
'categ_id': fields.Many2One("clinic.staff.categ", "Category",search=True),
"state": fields.Selection([["draft","Draft"],["approved","Approved"]],"Status"),
'user_id': fields.Many2One("base.user","Approver",search=True),
'note': fields.Text("Note"),
@ -91,8 +92,8 @@ class LaborCostEntry(Model):
dom.append(['labor_cost_id.cycle_item_id.branch_id','=',obj.branch_id.id])
if obj.department_id:
dom.append(['labor_cost_id.cycle_item_id.department_id','=',obj.department_id.id])
if obj.work_state:
dom.append(['staff_id.state','=',obj.work_state])
if obj.categ_id:
dom.append(['staff_id.categ_id','=',obj.categ_id.id])
for lc_id in get_model("clinic.labor.cost.line").search(dom):
line_ids.append(lc_id)
staffs={}
@ -100,7 +101,8 @@ class LaborCostEntry(Model):
staff=line.staff_id
qty=line.qty
amt=line.amount
state=line.state or staff.state
#state=line.state or staff.state
categ=line.categ_id
dpt=staff.department_id
citem=line.labor_cost_id.cycle_item_id
if not dpt:
@ -112,7 +114,8 @@ class LaborCostEntry(Model):
'qty': 0,
'amt': 0,
'rate': 0, # XXX for special nurse
'state': state,
#'state': state,
'categ_id': categ.id,
'report_staff_id': get_model("clinic.report.staff").create({
'date_from': obj.date_from,
'date_to': obj.date_to,
@ -130,7 +133,8 @@ class LaborCostEntry(Model):
for staff_id, vals in staffs.items():
qty=vals['qty'] or 0
amt=vals['amt'] or 0.0
state=vals['state']
#state=vals['state']
categ_id=vals['categ_id']
report_staff_id=vals['report_staff_id']
report_staff=get_model("clinic.report.staff").browse(report_staff_id)
@ -178,7 +182,8 @@ class LaborCostEntry(Model):
'amount': amt,
'date': timenow,
'rate': rate,
'state': state,
#'state': state,
'categ_id': categ_id,
'department_id': vals['department_id'],
'report_staff_id': report_staff.id,
}))

View File

@ -39,6 +39,7 @@ class LaborCostEntryLine(Model):
'max_cycle': fields.Integer("Max Cycle", function="_get_all",function_multi=True),
'over_cycle': fields.Integer("Over Cycle", function="_get_all",function_multi=True),
'report_staff_id2': fields.Many2One("clinic.report.staff","#PT",function="_get_all",function_multi=True),
'categ_id': fields.Many2One("clinic.staff.categ",'Category'),
}
_order="type"

View File

@ -18,7 +18,7 @@ class LaborCostLine(Model):
'date': fields.Date("Date",search=True),
'description': fields.Char("Description"),
'company_id': fields.Many2One('company','Company'),
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
'categ_id': fields.Many2One("clinic.staff.categ", "Category",domain=[['type','=','nurse']],search=True),
}
_defaults={

View File

@ -4,9 +4,9 @@ from calendar import monthrange
from netforce.model import Model,fields,get_model
from netforce.access import get_active_company
class ReportLaborCost(Model):
_name="clinic.report.labor.cost"
_string="Report Labor Cost"
class ReportLaborCostSummary(Model):
_name="clinic.report.labor.cost.summary"
_string="Report Labor Cost Summary"
_transient=True
_fields={
@ -52,6 +52,7 @@ class ReportLaborCost(Model):
if _type:
dom.append(['type','=',_type])
staffs={}
print('dom ', dom)
for line in get_model("clinic.labor.cost.line").search_browse(dom):
lcost=line.labor_cost_id
citem=lcost.cycle_item_id
@ -62,15 +63,19 @@ class ReportLaborCost(Model):
staffs[staff.name]={
dpt.name: {
'type': staff.type,
'amt': 0,
'amt': amt,
},
}
else:
#XXX bug
if not staffs[staff.name].get(dpt.name):
staffs[staff.name][dpt.name]={
'type': staff.type,
'amt': 0,
'amt': amt,
}
staffs[staff.name][dpt.name]['amt']+=amt
#if staffs.get(staff.name):
#if staffs[staff.name].get(dpt.name):
#staffs[staff.name][dpt.name]['amt']+=amt
lines=[]
dpts=get_model("clinic.department").search_read([],['name'])
@ -123,8 +128,8 @@ class ReportLaborCost(Model):
total_lines.append({'amt': total})
data={
'title': title,
'date_from': obj.date_from,
'date_to': obj.date_to,
'date_from': date_from,
'date_to': date_to,
'dpts': dpts,
'comp_name': comp.name or 0,
'comp_span': len(dpts),
@ -142,4 +147,4 @@ class ReportLaborCost(Model):
data['date_to']="%s-%s-%s"%(year,month,total_day)
return data
ReportLaborCost.register()
ReportLaborCostSummary.register()

View File

@ -109,45 +109,50 @@ class ClinicSetting(Model):
print("Only admin!!")
return
obj=self.browse(1)
t={}
[t.update({x.code : x.id}) for x in get_model("clinic.patient.type").search_browse([])]
for prod in get_model("product").search_browse([]):
code=prod.code or ""
tcodes=code.split("-")
tids=[]
for tcode in tcodes:
tid=t.get(tcode,None)
if tid:
tids.append(tid)
categs={}
for ct in get_model("clinic.staff.categ").search_read([['type','=','nurse']],['name']):
categs[ct['name']]=ct['id']
prod.write({
'patient_types': [('add',tids)]
for cline in get_model("clinic.cycle.item.line").search_browse([]):
nr=cline.nurse_id
st=nr.state or ""
if st=='part_time':
st='Part Time'
elif st=='full_time':
st='Full Time'
else:
st='Others'
ct_id=categs.get(st,None)
cline.write({
'categ_id': ct_id,
})
for line in obj.account_products:
acc=line.ar_debit_id
type='credit'
if acc:
if acc.code=='101101':
type='cash'
line.write({
'type': type,
for cline in get_model("clinic.labor.cost.line").search_browse([]):
staff=cline.staff_id
st=staff.state or ""
if st=='part_time':
st='Part Time'
elif st=='full_time':
st='Full Time'
else:
st='Others'
ct_id=categs.get(st,None)
cline.write({
'categ_id': ct_id,
})
print("Update product completed!")
for vs in get_model("clinic.visit").search_browse([['state','in', ['draft','pending']],['doctor_id','=',None]]):
doctor=vs.patient_id.doctor_id
if doctor:
vs.write({
'doctor_id': doctor.id,
for staff in get_model("clinic.staff").search_browse([]):
st=staff.state
if st=='part_time':
st='Part Time'
elif st=='full_time':
st='Full Time'
else:
st='Others'
ct_id=categs.get(st,None)
staff.write({
'categ_id': ct_id,
})
print("update visit.date ", vs.visit_date)
print("Update visit completed!")
for shop in get_model("clinic.shop").search_browse([]):
shop.write({
'company_id': 1,
})
print("Update shop completed!")
print("Done! ")
def reset_last_import(self,ids,context={}):

View File

@ -100,7 +100,7 @@ class Staff(Model):
"user_id": fields.Many2One("base.user","User",search=True),
'image': fields.File("Image"),
'note': fields.Text("Note"),
'categ_id': fields.Many2One("clinic.staff.categ", "Category"),
'categ_id': fields.Many2One("clinic.staff.categ", "Category",search=True),
'level_id': fields.Many2One("clinic.staff.level", "Level", function="_get_level"),
'active': fields.Boolean("Active"),
'date': fields.Date("Register Date"),

View File

@ -258,7 +258,8 @@ class Visit(Model):
item_vals['lines'].append(('create',{
'nurse_id': nurse.id,
'level_id': nurse.level_id.id,
'state': nurse.state,
#'state': nurse.state,
'categ_id': nurse.categ_id.id,
}))
item.write(item_vals)
@ -276,7 +277,8 @@ class Visit(Model):
lines.append(('create', {
'nurse_id': nr.id,
'level_id': nr.level_id.id,
'state': nr.state,
#'state': nr.state,
'categ_id': nr.categ_id.id,
}))
if lines:
print("copy nurse from %s to %s"%(item2.name, item.name))

View File

@ -10,7 +10,7 @@
<tbody>
<tr>
{{#each dpts}}
<td>{{name}}</td>
<td style="text-align:right">{{name}}</td>
{{/each}}
</tr>
</tbody>
@ -24,9 +24,9 @@
<td>{{no}}</th>
<td>{{staff_name}}</td>
{{#each sub_lines}}
<td style="text-align:right;">{{amt}}</td>
<td style="text-align:right;">{{currency amt zero=""}}</td>
{{/each}}
<td style="text-align:right;">{{total}}</th>
<td style="text-align:right;">{{currency total zero=""}}</th>
</tr>
{{/each}}
</tbody>
@ -34,7 +34,7 @@
<th></th>
<th style="text-align:right"></th>
{{#each total_lines}}
<th style="text-align:right;">{{amt}}</th>
<th style="text-align:right;">{{currency amt zero=""}}</th>
{{/each}}
<th></th>
</tfoot>