diff --git a/netforce_clinic/actions/report_clinic_payment_form.xml b/netforce_clinic/actions/report_clinic_payment_form.xml
new file mode 100644
index 0000000..7110519
--- /dev/null
+++ b/netforce_clinic/actions/report_clinic_payment_form.xml
@@ -0,0 +1,6 @@
+
+ report_odt
+ clinic.hd.case
+ get_report_payment_data
+ payment_form
+
diff --git a/netforce_clinic/layouts/clinic_hd_case_form.xml b/netforce_clinic/layouts/clinic_hd_case_form.xml
index 3408b5d..e38c8a4 100644
--- a/netforce_clinic/layouts/clinic_hd_case_form.xml
+++ b/netforce_clinic/layouts/clinic_hd_case_form.xml
@@ -119,7 +119,22 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index e2be6ea..342b8d4 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -38,3 +38,4 @@ from . import import_data_nhso
from . import import_data_sc
from . import translate
from . import payment
+from . import account_payment
diff --git a/netforce_clinic/models/account_payment.py b/netforce_clinic/models/account_payment.py
new file mode 100644
index 0000000..ad53ea9
--- /dev/null
+++ b/netforce_clinic/models/account_payment.py
@@ -0,0 +1,24 @@
+from netforce.model import Model, fields, get_model
+
+class AccountPayment(Model):
+ _inherit="account.payment"
+
+ def run_report(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ hd_case_id=obj.related_id.id
+ hd_case=get_model("clinic.hd.case").browse(hd_case_id)
+ # TODO
+ # set payment_id on hd case
+ # send to action print form payment
+ hd_case.write({
+ 'payment_id': obj.id,
+ })
+ return {
+ 'next': {
+ 'name': 'report_clinic_payment_form',
+ 'refer_id': hd_case_id,
+ 'payment_id': obj.id,
+ },
+ }
+
+AccountPayment.register()
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index ff0b5a7..7e05c5e 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -2,7 +2,7 @@ import time
from datetime import datetime
from netforce.model import Model, fields, get_model
-from netforce.utils import get_data_path
+from netforce.utils import get_data_path, get_file_path
from netforce.access import get_active_user,set_active_user
from netforce.access import get_active_company
@@ -72,6 +72,7 @@ class HDCase(Model):
'pay_amount': fields.Float("Amount",function="get_pay_amount"),
'pay_date': fields.Date("Pay Date"),
'pay_account_id': fields.Many2One("account.account","Account"),
+ 'payment_id': fields.Many2One("account.payment","Payment"), # for print
}
def _get_number(self,context={}):
@@ -579,5 +580,40 @@ class HDCase(Model):
obj.write({
'state': 'waiting_payment',
})
+
+ def get_report_payment_data(self,context={}):
+ settings=get_model("settings").browse(1)
+ refer_id=context.get("refer_id")
+ payment_id=context.get("payment_id")
+ data={
+ 'settings_address_text': settings.default_address_id and settings.default_address_id.get_address_text()[settings.default_address_id.id] or "",
+ 'logo': get_file_path(settings.logo) or "",
+ }
+ if refer_id:
+ pass
+ if payment_id:
+ #context['refer_id']=payment_id
+ #data=get_model("account.payment").get_report_data(context=context)
+ payment=get_model("account.payment").browse(int(payment_id))
+ partner_address_id=payment.partner_id.default_address_id
+ data['number']=payment.number
+ data['ref']=payment.related_id.number
+ data['date']=payment.date
+ data['partner_name']=payment.partner_id.name or 0
+ data['partner_address_text']=partner_address_id and partner_address_id.get_address_text()[partner_address_id.id] or "",
+ lines=[]
+ for line in payment.direct_lines:
+ lines.append({
+ 'description': line.description or '',
+ 'qty': line.qty,
+ 'unit_price': line.unit_price or 0.0,
+ 'amount': line.amount or 0.0,
+ })
+ data['lines']=lines
+ data['amount_subtotal']=payment.amount_subtotal or 0.0
+ data['amount_tax']=payment.amount_tax or 0.0
+ data['amount_total']=payment.amount_total or 0.0
+
+ return data
HDCase.register()
diff --git a/netforce_clinic/reports/payment_form.odt b/netforce_clinic/reports/payment_form.odt
new file mode 100644
index 0000000..6bdd567
Binary files /dev/null and b/netforce_clinic/reports/payment_form.odt differ