diff --git a/netforce_clinic/layouts/clinic_account_setting.xml b/netforce_clinic/layouts/clinic_account_setting.xml
index d0ff53a..0585c21 100644
--- a/netforce_clinic/layouts/clinic_account_setting.xml
+++ b/netforce_clinic/layouts/clinic_account_setting.xml
@@ -55,6 +55,7 @@
+
diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml
index 2576196..17d8705 100644
--- a/netforce_clinic/layouts/clinic_hd_case_form.xml
+++ b/netforce_clinic/layouts/clinic_hd_case_form.xml
@@ -135,6 +135,7 @@
+
diff --git a/netforce_clinic/models/account_invoice.py b/netforce_clinic/models/account_invoice.py
index fccc873..224c0c1 100644
--- a/netforce_clinic/models/account_invoice.py
+++ b/netforce_clinic/models/account_invoice.py
@@ -434,4 +434,36 @@ class AccountInvoice(Model):
data['signature']=get_file_path(cst.signature)
return data
+ def pay_invoice(self, ids, context={}):
+ paid_inv=[]
+ for obj in self.browse(ids):
+ if obj.state!='waiting_payment':
+ continue
+ rel=obj.related_id
+ if rel and rel._model=='clinic.hd.case':
+ clinic_setting=get_model("clinic.setting").browse(1)
+ if not clinic_setting.hdcase_payment_account_id:
+ raise Exception("Missing HDCase Payment Account in setting!")
+ inv_pm_id=get_model("invoice.payment").create({
+ 'date': time.strftime("%Y-%m-%d"),
+ 'invoice_id': obj.id,
+ 'account_id': clinic_setting.hdcase_payment_account_id.id,
+ 'ref': rel.number,
+ 'amount': obj.amount_due,
+ })
+ inv_pm=get_model("invoice.payment").browse(inv_pm_id)
+ inv_pm.add_payment(context)
+ for pm_line in obj.payments:
+ pm=pm_line.payment_id
+ pm.write({
+ 'related_id': "clinic.hd.case,%s"%rel.id,
+ })
+ paid_inv.append(obj.number)
+ if not paid_inv:
+ raise Exception("Nothing to paid!")
+ return {
+ 'flash': 'Invoice: %s has been paid'%(','.join(paid_inv)),
+ }
+
+
AccountInvoice.register()
diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py
index a20b6ec..6046818 100644
--- a/netforce_clinic/models/setting.py
+++ b/netforce_clinic/models/setting.py
@@ -58,6 +58,7 @@ class ClinicSetting(Model):
"cash_account_id": fields.Many2One("account.account","Cash Account",multi_company=True),
"income_account_id": fields.Many2One("account.account","Income Account",multi_company=True),
"import_account_id": fields.Many2One("account.account","Import Account",multi_company=True),
+ "hdcase_payment_account_id": fields.Many2One("account.account","HDCase Payment Account",multi_company=True),
'helper_categ_id': fields.Many2One("clinic.staff.categ","Helper Category"),
'base_salary_day': fields.Float("Base Salary Day"),
'next_date': fields.DateTime("Next Gen"),