diff --git a/netforce_clinic/actions/clinic_cycle_item.xml b/netforce_clinic/actions/clinic_cycle_item.xml
index 821c85b..7e152bd 100644
--- a/netforce_clinic/actions/clinic_cycle_item.xml
+++ b/netforce_clinic/actions/clinic_cycle_item.xml
@@ -5,4 +5,5 @@
list,form
[["All",[]],["Draft",[["state","=","draft"]]],["Done",[["state","=","done"]]]]
clinic_menu
+ 25
diff --git a/netforce_clinic/actions/clinic_hd_case.xml b/netforce_clinic/actions/clinic_hd_case.xml
index 3ac12b7..e871389 100644
--- a/netforce_clinic/actions/clinic_hd_case.xml
+++ b/netforce_clinic/actions/clinic_hd_case.xml
@@ -5,4 +5,5 @@
[["All",[]],["Draft",[["state","=","draft"]]],["Waiting Treatment",[["state","=","waiting_treatment"]]],["In Progress",[["state","=","in_progress"]]],["Waiting Payment",[["state","=","waiting_payment"]]],["Waiting Approval",[["state","=","waiting_approval"]]],["Completed",[["state","=","completed"]]],["Cancelled",[["state","=","cancelled"]]]]
list,form
clinic_menu
+ 25
diff --git a/netforce_clinic/actions/clinic_patient.xml b/netforce_clinic/actions/clinic_patient.xml
index fea87f2..6a59376 100644
--- a/netforce_clinic/actions/clinic_patient.xml
+++ b/netforce_clinic/actions/clinic_patient.xml
@@ -5,4 +5,5 @@
[["All",[]],["Archived",[["active","=","False"]]]]
clinic_menu
+ 25
diff --git a/netforce_clinic/actions/clinic_staff.xml b/netforce_clinic/actions/clinic_staff.xml
index 85eec9a..b0f69a8 100644
--- a/netforce_clinic/actions/clinic_staff.xml
+++ b/netforce_clinic/actions/clinic_staff.xml
@@ -5,4 +5,5 @@
[["All",[]],["Archived",[["active","=",false]]],["Doctor",[["type","=","doctor"]]],["Nurse",[["type","=","nurse"]]]]
list,page,form
clinic_menu
+ 25
diff --git a/netforce_clinic/actions/clinic_visit.xml b/netforce_clinic/actions/clinic_visit.xml
index 7108110..de14e33 100644
--- a/netforce_clinic/actions/clinic_visit.xml
+++ b/netforce_clinic/actions/clinic_visit.xml
@@ -5,4 +5,5 @@
[["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]],["Cancelled",[["state","=","cancelled"]]]]
list,form,calendar
clinic_menu
+ 25
diff --git a/netforce_clinic/layouts/import_clinic_payment_form.xml b/netforce_clinic/layouts/import_clinic_payment_form.xml
index 35f2227..2074baf 100644
--- a/netforce_clinic/layouts/import_clinic_payment_form.xml
+++ b/netforce_clinic/layouts/import_clinic_payment_form.xml
@@ -66,6 +66,7 @@
+
diff --git a/netforce_clinic/models/import_hd_case.py b/netforce_clinic/models/import_hd_case.py
index 7578e11..609fbe8 100644
--- a/netforce_clinic/models/import_hd_case.py
+++ b/netforce_clinic/models/import_hd_case.py
@@ -64,7 +64,6 @@ class ImportHDCase(Model):
msg=""
max_row=obj.max_row
count=0
- nofound=0
did=0
blank=0
fail_qty=0
@@ -80,10 +79,11 @@ class ImportHDCase(Model):
hcode=str(hcode)
if not obj.hcode_id.code==hcode:
if hcode:
- nofound+=1
if hcode!='0':
msg+="not found %s, %s, %s \n"%(hcode,hn,name)
fail_qty+=1
+ else:
+ blank+=1
else:
blank+=1
continue
@@ -147,25 +147,27 @@ class ImportHDCase(Model):
msg+="confirm visit %s\n"%(visit.visit_date)
else:
did+=1
- #print("not found visit for %s on %s"%(name,date))
else:
pass
- remain_row=len(lines)-blank-did-count
+ total_row=len(lines)
+ remain_row=total_row-blank-did-count
if remain_row <= 0:
msg="Nothing to import"
final_msg=''
- total_row=len(lines)
- if done_qty <=0:
+
+ if done_qty <=0 and did==0:
final_msg="Please import visit first"
+ raise Exception(final_msg)
+ elif done_qty <=0 and did!=0:
+ final_msg="Nothing to import"
total_row=0
done_qty=0
fail_qty=0
remain_row=0
- else:
- final_msg="Done!"
+ else: final_msg="Done!"
obj.write({
'total_row': total_row,
- 'remain_row': remain_row,
+ 'remain_row': remain_row+1, # XXX
'msg': msg,
'done_qty': done_qty and done_qty-1 or 0,
'fail_qty': fail_qty,
diff --git a/netforce_clinic/models/import_payment.py b/netforce_clinic/models/import_payment.py
index 06432bb..e81ac16 100644
--- a/netforce_clinic/models/import_payment.py
+++ b/netforce_clinic/models/import_payment.py
@@ -3,12 +3,14 @@ from datetime import datetime, timedelta
from calendar import monthrange
from netforce.model import Model, fields, get_model
+from netforce.access import get_active_company
from netforce.utils import get_file_path
from . import utils
class ImportPayment(Model):
_name="import.clinic.payment"
_string="Clinic Payment"
+ _multi_company=True
def _get_name(self,ids,context={}):
res={}
@@ -37,6 +39,8 @@ class ImportPayment(Model):
'match_lines': fields.One2Many("import.clinic.payment.line","import_payment_id","Match",domain=[["state","=","match"]]),
'unmatch_lines': fields.One2Many("import.clinic.payment.line","import_payment_id","UnMatch",domain=[["state","=","unmatch"]]),
'payment_id': fields.Many2One("account.payment","Payment"),
+ 'company_id': fields.Many2One("company","Company"),
+ 'partner_id': fields.Many2One("partner","Partner"),
}
def get_hcode_id(self,context={}):
@@ -63,6 +67,7 @@ class ImportPayment(Model):
'date_from': _get_date_from,
'date_to': _get_date_to,
'hcode_id': get_hcode_id,
+ 'company_id': lambda *a: get_active_company(),
'max_row': 50,
'state': 'draft',
}
@@ -203,5 +208,51 @@ class ImportPayment(Model):
})
print("Done!")
+ def approve(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ partner=obj.patient_id.partner_id
+ if not partner:
+ raise Exception("No contact on this patient")
+ company_id=get_active_company()
+ account_receivable_id=partner.account_receivable_id
+ if not account_receivable_id:
+ st=get_model('settings').browse(1)
+ account_receivable_id=st.account_receivable_id
+ if not account_receivable_id:
+ raise Exception("Not found account recieveable in account setting")
+ account_id=account_receivable_id.id
+ if not account_id:
+ raise Exception("No Account for payment")
+ vals={
+ "partner_id": partner.id,
+ "company_id": company_id,
+ "type": "in",
+ "pay_type": "invoice",
+ 'date': time.strftime("%Y-%m-%d"),
+ "account_id": account_id,
+ 'related_id': "clinic.hd.case,%s"%obj.id,
+ 'invoice_lines': [],
+ }
+
+ vals['invoice_lines'].append(('create',{
+ 'type': 'invoice',
+ 'description': 'Payment; %s'%obj.number,
+ 'account_id': account_id,
+ 'qty': 1,
+ 'unit_price': pay_amount,
+ 'amount': pay_amount,
+ }))
+
+ payment_id=get_model("account.payment").create(vals,context={"type":"in"})
+ #payment=get_model('account.payment').browse(payment_id)
+ #payment.post()
+ return {
+ 'next': {
+ 'name': 'import_clinic_payment',
+ 'mode': 'form',
+ 'active_id': obj.id,
+ },
+ 'flash': 'Done!',
+ }
ImportPayment.register()