From e26aa9de2c0b3c1cb95b413e3faf9a61a86c3c7d Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Tue, 11 Aug 2015 11:35:46 +0700 Subject: [PATCH] migrate post invoice --- .../layouts/clinic_cust_invoice_form.xml | 4 ++++ .../layouts/fin_account_settings.xml | 2 ++ netforce_clinic/migrations/repost_invoice.py | 19 ++++++++++++++++--- netforce_clinic/models/account_invoice.py | 7 +++++-- netforce_clinic/models/hd_case.py | 2 ++ netforce_clinic/models/shop.py | 1 + 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/netforce_clinic/layouts/clinic_cust_invoice_form.xml b/netforce_clinic/layouts/clinic_cust_invoice_form.xml index f185557..fcc409b 100644 --- a/netforce_clinic/layouts/clinic_cust_invoice_form.xml +++ b/netforce_clinic/layouts/clinic_cust_invoice_form.xml @@ -3,4 +3,8 @@ + + + + diff --git a/netforce_clinic/layouts/fin_account_settings.xml b/netforce_clinic/layouts/fin_account_settings.xml index e6ae90d..498c3bd 100644 --- a/netforce_clinic/layouts/fin_account_settings.xml +++ b/netforce_clinic/layouts/fin_account_settings.xml @@ -1,5 +1,7 @@ + diff --git a/netforce_clinic/migrations/repost_invoice.py b/netforce_clinic/migrations/repost_invoice.py index 40b2b92..401fb53 100644 --- a/netforce_clinic/migrations/repost_invoice.py +++ b/netforce_clinic/migrations/repost_invoice.py @@ -9,18 +9,31 @@ class Migration(migration.Migration): def migrate(self): set_active_user(1) set_active_company(1) + for hdcase_line in get_model('clinic.hd.case.line').search_browse([['description','=',None]]): + prod=hdcase_line.product_id + if prod: + hdcase_line.write({ + 'description': prod.name, + }) + for hdcase in get_model('clinic.hd.case').search_browse([]): for inv in hdcase.invoices: if inv.state=='waiting_payment': - print('repost ---> ', inv.number) + print('hdcase:repost ---> ', inv.number) inv.to_draft() + inv.write({ + 'hdcase_reconcile': True, + }) inv.post() - print("Done!") for shop in get_model('clinic.shop').search_browse([]): for inv in shop.invoices: - print('repost ---> ', inv.number) + print('shop:repost ---> ', inv.number) inv.to_draft() + inv.write({ + 'hdcase_reconcile': True, + }) inv.post() + print("Done!") return True Migration.register() diff --git a/netforce_clinic/models/account_invoice.py b/netforce_clinic/models/account_invoice.py index 7e40169..817f7dd 100644 --- a/netforce_clinic/models/account_invoice.py +++ b/netforce_clinic/models/account_invoice.py @@ -9,6 +9,7 @@ class AccountInvoice(Model): 'department_id': fields.Many2One("clinic.department","Department",search=True), 'patient_partner_id': fields.Many2One("partner","Patient",search=True), 'hdcase_credit': fields.Boolean("HD Case Credit"), + 'hdcase_reconcile': fields.Boolean("HD Case Reconcile"), } def _get_number(self,context={}): @@ -240,13 +241,16 @@ class AccountInvoice(Model): line["credit"]=-amt is_match=False - if settings.acc_prod_match and obj.type=='out': + if obj.hdcase_reconcile and obj.type=='out': print("#POST: clinic customize") cst=get_model('clinic.setting').browse(1) prod_acc=cst.get_product_account move_vals["lines"]=[] for line in group_lines: desc=line['description'] + if not desc: + print("skip no description ", obj.number) + continue ar_debit_id=None #ar_credit_id=None # search from patient_type @@ -266,7 +270,6 @@ class AccountInvoice(Model): if ar_debit_id: break if not ar_debit_id: - import pdb; pdb.set_trace() raise Exception("Missing AR Debit Account for product %s"%(desc), partner.id, partner.name) line_vals={ "description": desc, diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 787d705..82ecec2 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -681,6 +681,7 @@ class HDCase(Model): "lines": [], "company_id": company_id, 'hdcase_credit': False, + 'hdcase_reconcile': True, } vals["partner_id"]=partner.id vals['lines']=rmb_lines @@ -710,6 +711,7 @@ class HDCase(Model): "company_id": company_id, 'partner_id':partner.id, 'hdcase_credit': True, + 'hdcase_reconcile': True, } vals['lines']=normb_lines if patient_partner: diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py index 028d799..41467df 100644 --- a/netforce_clinic/models/shop.py +++ b/netforce_clinic/models/shop.py @@ -333,6 +333,7 @@ class Shop(Model): "currency_id": currency_id, "company_id": company_id, 'partner_id': partner.id, + 'hdcase_reconcile': True, "lines": [], } track_id=obj.branch_id.track_id.id