to zip file
parent
750d7de808
commit
dca8c54e02
|
@ -1,9 +1,7 @@
|
||||||
<record model="action">
|
<record model="action">
|
||||||
<field name="name">clinic_print_labor_cost</field>
|
<field name="string">Print Labor Cost</field>
|
||||||
<field name="view_cls">form_view</field>
|
<field name="view_cls">multi_view</field>
|
||||||
<field name="model">clinic.print.labor.cost</field>
|
<field name="model">clinic.print.labor.cost</field>
|
||||||
<field name="view_xml">clinic_print_labor_cost</field>
|
|
||||||
<field name="active_id">1</field>
|
|
||||||
<field name="menu">account_menu</field>
|
<field name="menu">account_menu</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
<form model="clinic.print.labor.cost" title="Print Labor Cost">
|
|
||||||
<group form_layout="stacked">
|
|
||||||
<field name="period_id" domain='[["state","=","open"]]' onchange="onchange_period" span="2"/>
|
|
||||||
<field name="date_from" span="2"/>
|
|
||||||
<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="cycle_id" span="2"/>
|
|
||||||
<field name="staff_type" required="1" span="2"/>
|
|
||||||
<button string="Generate Report" method="do_generate" icon="arrow-right" type="default"/>
|
|
||||||
<field name="report_labor_cost" span="3" readonly="1"/>
|
|
||||||
<field name="report_summary" span="3" readonly="1"/>
|
|
||||||
<field name="lines" nolabel="1" readonly="1">
|
|
||||||
<list>
|
|
||||||
<field name="staff_name" readonly="1"/>
|
|
||||||
<field name="report_detail" readonly="1"/>
|
|
||||||
<field name="report_sub_detail" readonly="1"/>
|
|
||||||
<!--<field name="report_daily" readonly="1"/>-->
|
|
||||||
<!--<field name="report_ot" readonly="1"/>-->
|
|
||||||
</list>
|
|
||||||
</field>
|
|
||||||
</group>
|
|
||||||
<foot replace="1">
|
|
||||||
</foot>
|
|
||||||
</form>
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<form model="clinic.print.labor.cost" title="Print Labor Cost" show_company="1">
|
||||||
|
<head>
|
||||||
|
<field name="state"/>
|
||||||
|
</head>
|
||||||
|
<group form_layout="stacked">
|
||||||
|
<field name="period_id" domain='[["state","=","open"]]' onchange="onchange_period" span="2"/>
|
||||||
|
<field name="date_from" span="2"/>
|
||||||
|
<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="cycle_id" span="2"/>
|
||||||
|
<field name="staff_type" required="1" span="2"/>
|
||||||
|
</group>
|
||||||
|
<foot>
|
||||||
|
<button string="Generate Report" method="do_generate" icon="arrow-right" type="default"/>
|
||||||
|
</foot>
|
||||||
|
</form>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<list model="clinic.print.labor.cost">
|
||||||
|
<field name="period_id"/>
|
||||||
|
<field name="report_file"/>
|
||||||
|
<field name="state"/>
|
||||||
|
</list>
|
|
@ -5,14 +5,31 @@ from calendar import monthrange
|
||||||
|
|
||||||
from netforce.model import Model,fields,get_model
|
from netforce.model import Model,fields,get_model
|
||||||
from netforce.database import get_active_db, get_connection
|
from netforce.database import get_active_db, get_connection
|
||||||
from netforce.access import get_active_user
|
from netforce.access import get_active_user, get_active_company
|
||||||
import netforce.config as config
|
import netforce.config as config
|
||||||
|
|
||||||
class PrintLaborCost(Model):
|
class PrintLaborCost(Model):
|
||||||
_name="clinic.print.labor.cost"
|
_name="clinic.print.labor.cost"
|
||||||
_string="Print Report Labor Cost"
|
_string="Report Labor Cost"
|
||||||
|
|
||||||
|
def _get_name(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
year_frm,month_frm,day_frm=obj.date_from.split(",")
|
||||||
|
year_to,month_to,day_to=obj.date_to.split(",")
|
||||||
|
name=''.join([year_frm,month_frm,day_frm,month_to,day_to])
|
||||||
|
if obj.cycle_id:
|
||||||
|
name+=obj.cycle_id.name
|
||||||
|
if obj.branch_id:
|
||||||
|
name+=obj.branch_id.name
|
||||||
|
if obj.department_id:
|
||||||
|
name+=obj.department_id.name
|
||||||
|
name+='-'%obj.type
|
||||||
|
res[obj.id]=name
|
||||||
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
|
"name": fields.Char("Name",function="_get_name"),
|
||||||
"date": fields.Date("Month"),
|
"date": fields.Date("Month"),
|
||||||
"period_id": fields.Many2One("clinic.period.line","Period"),
|
"period_id": fields.Many2One("clinic.period.line","Period"),
|
||||||
"date_from": fields.Date("From", required=True),
|
"date_from": fields.Date("From", required=True),
|
||||||
|
@ -31,8 +48,45 @@ class PrintLaborCost(Model):
|
||||||
'ot_report_id': fields.Many2One("clinic.report.labor.cost.overtime","Overtime Report"),
|
'ot_report_id': fields.Many2One("clinic.report.labor.cost.overtime","Overtime Report"),
|
||||||
'report_summary': fields.File("Summary"),
|
'report_summary': fields.File("Summary"),
|
||||||
'report_labor_cost': fields.File("Labor Cost"),
|
'report_labor_cost': fields.File("Labor Cost"),
|
||||||
|
'state': fields.Selection([['draft','Draft'],['pending','Pending'],['done','Done']],'State'),
|
||||||
|
'company_id': fields.Many2One('company','Company'),
|
||||||
|
'report_file': fields.File("File"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _get_date_from(self,context={}):
|
||||||
|
year,month,day=time.strftime("%Y-%m-%d").split("-")
|
||||||
|
#return '%s-%s-01'%(year,month)
|
||||||
|
return '%s-%s-%s'%(year,month,day)
|
||||||
|
|
||||||
|
def _get_date_to(self,context={}):
|
||||||
|
year,month,day=time.strftime("%Y-%m-%d").split("-")
|
||||||
|
weekday, total_day=monthrange(int(year), int(month))
|
||||||
|
#return "%s-%s-%s"%(year,month,total_day)
|
||||||
|
return "%s-%s-%s"%(year,month,day)
|
||||||
|
|
||||||
|
def default_get(self,field_names=None,context={},**kw):
|
||||||
|
defaults=context.get("defaults",{})
|
||||||
|
date_from=defaults.get("date_from", self._get_date_from())
|
||||||
|
date_to=defaults.get("date_to", self._get_date_to())
|
||||||
|
print('defaults ', defaults)
|
||||||
|
yearnow=date_from.split("-")[0]
|
||||||
|
for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
|
||||||
|
for line in period.lines:
|
||||||
|
if line.state=='open':
|
||||||
|
period_id=line.id
|
||||||
|
date_from=line.date_start
|
||||||
|
date_to=line.date_stop
|
||||||
|
break
|
||||||
|
res={
|
||||||
|
'period_id': period_id,
|
||||||
|
'date': time.strftime("%Y-%m-%d"),
|
||||||
|
'date_from': date_from,
|
||||||
|
'date_to': date_to,
|
||||||
|
'state': 'draft',
|
||||||
|
'company_id': get_active_company(),
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
def reload(self,ids,context={}):
|
def reload(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
context['defaults']={
|
context['defaults']={
|
||||||
|
@ -182,8 +236,6 @@ class PrintLaborCost(Model):
|
||||||
report_lines=[
|
report_lines=[
|
||||||
{'report_file': 'report_detail','model': 'clinic.report.labor.cost.detail', 'report_id': obj.dt_report_id.id,'field_name': 'dt_report_id'},
|
{'report_file': 'report_detail','model': 'clinic.report.labor.cost.detail', 'report_id': obj.dt_report_id.id,'field_name': 'dt_report_id'},
|
||||||
{'report_file': 'report_sub_detail','model': 'clinic.report.labor.cost.sub.detail', 'report_id': obj.sub_dt_report_id.id,'field_name': 'sub_dt_report_id'},
|
{'report_file': 'report_sub_detail','model': 'clinic.report.labor.cost.sub.detail', 'report_id': obj.sub_dt_report_id.id,'field_name': 'sub_dt_report_id'},
|
||||||
#{'report_file': 'report_daily','model': 'clinic.report.labor.cost.daily', 'report_id': obj.dl_report_id.id,'field_name': 'dl_report_id'},
|
|
||||||
#{'report_file': 'report_ot','model': 'clinic.report.labor.cost.overtime', 'report_id': obj.ot_report_id.id,'field_name': 'ot_report_id'},
|
|
||||||
]
|
]
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
staff=line.staff_id
|
staff=line.staff_id
|
||||||
|
@ -231,7 +283,6 @@ class PrintLaborCost(Model):
|
||||||
report_file: fname,
|
report_file: fname,
|
||||||
})
|
})
|
||||||
db.commit()
|
db.commit()
|
||||||
print("Done!")
|
|
||||||
vals={
|
vals={
|
||||||
'to_id': get_active_user(),
|
'to_id': get_active_user(),
|
||||||
'subject': 'Generate Report',
|
'subject': 'Generate Report',
|
||||||
|
@ -241,38 +292,6 @@ class PrintLaborCost(Model):
|
||||||
}
|
}
|
||||||
get_model("message").create(vals)
|
get_model("message").create(vals)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
def _get_date_from(self,context={}):
|
|
||||||
year,month,day=time.strftime("%Y-%m-%d").split("-")
|
|
||||||
#return '%s-%s-01'%(year,month)
|
|
||||||
return '%s-%s-%s'%(year,month,day)
|
|
||||||
|
|
||||||
def _get_date_to(self,context={}):
|
|
||||||
year,month,day=time.strftime("%Y-%m-%d").split("-")
|
|
||||||
weekday, total_day=monthrange(int(year), int(month))
|
|
||||||
#return "%s-%s-%s"%(year,month,total_day)
|
|
||||||
return "%s-%s-%s"%(year,month,day)
|
|
||||||
|
|
||||||
def default_get(self,field_names=None,context={},**kw):
|
|
||||||
defaults=context.get("defaults",{})
|
|
||||||
date_from=defaults.get("date_from", self._get_date_from())
|
|
||||||
date_to=defaults.get("date_to", self._get_date_to())
|
|
||||||
print('defaults ', defaults)
|
|
||||||
yearnow=date_from.split("-")[0]
|
|
||||||
for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
|
|
||||||
for line in period.lines:
|
|
||||||
if line.state=='open':
|
|
||||||
period_id=line.id
|
|
||||||
date_from=line.date_start
|
|
||||||
date_to=line.date_stop
|
|
||||||
break
|
|
||||||
res={
|
|
||||||
'period_id': period_id,
|
|
||||||
'date': time.strftime("%Y-%m-%d"),
|
|
||||||
'date_from': date_from,
|
|
||||||
'date_to': date_to,
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
|
|
||||||
def onchange_date(self,context={}):
|
def onchange_date(self,context={}):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
|
@ -301,4 +320,5 @@ class PrintLaborCost(Model):
|
||||||
data['date_to']=period.date_stop
|
data['date_to']=period.date_stop
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
PrintLaborCost.register()
|
PrintLaborCost.register()
|
||||||
|
|
Loading…
Reference in New Issue