diff --git a/netforce_clinic/actions/clinic_print_labor_cost.xml b/netforce_clinic/actions/clinic_print_labor_cost.xml
index fdd6673..262a840 100644
--- a/netforce_clinic/actions/clinic_print_labor_cost.xml
+++ b/netforce_clinic/actions/clinic_print_labor_cost.xml
@@ -1,9 +1,7 @@
- clinic_print_labor_cost
- form_view
+ Print Labor Cost
+ multi_view
clinic.print.labor.cost
- clinic_print_labor_cost
- 1
account_menu
diff --git a/netforce_clinic/layouts/clinic_print_labor_cost.xml b/netforce_clinic/layouts/clinic_print_labor_cost.xml
deleted file mode 100644
index 8296cdd..0000000
--- a/netforce_clinic/layouts/clinic_print_labor_cost.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
diff --git a/netforce_clinic/layouts/clinic_print_labor_cost_form.xml b/netforce_clinic/layouts/clinic_print_labor_cost_form.xml
new file mode 100644
index 0000000..6ed2143
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_print_labor_cost_form.xml
@@ -0,0 +1,17 @@
+
diff --git a/netforce_clinic/layouts/clinic_print_labor_cost_list.xml b/netforce_clinic/layouts/clinic_print_labor_cost_list.xml
new file mode 100644
index 0000000..2b8fff1
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_print_labor_cost_list.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/netforce_clinic/models/print_labor_cost.py b/netforce_clinic/models/print_labor_cost.py
index e663afd..91c5353 100644
--- a/netforce_clinic/models/print_labor_cost.py
+++ b/netforce_clinic/models/print_labor_cost.py
@@ -5,14 +5,31 @@ 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
+from netforce.access import get_active_user, get_active_company
import netforce.config as config
class PrintLaborCost(Model):
_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={
+ "name": fields.Char("Name",function="_get_name"),
"date": fields.Date("Month"),
"period_id": fields.Many2One("clinic.period.line","Period"),
"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"),
'report_summary': fields.File("Summary"),
'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={}):
obj=self.browse(ids)[0]
context['defaults']={
@@ -182,8 +236,6 @@ class PrintLaborCost(Model):
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_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:
staff=line.staff_id
@@ -231,7 +283,6 @@ class PrintLaborCost(Model):
report_file: fname,
})
db.commit()
- print("Done!")
vals={
'to_id': get_active_user(),
'subject': 'Generate Report',
@@ -241,38 +292,6 @@ class PrintLaborCost(Model):
}
get_model("message").create(vals)
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={}):
data=context['data']
@@ -301,4 +320,5 @@ class PrintLaborCost(Model):
data['date_to']=period.date_stop
return data
+
PrintLaborCost.register()