diff --git a/netforce_clinic/actions/clinic_cycle_dialy.xml b/netforce_clinic/actions/clinic_cycle_daily.xml
similarity index 53%
rename from netforce_clinic/actions/clinic_cycle_dialy.xml
rename to netforce_clinic/actions/clinic_cycle_daily.xml
index dba30fd..29643ad 100644
--- a/netforce_clinic/actions/clinic_cycle_dialy.xml
+++ b/netforce_clinic/actions/clinic_cycle_daily.xml
@@ -1,8 +1,8 @@
- Cycle Dialy
+ Cycle Daily
multi_view
- clinic.cycle.dialy
- [["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]],["Done",[["state","=","done"]]]]
+ clinic.cycle.daily
+ [["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]]]
list,form
clinic_menu
diff --git a/netforce_clinic/actions/clinic_cycle_dialy.xml.old b/netforce_clinic/actions/clinic_cycle_dialy.xml.old
deleted file mode 100644
index 5df7a10..0000000
--- a/netforce_clinic/actions/clinic_cycle_dialy.xml.old
+++ /dev/null
@@ -1,11 +0,0 @@
-
- Cycle Dialy
- report_view
- clinic.cycle.item
-
- date
- cycle_id
-
-
- clinic_menu
-
diff --git a/netforce_clinic/actions/clinic_cycle_monthly.xml b/netforce_clinic/actions/clinic_cycle_monthly.xml
new file mode 100644
index 0000000..b4eadea
--- /dev/null
+++ b/netforce_clinic/actions/clinic_cycle_monthly.xml
@@ -0,0 +1,8 @@
+
+ Cycle Monthly
+ multi_view
+ clinic.cycle.monthly
+ [["All",[]],["Draft",[["state","=","draft"]]],["Approved",[["state","=","approved"]]]]
+ list,form
+ clinic_menu
+
diff --git a/netforce_clinic/actions/clinic_hd_case_dialy.xml b/netforce_clinic/actions/clinic_hd_case_daily.xml
similarity index 66%
rename from netforce_clinic/actions/clinic_hd_case_dialy.xml
rename to netforce_clinic/actions/clinic_hd_case_daily.xml
index 5a13d45..898f79a 100644
--- a/netforce_clinic/actions/clinic_hd_case_dialy.xml
+++ b/netforce_clinic/actions/clinic_hd_case_daily.xml
@@ -1,8 +1,8 @@
- HD Case Dialy
+ HD Case Daily
report
- clinic.hd.case.dialy
- hd_case_dialy
- hd_case_dialy
+ clinic.hd.case.daily
+ hd_case_daily
+ hd_case_daily
clinic_menu
diff --git a/netforce_clinic/layouts/clinic_cycle_dialy_form.xml b/netforce_clinic/layouts/clinic_cycle_daily_form.xml
similarity index 96%
rename from netforce_clinic/layouts/clinic_cycle_dialy_form.xml
rename to netforce_clinic/layouts/clinic_cycle_daily_form.xml
index 2be38c1..5674a30 100644
--- a/netforce_clinic/layouts/clinic_cycle_dialy_form.xml
+++ b/netforce_clinic/layouts/clinic_cycle_daily_form.xml
@@ -1,4 +1,4 @@
-
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index cd0de0f..8b369ae 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -32,8 +32,10 @@ from . import cycle
from . import cycle_item
from . import cycle_item_nurse
from . import cycle_item_line
-from . import cycle_dialy
-from . import cycle_dialy_line
+from . import cycle_daily
+from . import cycle_daily_line
+from . import cycle_monthly
+from . import cycle_monthly_line
from . import gen_visit
from . import gen_visit_line
from . import fin_setting
diff --git a/netforce_clinic/models/cycle_dialy.py b/netforce_clinic/models/cycle_daily.py
similarity index 87%
rename from netforce_clinic/models/cycle_dialy.py
rename to netforce_clinic/models/cycle_daily.py
index aa3fb21..4404762 100644
--- a/netforce_clinic/models/cycle_dialy.py
+++ b/netforce_clinic/models/cycle_daily.py
@@ -4,9 +4,9 @@ from netforce.model import Model, fields
from netforce.access import get_active_company, get_active_user
from netforce.utils import get_data_path
-class CycleDialy(Model):
- _name="clinic.cycle.dialy"
- _string="Cycle Dialy"
+class CycleDaily(Model):
+ _name="clinic.cycle.daily"
+ _string="Cycle Daily"
def _get_all(self,ids,context={}):
res={}
@@ -22,9 +22,9 @@ class CycleDialy(Model):
_fields={
"name": fields.Char("Name"),
'date': fields.Date("Date", required=True, search=True),
- 'cycle_items': fields.One2Many("clinic.cycle.item","cycle_dialy_id", "Cycle Items"),
- 'lines': fields.One2Many("clinic.cycle.dialy.line","cycle_dialy_id", "Lines"),
- "state": fields.Selection([("draft","Draft"),('confirmed','Confirmed'),("done","Done")],"Status",required=True),
+ 'cycle_items': fields.One2Many("clinic.cycle.item","cycle_daily_id", "Cycle Items"),
+ 'lines': fields.One2Many("clinic.cycle.daily.line","cycle_daily_id", "Lines"),
+ "state": fields.Selection([("draft","Draft"),('confirmed','Confirmed')],"Status",required=True),
'company_id': fields.Many2One("company","Company"),
'total': fields.Float("Total",function="_get_all", function_multi=True),
'user_id': fields.Many2One("base.user","User"),
@@ -51,7 +51,7 @@ class CycleDialy(Model):
})
return {
'next': {
- 'name': 'clinic_cycle_dialy',
+ 'name': 'clinic_cycle_daily',
'mode': 'form',
'active_id': obj.id,
},
@@ -73,7 +73,7 @@ class CycleDialy(Model):
context=ctx
return {
'next': {
- 'name': 'clinic_cycle_dialy',
+ 'name': 'clinic_cycle_daily',
'mode': 'form',
'active_id': obj.id,
},
@@ -88,7 +88,7 @@ class CycleDialy(Model):
})
return {
'next': {
- 'name': 'clinic_cycle_dialy',
+ 'name': 'clinic_cycle_daily',
'mode': 'form',
'active_id': obj.id,
},
@@ -110,4 +110,4 @@ class CycleDialy(Model):
data['total']=total
return data
-CycleDialy.register()
+CycleDaily.register()
diff --git a/netforce_clinic/models/cycle_dialy_line.py b/netforce_clinic/models/cycle_daily_line.py
similarity index 78%
rename from netforce_clinic/models/cycle_dialy_line.py
rename to netforce_clinic/models/cycle_daily_line.py
index 9fefa9d..a021e7b 100644
--- a/netforce_clinic/models/cycle_dialy_line.py
+++ b/netforce_clinic/models/cycle_daily_line.py
@@ -1,12 +1,12 @@
from netforce.model import Model, fields
from netforce.access import get_active_company
-class CycleDialyLine(Model):
- _name="clinic.cycle.dialy.line"
- _string="Cycle Dialy Line"
+class CycleDailyLine(Model):
+ _name="clinic.cycle.daily.line"
+ _string="Cycle Daily Line"
_fields={
- "cycle_dialy_id": fields.Many2One("clinic.cycle.dialy","Cycle Dialy"),
+ "cycle_daily_id": fields.Many2One("clinic.cycle.daily","Cycle Daily"),
'cycle_id': fields.Many2One("clinic.cycle", "Cycle"),
'staff_id': fields.Many2One("clinic.staff", "Staff"),
'level_id': fields.Many2One("clinic.staff.level", "Level"),
@@ -23,4 +23,4 @@ class CycleDialyLine(Model):
}
-CycleDialyLine.register()
+CycleDailyLine.register()
diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py
index 51cbb90..b114e36 100644
--- a/netforce_clinic/models/cycle_item.py
+++ b/netforce_clinic/models/cycle_item.py
@@ -42,7 +42,7 @@ class CycleItem(Model):
'name': fields.Char("Name", function="_get_all",function_multi=True),
'date': fields.Date("Date",search=True),
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
- 'cycle_dialy_id': fields.Many2One("clinic.cycle.dialy", "Cycle Dialy",search=True),
+ 'cycle_daily_id': fields.Many2One("clinic.cycle.daily", "Cycle Daily",search=True),
'lines': fields.One2Many("clinic.cycle.item.line","item_id", "Lines"),
'visits': fields.One2Many("clinic.visit","cycle_item_id", "Visits"),
'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"),
@@ -79,16 +79,16 @@ class CycleItem(Model):
("cycle_item_uniq","unique (cycle_id,date,company_id)","Cycle item should be unique"),
]
- def get_cycle_diary(self,date):
+ def get_cycle_daily(self,date):
dom=[]
print("get ", date)
dom.append(['date','=',date])
- cd_ids=get_model('clinic.cycle.dialy').search(dom)
+ cd_ids=get_model('clinic.cycle.daily').search(dom)
cd_id=None
if cd_ids:
cd_id=cd_ids[0]
else:
- cd_id=get_model('clinic.cycle.dialy').create({
+ cd_id=get_model('clinic.cycle.daily').create({
'date':date,
'name':date,
})
@@ -98,7 +98,7 @@ class CycleItem(Model):
def create(self, vals,**kw):
date=vals['date']
cycle_id=vals['cycle_id']
- vals['cycle_dialy_id']=self.get_cycle_diary(date)
+ vals['cycle_daily_id']=self.get_cycle_daily(date)
cycle=get_model("clinic.cycle").browse(cycle_id)
vals['sequence']='%s-%s'%(date,cycle.sequence) #date-sequence
@@ -109,13 +109,12 @@ class CycleItem(Model):
obj=self.browse(ids)[0]
cycle=obj.cycle_id
date=vals.get('date') and vals.get('date') or obj.date
- vals['cycle_dialy_id']=self.get_cycle_diary(date)
+ vals['cycle_daily_id']=self.get_cycle_daily(date)
vals['sequence']='%s-%s'%(obj.date,cycle.sequence) #date-sequence
super().write(ids,vals,**kw)
def validate(self,ids,context={}):
obj=self.browse(ids)[0]
- # copy list of nurse to cycle.dialy.line
levels={}
for line in obj.lines:
level=line.level_id
@@ -172,9 +171,9 @@ class CycleItem(Model):
'type': type,
}))
- cycle_dialy=obj.cycle_dialy_id
+ cycle_daily=obj.cycle_daily_id
# clear cost line
- for line in cycle_dialy.lines:
+ for line in cycle_daily.lines:
cycle=line.cycle_id
if obj.cycle_id.id==cycle.id: # only own cycle
line.delete()
@@ -217,7 +216,7 @@ class CycleItem(Model):
if context.get('called'):
return lines
- cycle_dialy.write({
+ cycle_daily.write({
'lines': lines,
})
@@ -227,9 +226,9 @@ class CycleItem(Model):
return {
'next': {
- 'name': 'clinic_cycle_dialy',
+ 'name': 'clinic_cycle_daily',
'mode': 'form',
- 'active_id': cycle_dialy.id,
+ 'active_id': cycle_daily.id,
},
'flash': 'Cycle Item has been validated, please see the detail of cost below.',
}
@@ -407,15 +406,15 @@ class CycleItem(Model):
}
}
- def view_cycle_dialy(self,ids,context={}):
+ def view_cycle_daily(self,ids,context={}):
obj=self.browse(ids)[0]
- if not obj.cycle_dialy_id:
+ if not obj.cycle_daily_id:
raise Exception("Please validate cycle item")
return {
'next': {
- 'name': 'clinic_cycle_dialy',
+ 'name': 'clinic_cycle_daily',
'mode': 'form',
- 'active_id': obj.cycle_dialy_id.id,
+ 'active_id': obj.cycle_daily_id.id,
}
}
diff --git a/netforce_clinic/models/cycle_monthly.py b/netforce_clinic/models/cycle_monthly.py
new file mode 100644
index 0000000..da851fe
--- /dev/null
+++ b/netforce_clinic/models/cycle_monthly.py
@@ -0,0 +1,97 @@
+import time
+
+from netforce.model import Model, fields
+from netforce.access import get_active_company, get_active_user
+from netforce.utils import get_data_path
+
+class CycleMonthly(Model):
+ _name="clinic.cycle.monthly"
+ _string="Cycle Monthly"
+
+ def _get_all(self,ids,context={}):
+ res={}
+ for obj in self.browse(ids):
+ total=0.0
+ for line in obj.lines:
+ total+=(line.amount or 0)
+ res[obj.id]={
+ 'total': total,
+ }
+ return res
+
+ _fields={
+ "name": fields.Char("Name"),
+ 'month': fields.Date("Month", required=True, search=True),
+ 'cycle_dailies': fields.One2Many("clinic.cycle.daily","cycle_monthly_id", "Cycle Dialies"),
+ 'lines': fields.One2Many("clinic.cycle.monthly.line","cycle_monthly_id", "Lines"),
+ 'company_id': fields.Many2One("company","Company"),
+ 'total': fields.Float("Total",function="_get_all", function_multi=True),
+ 'user_id': fields.Many2One("base.user","User"),
+ "state": fields.Selection([("draft","Draft"),('approved','Approved')],"Status",required=True),
+ }
+
+ _defaults={
+ 'company_id': lambda *a: get_active_company(),
+ 'month': lambda *a: time.strftime("%Y-%m-%d"),
+ 'name': lambda *a: time.strftime("%Y-%m-%d"),
+ 'user_id': lambda *a: get_active_user(),
+ 'state': 'draft',
+ }
+
+ def write(self,ids,vals,**kw):
+ date=vals.get('month','')
+ if date:
+ vals['name']=date
+ super().write(ids,vals,**kw)
+
+ def approve(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ obj.write({
+ 'state': 'approved',
+ })
+ return {
+ 'next': {
+ 'name': 'clinic_cycle_monthly',
+ 'mode': 'form',
+ 'active_id': obj.id,
+ },
+ 'flash':'Approved',
+ }
+
+ def recheck_daily(self,ids,context={}):
+ # copy cost of nurse and doctor from cycle item
+ obj=self.browse(ids)[0]
+ lines=[]
+ ctx=context.copy()
+ context['called']=True
+ for cycle_daily in obj.dailies:
+ lines+=cycle_daily.confirm(context=context)
+ obj.write({
+ 'lines': lines,
+ })
+ context=ctx
+ return {
+ 'next': {
+ 'name': 'clinic_cycle_monthly',
+ 'mode': 'form',
+ 'active_id': obj.id,
+ },
+ 'flash':'Recheck successfully',
+ }
+
+ def onchange_line(self,context={}):
+ data=context['data']
+ path=context['path']
+ line=get_data_path(data,path,parent=True)
+ qty=line['qty']
+ rate=line['rate']
+ line['amount']=qty*rate
+ total=0.0
+ for line in data['lines']:
+ qty=line['qty']
+ rate=line['rate']
+ total+=qty*rate
+ data['total']=total
+ return data
+
+CycleMonthly.register()
diff --git a/netforce_clinic/models/cycle_monthly_line.py b/netforce_clinic/models/cycle_monthly_line.py
new file mode 100644
index 0000000..eade95e
--- /dev/null
+++ b/netforce_clinic/models/cycle_monthly_line.py
@@ -0,0 +1,24 @@
+from netforce.model import Model, fields
+from netforce.access import get_active_company
+
+class CycleMonthlyLine(Model):
+ _name="clinic.cycle.monthly.line"
+ _string="Cycle Monthly Line"
+
+ _fields={
+ "cycle_monthly_id": fields.Many2One("clinic.cycle.monthly","Cycle Monthly"),
+ 'staff_id': fields.Many2One("clinic.staff", "Staff"),
+ 'level_id': fields.Many2One("clinic.staff.level", "Level"),
+ 'qty': fields.Integer("Qty"),
+ 'rate': fields.Float("Rate"),
+ 'amount': fields.Float("Amount"),
+ 'company_id': fields.Many2One("company","Company"),
+ "type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Type",required=True),
+ }
+
+ _defaults={
+ 'company_id': lambda *a: get_active_company(),
+ }
+
+
+CycleMonthlyLine.register()
diff --git a/netforce_clinic/models/report_nurse_fee_detail.py b/netforce_clinic/models/report_nurse_fee_detail.py
index 80f3443..9b769c4 100644
--- a/netforce_clinic/models/report_nurse_fee_detail.py
+++ b/netforce_clinic/models/report_nurse_fee_detail.py
@@ -65,12 +65,12 @@ class ReportNurseFeeDetail(Model):
staff=get_model("clinic.staff").browse(staff_id)
staff_name=staff.name
dom.append(['staff_id','=',staff.id])
- records=get_model('clinic.cycle.dialy.line').search_browse(dom)
+ dlines=get_model('clinic.cycle.daily.line').search_browse(dom)
# group by date
all_vals={}
- for record in records:
- date=record.date
- staff=record.staff_id
+ for dline in dlines:
+ date=dline.date
+ staff=dline.staff_id
if staff_type:
if staff_type!=staff.type:
continue
@@ -82,8 +82,8 @@ class ReportNurseFeeDetail(Model):
'staff_name': staff.name or "",
'amount': 0,
}
- all_vals[key]['qty']+=record.qty or 0
- all_vals[key]['amount']+=record.amount or 0
+ all_vals[key]['qty']+=dline.qty or 0
+ all_vals[key]['amount']+=dline.amount or 0
lines=[]
total_amount=0.0
diff --git a/netforce_clinic/models/report_nurse_fee_sum.py b/netforce_clinic/models/report_nurse_fee_sum.py
index 5f02474..9b60fc6 100644
--- a/netforce_clinic/models/report_nurse_fee_sum.py
+++ b/netforce_clinic/models/report_nurse_fee_sum.py
@@ -92,14 +92,14 @@ class ReportNurseFeeSum(Model):
dom.append(['date','=',date])
dom.append(['staff_id','=',nurse.id])
amt=0
- results=get_model("clinic.cycle.dialy.line").search_read(dom,['amount','cycle_dialy_id'])
- cycle_dialy_id=None
+ results=get_model("clinic.cycle.daily.line").search_read(dom,['amount','cycle_daily_id'])
+ cycle_daily_id=None
if results:
for result in results:
amt+=result['amount'] or 0.0
- cycle_dialy_id=result['cycle_dialy_id'][0]
+ cycle_daily_id=result['cycle_daily_id'][0]
line['sub_lines'].append({
- 'cycle_dialy_id': cycle_dialy_id,
+ 'cycle_daily_id': cycle_daily_id,
'amt': amt,
'last': False,
})
diff --git a/netforce_clinic/models/schedule.py b/netforce_clinic/models/schedule.py
index bb5dce0..eda6545 100644
--- a/netforce_clinic/models/schedule.py
+++ b/netforce_clinic/models/schedule.py
@@ -16,7 +16,8 @@ class Schedule(Model):
count=0
for line in obj.lines:
nurse=line.nurse_id
- st+='%s %s\n'%(nurse.name, nurse.level_id.name or "")
+ level=line.level_id
+ st+='%s %s\n'%(nurse.name, level.name or "")
count+=1
res[obj.id]='%s'%(st if count else 'No nurse')
return res
@@ -65,12 +66,28 @@ class Schedule(Model):
obj.write({
'state': 'confirmed',
})
+ return {
+ 'next': {
+ 'name': 'clinic_schedule',
+ 'mode': 'form',
+ 'active_id': obj.id,
+ },
+ 'flash': 'Schedule %s has been confirmed'%obj.date,
+ }
def to_draft(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({
'state': 'draft',
})
+ return {
+ 'next': {
+ 'name': 'clinic_schedule',
+ 'mode': 'form',
+ 'active_id': obj.id,
+ },
+ 'flash': 'Schedule %s has been set to draft'%obj.date,
+ }
def copy(self,ids,context={}):
diff --git a/netforce_clinic/models/schedule_line.py b/netforce_clinic/models/schedule_line.py
index b4a4f9c..c20aa47 100644
--- a/netforce_clinic/models/schedule_line.py
+++ b/netforce_clinic/models/schedule_line.py
@@ -7,7 +7,12 @@ class ScheduleLine(Model):
def _get_level(self,ids,context={}):
res={}
for obj in self.browse(ids):
- res[obj.id]=obj.nurse_id.level_id.id
+ nurse=obj.nurse_id
+ level=nurse.level_id
+ level_id=None
+ if level:
+ level_id=level.id
+ res[obj.id]=level_id
return res
_fields={
diff --git a/netforce_clinic/reports/hd_case_dialy.xlsx b/netforce_clinic/reports/hd_case_daily.xlsx
similarity index 100%
rename from netforce_clinic/reports/hd_case_dialy.xlsx
rename to netforce_clinic/reports/hd_case_daily.xlsx
diff --git a/netforce_clinic/templates/hd_case_dialy.hbs b/netforce_clinic/templates/hd_case_daily.hbs
similarity index 100%
rename from netforce_clinic/templates/hd_case_dialy.hbs
rename to netforce_clinic/templates/hd_case_daily.hbs