clinic/netforce_clinic/migrations/remove_conv_bal.py

29 lines
862 B
Python
Raw Normal View History

2015-02-21 13:38:21 +00:00
from datetime import datetime
from netforce.model import get_model
from netforce import migration
from netforce.database import get_connection
#from netforce.access import set_active_user, get_active_user
class Migration(migration.Migration):
_name="clinic.remove.conv.bal"
_version="2.11.0"
def migrate(self):
db=get_connection()
res=db.query("""
select id, amount_due, state,date from account_invoice where extract(year from date)=2014;
""")
inv_ids=[r['id'] for r in res]
for inv in get_model("account.invoice").browse(inv_ids):
inv.to_draft()
print('%s is deleted'%(inv.number))
inv.delete()
start=datetime.now()
stop=datetime.now()
finish=stop-start
print(finish.seconds/60)
return True
Migration.register()