From 38fad33d43e0bde41ca44ed3081ac434e6183d63 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Wed, 26 Aug 2015 22:56:02 +0700 Subject: [PATCH] delete invoice paid --- netforce_clinic/migrations/repost_invoice.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/netforce_clinic/migrations/repost_invoice.py b/netforce_clinic/migrations/repost_invoice.py index 0822628..90891e8 100644 --- a/netforce_clinic/migrations/repost_invoice.py +++ b/netforce_clinic/migrations/repost_invoice.py @@ -18,7 +18,17 @@ class Migration(migration.Migration): for hdcase in get_model('clinic.hd.case').search_browse(dom): reset=False for inv in hdcase.invoices: - if inv.state=='waiting_payment': + if inv.state=='paid': + inv.write({ + 'state': 'waiting_payment', + }) + for pm_line in get_model("account.payment.line").search_browse([['invoice_id','=',inv.id]]): + pm=pm_line.payment_id + pm.to_draft() + pm.delete() + inv.to_draft() + inv.delete() + elif inv.state=='waiting_payment': inv.to_draft() inv.delete() reset=True @@ -29,10 +39,10 @@ class Migration(migration.Migration): 'state': 'draft', }) ids=list(hdcase_ids) + for seq in get_model("sequence").search_browse([['type','in',['cust_invoice','clinic_invoice_noclaim']]]): - seq.write({ - 'running': [('delete_all'),], - }) + for run in seq.running: + run.delete() for hdcase in get_model('clinic.hd.case').browse(ids): print('remake_invoice ---> ', hdcase.number) ctx={