paid invoice on hdcase
parent
25e453232a
commit
1062124931
|
@ -55,6 +55,7 @@
|
|||
<field name="cash_account_id"/>
|
||||
<field name="income_account_id" string="Account Receivable"/>
|
||||
<field name="import_account_id"/>
|
||||
<field name="hdcase_payment_account_id"/>
|
||||
</tab>
|
||||
<tab string="Reporting">
|
||||
<field name="helper_categ_id"/>
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
<list colors='{"#9f9":[["state","=","paid"]]}'>
|
||||
<head>
|
||||
<button string="Print" action="clinic_hdcase_invoice_print" action_options="convert=pdf" icon="print"/>
|
||||
<button string="Pay" method="pay_invoice" type="success"/>
|
||||
</head>
|
||||
<field name="number"/>
|
||||
<field name="ref"/>
|
||||
|
|
|
@ -434,4 +434,36 @@ class AccountInvoice(Model):
|
|||
data['signature']=get_file_path(cst.signature)
|
||||
return data
|
||||
|
||||
def pay_invoice(self, ids, context={}):
|
||||
paid_inv=[]
|
||||
for obj in self.browse(ids):
|
||||
if obj.state!='waiting_payment':
|
||||
continue
|
||||
rel=obj.related_id
|
||||
if rel and rel._model=='clinic.hd.case':
|
||||
clinic_setting=get_model("clinic.setting").browse(1)
|
||||
if not clinic_setting.hdcase_payment_account_id:
|
||||
raise Exception("Missing HDCase Payment Account in setting!")
|
||||
inv_pm_id=get_model("invoice.payment").create({
|
||||
'date': time.strftime("%Y-%m-%d"),
|
||||
'invoice_id': obj.id,
|
||||
'account_id': clinic_setting.hdcase_payment_account_id.id,
|
||||
'ref': rel.number,
|
||||
'amount': obj.amount_due,
|
||||
})
|
||||
inv_pm=get_model("invoice.payment").browse(inv_pm_id)
|
||||
inv_pm.add_payment(context)
|
||||
for pm_line in obj.payments:
|
||||
pm=pm_line.payment_id
|
||||
pm.write({
|
||||
'related_id': "clinic.hd.case,%s"%rel.id,
|
||||
})
|
||||
paid_inv.append(obj.number)
|
||||
if not paid_inv:
|
||||
raise Exception("Nothing to paid!")
|
||||
return {
|
||||
'flash': 'Invoice: %s has been paid'%(','.join(paid_inv)),
|
||||
}
|
||||
|
||||
|
||||
AccountInvoice.register()
|
||||
|
|
|
@ -58,6 +58,7 @@ class ClinicSetting(Model):
|
|||
"cash_account_id": fields.Many2One("account.account","Cash Account",multi_company=True),
|
||||
"income_account_id": fields.Many2One("account.account","Income Account",multi_company=True),
|
||||
"import_account_id": fields.Many2One("account.account","Import Account",multi_company=True),
|
||||
"hdcase_payment_account_id": fields.Many2One("account.account","HDCase Payment Account",multi_company=True),
|
||||
'helper_categ_id': fields.Many2One("clinic.staff.categ","Helper Category"),
|
||||
'base_salary_day': fields.Float("Base Salary Day"),
|
||||
'next_date': fields.DateTime("Next Gen"),
|
||||
|
|
Loading…
Reference in New Issue