diff --git a/netforce_clinic/layouts/clinic_print_labor_cost.xml b/netforce_clinic/layouts/clinic_print_labor_cost.xml
index 8a08c67..920b4fb 100644
--- a/netforce_clinic/layouts/clinic_print_labor_cost.xml
+++ b/netforce_clinic/layouts/clinic_print_labor_cost.xml
@@ -6,9 +6,9 @@
-
+
-
+
diff --git a/netforce_clinic/models/print_labor_cost.py b/netforce_clinic/models/print_labor_cost.py
index ba5667e..4267c86 100644
--- a/netforce_clinic/models/print_labor_cost.py
+++ b/netforce_clinic/models/print_labor_cost.py
@@ -5,6 +5,8 @@ from calendar import monthrange
from netforce.model import Model,fields,get_model
from netforce.database import get_active_db, get_connection
+from netforce.access import get_active_user
+import netforce.config as config
class PrintLaborCost(Model):
_name="clinic.print.labor.cost"
@@ -63,12 +65,35 @@ class PrintLaborCost(Model):
'lines': lines,
})
+ def do_generate(self,ids,context={}):
+ dom=[
+ ['model', '=','clinic.print.labor.cost'],
+ ['method','=','generate_report'],
+ ]
+ for cj in get_model('cron.job').search_browse(dom):
+ cj.write({
+ 'state': 'waiting',
+ })
+ vals={
+ 'to_id': get_active_user(),
+ 'subject': 'Generate Report',
+ 'body': """
+ Please wait until report is generated.
+ """,
+ }
+ db=get_connection()
+ get_model("message").create(vals)
+ db.commit()
+
def generate_report(self,ids,context={}):
obj=self.browse(ids)[0]
# clear and reload
obj.reload()
-
def load_report(fname,link):
+ host=config.config['host']
+ port=config.config['port']
+ hostname='http://%s:%s/'%(host,port)
+ link=hostname+link
req=urllib.request.Request(link)
response=urllib.request.urlopen(req)
data=response.read()
@@ -134,15 +159,15 @@ class PrintLaborCost(Model):
})
db.commit()
-
+
# generate labor costs
lcname='labor.cost.xlsx'
- link='http://localhost:9999/report_export_xls?model=clinic.report.labor.cost&template=report_labor_cost&active_id=%s'%(lc_id)
+ link='report_export_xls?model=clinic.report.labor.cost&template=report_labor_cost&active_id=%s'%(lc_id)
load_report(lcname,link)
# generate labor cost summary
sum_name='labor.cost-summary.xlsx'
- link='http://localhost:9999/report_export_xls?model=clinic.report.labor.cost.summary&template=report_labor_cost_summary&active_id=%s'%(sum_id)
+ link='report_export_xls?model=clinic.report.labor.cost.summary&template=report_labor_cost_summary&active_id=%s'%(sum_id)
load_report(sum_name,link)
obj.write({
@@ -197,13 +222,22 @@ class PrintLaborCost(Model):
report_line['field_name']: report_id,
})
db.commit()
- link='http://localhost:9999/report_export_xls?model=%s&template=%s&active_id=%s'%(report_model,report_template,report_obj.id)
+ link='report_export_xls?model=%s&template=%s&active_id=%s'%(report_model,report_template,report_obj.id)
load_report(fname,link)
line.write({
report_file: fname,
})
db.commit()
print("Done!")
+ vals={
+ 'to_id': get_active_user(),
+ 'subject': 'Generate Report',
+ 'body': """
+ Finish to generate report.
+ """,
+ }
+ get_model("message").create(vals)
+ db.commit()
def _get_date_from(self,context={}):
year,month,day=time.strftime("%Y-%m-%d").split("-")