diff --git a/netforce_clinic/models/account_invoice.py b/netforce_clinic/models/account_invoice.py index aaf0679..763a70e 100644 --- a/netforce_clinic/models/account_invoice.py +++ b/netforce_clinic/models/account_invoice.py @@ -6,6 +6,7 @@ class AccountInvoice(Model): '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","Patient",search=True), + 'hdcase_credit': fields.Boolean("HD Case Credit"), } def _get_number(self,context={}): @@ -48,5 +49,4 @@ class AccountInvoice(Model): } - AccountInvoice.register() diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index 7a531aa..ea0977e 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -444,9 +444,13 @@ class HDCase(Model): "amount": line.amount or 0, 'account_id': account_id, })) - payment_id=get_model("account.payment").create(vals,context={"type":"in"}) + context={ + 'type': 'in', + 'branch_id': obj.branch_id.id, + } + payment_id=get_model("account.payment").create(vals,context=context) obj.write({ - 'state': 'paid', + #'state': 'paid', 'payment_lines': [('create',{ 'payment_id': payment_id, 'amount': pay_amount, @@ -570,6 +574,7 @@ class HDCase(Model): "company_id": company_id, "lines": [], "company_id": company_id, + 'hdcase_credit': False, } vals["partner_id"]=partner.id vals['lines']=rmb_lines @@ -593,6 +598,7 @@ class HDCase(Model): "lines": [], "company_id": company_id, 'partner_id':partner.id, + 'hdcase_credit': True, } vals['lines']=normb_lines if patient_partner: @@ -1039,11 +1045,13 @@ class HDCase(Model): lines=[] for line in payment.lines: amt=line.amount or 0 + desc=line.description or '' + uom_name="" lines.append({ 'no': no, 'product_name': '', - 'description': line.description or '', - 'uom_name': '', + 'description': desc, + 'uom_name': uom_name, 'qty': line.qty or 0, 'price': line.unit_price or 0, 'amount': amt, diff --git a/netforce_clinic/models/hd_case_payment.py b/netforce_clinic/models/hd_case_payment.py index b0a0909..2bf213c 100644 --- a/netforce_clinic/models/hd_case_payment.py +++ b/netforce_clinic/models/hd_case_payment.py @@ -77,13 +77,21 @@ class HDCasePayment(Model): hd_case.post_invoices() hd_case.create_cycle_item() hd_case.do_expense() + hd_case.write({ + 'state': 'waiting_payment', + 'req_fee': 0, # force to hide button pay! + }) + inv_number=[] + for inv in hd_case.invoices: + inv_number.append(inv.number or "") + flash='%s is waiting to pay.'% ' and '.join([inv for inv in inv_number]) return { 'next': { 'name': 'clinic_hd_case', 'mode': 'form', 'active_id': hd_case.id, }, - 'flash': '%s has been paid'%hd_case.number, + 'flash': flash, } def onchange_amount(self,context={}): diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index 13a3749..6f4756b 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -910,6 +910,7 @@ class ClinicSetting(Model): 'ar_debit_id': ac_prod.ar_debit_id.id, }) break + print("res ", res) return res def get_patient_hn(self,ids,context={}): diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py index 784b2cd..cff2851 100644 --- a/netforce_clinic/models/shop.py +++ b/netforce_clinic/models/shop.py @@ -548,12 +548,22 @@ class Shop(Model): comp_name=comp.name or "" if st.default_address_id.company: comp_name=st.default_address_id.company or "" + number=shop.number or "" + ref=shop.ref or "" + if shop.pay_type=="cash": + for pm in shop.payments: + number=pm.number or "" + ref=shop.number or "" + else: + for inv in shop.invoices: + number=inv.number or "" + ref=shop.number or "" data={ 'comp_name': comp_name, 'comp_addr': comp_addr or '', 'tax_no': st.tax_no or '', - 'number': shop.number or '', - 'ref': shop.ref, + 'number': number, + 'ref': ref, 'date': shop.date, 'datenow': shop.date or time.strftime("%d/%m/%Y"), 'dateprint': shop.date or time.strftime("%d/%m/%Y %H:%M:%S"), diff --git a/netforce_clinic/reports/cust_payment.odt b/netforce_clinic/reports/cust_payment.odt index db87904..a75fd5f 100644 Binary files a/netforce_clinic/reports/cust_payment.odt and b/netforce_clinic/reports/cust_payment.odt differ