clinic/netforce_clinic/migrations/conv_bal.py

56 lines
1.7 KiB
Python
Raw Normal View History

from netforce.model import get_model
from netforce import migration
2015-08-06 01:37:48 +00:00
from netforce.access import set_active_user, set_active_company
class Migration(migration.Migration):
2015-08-06 04:35:40 +00:00
_name="clinic.conv.bal"
2015-08-06 01:37:48 +00:00
_version="2.10.0"
def migrate(self):
2015-08-06 01:37:48 +00:00
set_active_user(1)
2015-02-25 13:19:50 +00:00
set_active_company(1)
2015-08-10 14:38:19 +00:00
#for mv in get_model("account.move").search_browse([['number','ilike', 'OPEN']]):
#mv.to_draft()
#mv.delete()
2015-02-23 07:12:30 +00:00
cbv_id=24
cbv=get_model("conv.bal").browse(cbv_id)
2015-08-06 01:37:48 +00:00
cbv.write({
2015-08-10 14:38:19 +00:00
'date_fmt': '%Y-%m-%d',
2015-08-06 01:37:48 +00:00
'file': 'tb.csv',
})
print("import acc file (step 1) running ...")
get_model("conv.bal").import_acc_file([cbv.id],context={})
get_model("conv.bal").import_acc([cbv.id],context={})
2015-08-10 14:38:19 +00:00
2015-08-06 01:37:48 +00:00
cbv.write({
2015-08-10 14:38:19 +00:00
'date_fmt': '%d/%m/%Y',
2015-08-06 01:37:48 +00:00
'file': 'ar.csv',
})
print("import sale file (step 2)running ...")
get_model("conv.bal").import_sale_file([cbv.id],context={})
get_model("conv.bal").import_sale([cbv.id],context={})
2015-02-18 10:55:31 +00:00
2015-08-06 01:37:48 +00:00
print("import purch file (step 3) running ...")
cbv.write({
'file': 'ap.csv',
'date_fmt': '%d/%m/%Y',
})
get_model("conv.bal").import_purch_file([cbv.id],context={})
get_model("conv.bal").import_purch([cbv.id],context={})
cbv.write({
'date_fmt': '%Y-%m-%d',
})
2015-08-10 14:38:19 +00:00
print(">> next 3")
2015-08-06 01:37:48 +00:00
print("create_open_entry...")
cbv.create_open_entry()
print("create_sale_invoices...")
cbv.create_sale_invoices()
print("create_purch_invoices...")
cbv.create_purch_invoices()
2015-02-23 07:12:30 +00:00
print("Done!")
return True
Migration.register()