delete invoice paid

fix_acc
watcha.h@almacom.co.th 2015-08-26 22:56:02 +07:00
parent 4d73bffaff
commit 38fad33d43
1 changed files with 14 additions and 4 deletions

View File

@ -18,7 +18,17 @@ class Migration(migration.Migration):
for hdcase in get_model('clinic.hd.case').search_browse(dom): for hdcase in get_model('clinic.hd.case').search_browse(dom):
reset=False reset=False
for inv in hdcase.invoices: 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.to_draft()
inv.delete() inv.delete()
reset=True reset=True
@ -29,10 +39,10 @@ class Migration(migration.Migration):
'state': 'draft', 'state': 'draft',
}) })
ids=list(hdcase_ids) ids=list(hdcase_ids)
for seq in get_model("sequence").search_browse([['type','in',['cust_invoice','clinic_invoice_noclaim']]]): for seq in get_model("sequence").search_browse([['type','in',['cust_invoice','clinic_invoice_noclaim']]]):
seq.write({ for run in seq.running:
'running': [('delete_all'),], run.delete()
})
for hdcase in get_model('clinic.hd.case').browse(ids): for hdcase in get_model('clinic.hd.case').browse(ids):
print('remake_invoice ---> ', hdcase.number) print('remake_invoice ---> ', hdcase.number)
ctx={ ctx={