fix labor cost
parent
f9546abf6b
commit
4b767ecab8
|
@ -1,7 +1,21 @@
|
|||
<form model="clinic.labor.cost.line">
|
||||
<tabs>
|
||||
<tab string="General">
|
||||
<field name="date"/>
|
||||
<field name="cycle_id"/>
|
||||
<field name="staff_id"/>
|
||||
<field name="type"/>
|
||||
<field name="type" readonly="1"/>
|
||||
<field name="branch_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="qty" onchange="onchange_vals" help="Number of HD Case"/>
|
||||
<field name="rate" onchange="onchange_vals"/>
|
||||
<field name="amount"/>
|
||||
</tab>
|
||||
<tab string="Computation">
|
||||
<field name="labor_cost_id"/>
|
||||
</tab>
|
||||
<tab string="Other">
|
||||
<field name="note"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
</form>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from . import clinic_setting
|
||||
from . import import_acc
|
||||
from . import remove_conv_bal
|
||||
#from . import import_acc
|
||||
#from . import remove_conv_bal
|
||||
from . import update_labor_cost_line
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
from datetime import datetime
|
||||
|
||||
from netforce.model import get_model
|
||||
from netforce import migration
|
||||
from netforce.database import get_connection
|
||||
|
||||
class Migration(migration.Migration):
|
||||
_name="clinic.update.labor.cost.line"
|
||||
_version="2.11.0"
|
||||
|
||||
def migrate(self):
|
||||
for lcost_line in get_model("clinic.labor.cost.line").search_browse([]):
|
||||
lcost_line.write({
|
||||
'note': ' ',
|
||||
})
|
||||
return True
|
||||
|
||||
Migration.register()
|
|
@ -78,7 +78,7 @@ class HDCase(Model):
|
|||
for line in obj.lines:
|
||||
prod=line.product_id
|
||||
categ=line.product_categ_id
|
||||
if categ and prod:
|
||||
if categ and prod and line.reimbursable=='yes':
|
||||
if categ.code=='EPO':
|
||||
name=prod.name or ""
|
||||
name=name.split("-") #XXX
|
||||
|
|
|
@ -6,37 +6,54 @@ class LaborCostLine(Model):
|
|||
_string="Labor Cost Item"
|
||||
_name_field="labor_cost_id"
|
||||
|
||||
def _get_store(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
staff_type=obj.staff_id.type
|
||||
citem=obj.labor_cost_id.cycle_item_id
|
||||
dpt=citem.department_id
|
||||
br=dpt.branch_id
|
||||
res[obj.id]={
|
||||
'type': staff_type,
|
||||
'branch_id': br.id,
|
||||
'department_id': dpt.id,
|
||||
}
|
||||
return res
|
||||
|
||||
_fields={
|
||||
"labor_cost_id": fields.Many2One("clinic.labor.cost","Cycle Item",required=True,on_delete="cascade"),
|
||||
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Type",required=True,search=True),
|
||||
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Staff Type",required=True,search=True,function="_get_store",function_multi=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),
|
||||
'qty': fields.Integer("#HDCase"),
|
||||
'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'),
|
||||
'categ_id': fields.Many2One("clinic.staff.categ", "Category",domain=[['type','=','nurse']],search=True),
|
||||
'branch_id': fields.Many2One('clinic.branch','Branch',function="_get_store",function_multi=True,store=True,search=True),
|
||||
'department_id': fields.Many2One('clinic.department','Department',function="_get_store",function_multi=True,store=True,search=True),
|
||||
'note': fields.Text("Note"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
}
|
||||
|
||||
_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)
|
||||
self.function_store([new_id])
|
||||
return new_id
|
||||
|
||||
def write(self,ids,vals,**kw):
|
||||
self.function_store(ids)
|
||||
super().write(ids,vals,**kw)
|
||||
|
||||
def onchange_vals(self,context={}):
|
||||
data=context['data']
|
||||
data['amount']=(data['rate'] or 0)*(data['qty'] or 0)
|
||||
return data
|
||||
|
||||
LaborCostLine.register()
|
||||
|
|
|
@ -29,13 +29,6 @@ class ReportLaborCostDetail(Model):
|
|||
weekday, total_day=monthrange(int(year), int(month))
|
||||
return "%s-%s-%s"%(year,month,total_day)
|
||||
|
||||
#_defaults={
|
||||
#'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
#'date_from': _get_date_from,
|
||||
#'date_to': _get_date_to,
|
||||
#'type': 'doctor',
|
||||
#}
|
||||
|
||||
def default_get(self,field_names=None,context={},**kw):
|
||||
defaults=context.get("defaults",{})
|
||||
date_from=defaults.get("date_from")
|
||||
|
@ -83,6 +76,9 @@ class ReportLaborCostDetail(Model):
|
|||
dom.append(['type','=',staff_type])
|
||||
if department_id:
|
||||
dom.append(['labor_cost_id.cycle_item_id.department_id','=',department_id])
|
||||
|
||||
def replace_quote(dom=""):
|
||||
return dom.replace("'","\"")
|
||||
#prevent to load more data
|
||||
if not staff_id:
|
||||
return {}
|
||||
|
@ -114,6 +110,7 @@ class ReportLaborCostDetail(Model):
|
|||
dpt.name: {
|
||||
'amt': 0,
|
||||
'qty': 0,
|
||||
'dom': [['staff_id','=',staff.id],['date','>=', date],['date','<=',date], ['department_id','=',dpt.id]],
|
||||
},
|
||||
}
|
||||
if not dates[date].get(dpt.name):
|
||||
|
@ -124,6 +121,7 @@ class ReportLaborCostDetail(Model):
|
|||
dpt.name: {
|
||||
'amt': 0,
|
||||
'qty': 0,
|
||||
'dom': [['staff_id','=',staff.id],['date','>=', date],['date','<=',date], ['department_id','=',dpt.id]],
|
||||
}})
|
||||
dates[date][dpt.name]['amt']+=amt
|
||||
dates[date][dpt.name]['qty']+=qty
|
||||
|
@ -147,10 +145,19 @@ class ReportLaborCostDetail(Model):
|
|||
amt,qty=0,0
|
||||
dname=dpt['name'] or ''
|
||||
dpt_vals=vals.get(dname)
|
||||
url_name=None
|
||||
if dpt_vals:
|
||||
amt=dpt_vals.get("amt",0)
|
||||
qty=dpt_vals.get("qty",0)
|
||||
lvals['sub_lines'].append({'qty': qty, 'amt': amt, 'dpt_id': dpt['id']})
|
||||
dom=dpt_vals.get('dom',[])
|
||||
if dom:
|
||||
url_name='#name=clinic_labor_cost_item&mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%dom),
|
||||
lvals['sub_lines'].append({
|
||||
'qty': qty,
|
||||
'amt': amt,
|
||||
'dpt_id': dpt['id'],
|
||||
'url_name': url_name,
|
||||
})
|
||||
total_amt+=amt
|
||||
total_qty+=qty
|
||||
lvals['total_qty']=total_qty # total show as right hand side
|
||||
|
|
|
@ -41,7 +41,9 @@
|
|||
<a href="#name=clinic_report_labor_cost_daily&defaults.date={{../date}}&defaults.staff_type={{../staff_type}}&defaults.staff_id={{../staff_id}}&defaults.department_id={{dpt_id}}">{{currency qty zero=""}}</a>
|
||||
</td>
|
||||
<td style="text-align:right;">
|
||||
<a href="{{url_name}}" target="_blank">
|
||||
{{currency amt zero=""}}
|
||||
</a>
|
||||
</td>
|
||||
{{/each}}
|
||||
<td style="text-align:right;">
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th rowspan="2">#</th>
|
||||
<th rowspan="2">Number</th>
|
||||
<th rowspan="2">Name</th>
|
||||
<th rowspan="2">Level</th>
|
||||
<th rowspan="2">Category</th>
|
||||
<th rowspan="2">รหัส</th>
|
||||
<th rowspan="2">ชื่อ-สกุล</th>
|
||||
<th rowspan="2">ตำแหน่ง</th>
|
||||
<th rowspan="2">หมวดหมู่</th>
|
||||
{{#each dpts}}
|
||||
<th style="text-align:right">{{name}}</th>
|
||||
{{/each}}
|
||||
|
|
Loading…
Reference in New Issue