allow to filter patient type on invoice

stable
watcha.h 2016-02-12 13:07:42 +07:00
parent 1b79fdc191
commit 078279f07a
5 changed files with 36 additions and 5 deletions

View File

@ -5,5 +5,6 @@
</field> </field>
<field name="memo" position="after"> <field name="memo" position="after">
<field name="account_id" string="Account Receivable" span="2"/> <field name="account_id" string="Account Receivable" span="2"/>
<field name="patient_type_id" span="2"/>
</field> </field>
</inherit> </inherit>

View File

@ -1,5 +1,6 @@
<inherit model="account.invoice" inherit="cust_invoice_list"> <inherit inherit="cust_invoice_list">
<field name="partner_id" position="after"> <field name="ref" position="after">
<field name="department_id"/> <field name="patient_type_id"/>
</field> </field>
<field name="memo" position="replace"/>
</inherit> </inherit>

View File

@ -8,3 +8,4 @@
#from . import rename_dbl_hdcase_number #from . import rename_dbl_hdcase_number
#from . import reset_hdcase_number #from . import reset_hdcase_number
from . import remove_dbl_contact from . import remove_dbl_contact
from . import update_invoice

View File

@ -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()

View File

@ -13,17 +13,23 @@ class AccountInvoice(Model):
res={} res={}
for obj in self.browse(ids): for obj in self.browse(ids):
pt_id=None pt_id=None
pt_type_id=None
if obj.patient_partner_id: if obj.patient_partner_id:
for pt in get_model('clinic.patient').search_browse([['partner_id','=',obj.patient_partner_id.id]]): for pt in get_model('clinic.patient').search_browse([['partner_id','=',obj.patient_partner_id.id]]):
pt_id=pt.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 return res
_fields={ _fields={
'clinic_expense_id': fields.Many2One("clinic.hd.case.expense","Expense"), 'clinic_expense_id': fields.Many2One("clinic.hd.case.expense","Expense"),
'department_id': fields.Many2One("clinic.department","Department",search=True), 'department_id': fields.Many2One("clinic.department","Department",search=True),
'patient_partner_id': fields.Many2One("partner","Partner Patient",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={}): def _get_number(self,context={}):