to draft invoice in hdcase

fix1
SPP 2018-01-24 12:07:43 +07:00
parent 43466e07f9
commit 2690a20b93
2 changed files with 11 additions and 0 deletions

View File

@ -136,6 +136,7 @@
<head>
<button string="Print" action="clinic_hdcase_invoice_print" action_options="convert=pdf" icon="print"/>
<button string="Pay" method="pay_invoice" type="success"/>
<button string="To Draft" method="hdcase_to_draft" type="default"/>
</head>
<field name="number"/>
<field name="ref"/>

View File

@ -469,5 +469,15 @@ class AccountInvoice(Model):
'flash': 'Invoice: %s has been paid'%(','.join(paid_inv)),
}
def hdcase_to_draft(self, ids, context={}):
for payment_line in get_model("account.payment.line").search_browse([['invoice_id','in',ids]]):
payment=payment_line.payment_id
rel=payment.related_id
if rel._model=='clinic.hd.case':
payment.to_draft()
payment.delete()
for inv in self.browse(ids):
inv.to_draft()
inv.approve()
AccountInvoice.register()