diff --git a/netforce_clinic/layouts/clinic_cust_invoice_form.xml b/netforce_clinic/layouts/clinic_cust_invoice_form.xml
index b0c7f41..3fce2e4 100644
--- a/netforce_clinic/layouts/clinic_cust_invoice_form.xml
+++ b/netforce_clinic/layouts/clinic_cust_invoice_form.xml
@@ -5,5 +5,6 @@
+
diff --git a/netforce_clinic/layouts/clinic_cust_invoice_list.xml b/netforce_clinic/layouts/clinic_cust_invoice_list.xml
index d911443..183bd38 100644
--- a/netforce_clinic/layouts/clinic_cust_invoice_list.xml
+++ b/netforce_clinic/layouts/clinic_cust_invoice_list.xml
@@ -1,5 +1,6 @@
-
-
-
+
+
+
+
diff --git a/netforce_clinic/migrations/__init__.py b/netforce_clinic/migrations/__init__.py
index a5ef4b2..7d09b35 100644
--- a/netforce_clinic/migrations/__init__.py
+++ b/netforce_clinic/migrations/__init__.py
@@ -8,3 +8,4 @@
#from . import rename_dbl_hdcase_number
#from . import reset_hdcase_number
from . import remove_dbl_contact
+from . import update_invoice
diff --git a/netforce_clinic/migrations/update_invoice.py b/netforce_clinic/migrations/update_invoice.py
new file mode 100644
index 0000000..4dbf168
--- /dev/null
+++ b/netforce_clinic/migrations/update_invoice.py
@@ -0,0 +1,22 @@
+from netforce.model import get_model
+from netforce import migration
+from netforce.access import set_active_user, set_active_company
+from netforce.database import get_connection
+
+class Migration(migration.Migration):
+ _name="clinic.update.invoice"
+ _version="2.12.4"
+
+ def migrate(self):
+ set_active_company(1)
+ set_active_user(1)
+ db=get_connection()
+ for ptype_id in get_model("clinic.patient.type").search([]):
+ pids=get_model('clinic.patient').search([['type_id','=',ptype_id]])
+ if pids:
+ db.execute("""
+ update account_invoice set patient_type_id=%s where patient_id in %s
+ """,ptype_id,tuple(pids))
+ print("update type %s to invoice -> Done"%(ptype_id))
+
+Migration.register()
diff --git a/netforce_clinic/models/account_invoice.py b/netforce_clinic/models/account_invoice.py
index 0bb711a..37613aa 100644
--- a/netforce_clinic/models/account_invoice.py
+++ b/netforce_clinic/models/account_invoice.py
@@ -13,17 +13,23 @@ class AccountInvoice(Model):
res={}
for obj in self.browse(ids):
pt_id=None
+ pt_type_id=None
if obj.patient_partner_id:
for pt in get_model('clinic.patient').search_browse([['partner_id','=',obj.patient_partner_id.id]]):
pt_id=pt.id
- res[obj.id]=pt_id
+ pt_type_id=pt.type_id.id
+ res[obj.id]={
+ 'patient_id': pt_id,
+ 'patient_type_id': pt_type_id,
+ }
return res
_fields={
'clinic_expense_id': fields.Many2One("clinic.hd.case.expense","Expense"),
'department_id': fields.Many2One("clinic.department","Department",search=True),
'patient_partner_id': fields.Many2One("partner","Partner Patient",search=True),
- 'patient_id': fields.Many2One("clinic.patient","Patient",function="_get_patient", store=True,search=True),
+ 'patient_id': fields.Many2One("clinic.patient","Patient",function="_get_patient", function_multi=True,store=True,search=True),
+ 'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type",function="_get_patient", function_multi=True,store=True,search=True),
}
def _get_number(self,context={}):