diff --git a/netforce_clinic/actions/clinic_hd_case.xml b/netforce_clinic/actions/clinic_hd_case.xml
index d0398be..e6f021c 100644
--- a/netforce_clinic/actions/clinic_hd_case.xml
+++ b/netforce_clinic/actions/clinic_hd_case.xml
@@ -2,7 +2,7 @@
Treatments
multi_view
clinic.hd.case
- [["All",[]],["Draft",[["state","=","draft"]]],["In Progress",[["state","=","in_progress"]]],["Completed",[["state","=","completed"]]],["Uncompleted",[["state","=","uncompleted"]]]]
+ [["All",[]],["Draft",[["state","=","draft"]]],["In Progress",[["state","=","in_progress"]]],["Completed",[["state","=","completed"]]],["In Completed",[["state","=","in_completed"]]]]
list,form
clinic_menu
diff --git a/netforce_clinic/layouts/clinic_dialyzer_form.xml b/netforce_clinic/layouts/clinic_dialyzer_form.xml
index 5df8cbb..a2d9cc7 100644
--- a/netforce_clinic/layouts/clinic_dialyzer_form.xml
+++ b/netforce_clinic/layouts/clinic_dialyzer_form.xml
@@ -23,8 +23,8 @@
-
-
+
+
diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml
index 183a1fd..d03cdb9 100644
--- a/netforce_clinic/layouts/clinic_hd_case_form.xml
+++ b/netforce_clinic/layouts/clinic_hd_case_form.xml
@@ -27,10 +27,10 @@
-
+
-
+
@@ -89,9 +89,10 @@
-
-
-
+
+
+
+
diff --git a/netforce_clinic/models/dialyzer.py b/netforce_clinic/models/dialyzer.py
index 81b85af..85a57a2 100644
--- a/netforce_clinic/models/dialyzer.py
+++ b/netforce_clinic/models/dialyzer.py
@@ -152,6 +152,7 @@ class Dialyzer(Model):
for obj in self.browse(ids):
if obj.state != 'new':
raise Exception("Can not delete Dializer %s because state is not 'new'"%obj.number)
+ super().delete(ids)
def cancel(self,ids,context={}):
obj=self.browse(ids[0])
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index 9236750..90d1f63 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -1,5 +1,5 @@
import time
-from datetime import datetime, timedelta
+from datetime import datetime
from netforce.model import Model, fields, get_model
from netforce.utils import get_data_path
@@ -43,9 +43,8 @@ class HDcase(Model):
"hct": fields.Integer("HCT %", required=True),
"check_goverment_pay" : fields.Boolean("The Government Pay"),
"check_personal_pay" : fields.Boolean("Pay yourself"),
- "state": fields.Selection([("draft","Draft"),("confirmed","Confirmed"),("approved","Approved"),("cancelled","Cancelled"),("paid","Paid")],"Status",required=True),
- "hct": fields.Integer("HCT %"),
- "state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("discountinued","Discountinued"),("uncompleted","Uncompleted")],"Status",required=True),
+ "hct": fields.Integer("HCT %(>39)"),
+ "state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("discountinued","Discountinued"),("in_completed","In completed")],"Status",required=True),
"dialyzers": fields.One2Many("clinic.dialyzer.line","hd_case_id","Dialyzers"),
"lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Lines"),
"gm_lines": fields.One2Many("clinic.hd.case.gm.line","hd_case_id","GM Lines"),
@@ -109,8 +108,16 @@ class HDcase(Model):
if not dialyzer_id:
return {}
dialyzer=get_model("clinic.dialyzer").browse(dialyzer_id)
+ use_time=dialyzer.use_time or 0
+ max_time=dialyzer.max_use_time or 0
+ if use_time > max_time:
+ dialyzer.write({
+ 'state': 'expire',
+ })
+ raise Exception("%s is expired"%dialyzer.number)
+ use_time+=1
line["description"]=dialyzer.description or ""
- line["use_time"]=dialyzer.use_time
+ line["use_time"]=use_time
line["max_use_time"]=dialyzer.max_use_time
line["member_type"]=dialyzer.member_type
line["dialyzer_type"]=dialyzer.dialyzer_type
@@ -165,11 +172,11 @@ class HDcase(Model):
return data
def onchange_hct(self,context={}):
- data=context['hct']
+ data=context['data']
hct=data['hct']
if(hct<=39):
- raise Exception("Unit not found in uom")
-
+ data['hct']=0
+ return data
def cancelled(self,ids,context={}):
obj=self.browse(ids)[0]
@@ -209,7 +216,6 @@ class HDcase(Model):
def make_payment(self,ids,context={}):
pass
-
def make_invoices(self,ids,context={}):
setting=get_model("settings").browse(1)
currency_id=setting.currency_id.id
@@ -356,21 +362,31 @@ class HDcase(Model):
inv.post()
print("Post!")
- def confirm(self,ids,context={}):
+ def do_treatment(self,ids,context={}):
obj=self.browse(ids)[0]
+ if not obj.dialyzers:
+ raise Exception("Can not do treatment without dialyzer!")
obj.write({"state":"in_progress"})
def discontinue(self,ids,context={}):
obj=self.browse(ids)[0]
# TODO pop to note
- obj.write({"state":"uncompleted"})
-
+ obj.write({"state":"in_completed"})
+
+ def update_usetime(self,ids,context={}):
+ for obj in self.browse(ids):
+ for dlz_line in obj.dialyzers:
+ dlz=dlz_line.dialyzer_id
+ dlz.write({
+ 'use_time': dlz_line.use_time,
+ })
+ return True
+
def complete(self,ids,context={}):
obj=self.browse(ids)[0]
- if not obj.dialyzers:
- raise Exception("Please enter dialyzer!")
obj.make_invoices()
obj.post_invoices()
+ obj.update_usetime()
obj.write({
"state":"completed",
})
@@ -443,4 +459,29 @@ class HDcase(Model):
data['fee']=0.0
return data
+ def undo(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ for inv in obj.invoices:
+ inv.write({
+ 'state': 'draft',
+ })
+ inv.delete()
+ for pick in obj.pickings:
+ pick.write({
+ 'state': 'draft',
+ })
+ pick.delete()
+
+ obj.write({
+ 'state': 'draft',
+ })
+ return {
+ 'next': {
+ 'name': 'clinic_hd_case',
+ 'mode': 'form',
+ 'active_id': obj.id,
+ },
+ 'flash': '%s has been undo'%obj.number,
+ }
+
HDcase.register()
diff --git a/netforce_clinic/models/import_payment.py b/netforce_clinic/models/import_payment.py
index a84e474..99c1ebe 100644
--- a/netforce_clinic/models/import_payment.py
+++ b/netforce_clinic/models/import_payment.py
@@ -53,21 +53,7 @@ class ImportPayment(Model):
}
def load_data(self,ids,context):
- records=[1,2,]
- del records[0]
- fmt1="%y-%m-%d"
- fmt2="%Y-%m-%d"
- for record in records:
- row=record.split(",")
- doc_date=row[0]
- if doc_date:
- #'%m/%d/%y
- pt="(\d+)/(\d+)/(\d+)"
- res=re.search(pt,doc_date)
- if res:
- doc_date="%s-%s-%s" % (res.group(3),res.group(1),res.group(2))
- newdate=datetime.strptime(doc_date,fmt1)
- print(newdate.strftime(fmt2))
+ pass
def load_sheet(self,ids,context={}):
obj=self.browse(ids[0])
diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py
index b1c5bb1..3b028cf 100644
--- a/netforce_clinic/models/visit.py
+++ b/netforce_clinic/models/visit.py
@@ -112,8 +112,9 @@ class Visit(Model):
'lines':[],
'gm_lines':[],
'dialyzers': [],
- 'state': 'in_progress',
+ 'state': 'draft',
}
+
products=get_model("product").search_browse([['code','=','FEE']])
for product in products:
vals['gm_lines'].append(('create',{