clinic/netforce_clinic/migrations/conv_bal.py

56 lines
1.7 KiB
Python

from netforce.model import get_model
from netforce import migration
from netforce.access import set_active_user, set_active_company
class Migration(migration.Migration):
_name="clinic.conv.bal"
_version="2.10.0"
def migrate(self):
set_active_user(1)
set_active_company(1)
#for mv in get_model("account.move").search_browse([['number','ilike', 'OPEN']]):
#mv.to_draft()
#mv.delete()
cbv_id=24
cbv=get_model("conv.bal").browse(cbv_id)
cbv.write({
'date_fmt': '%Y-%m-%d',
'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={})
cbv.write({
'date_fmt': '%d/%m/%Y',
'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={})
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',
})
print(">> next 3")
print("create_open_entry...")
cbv.create_open_entry()
print("create_sale_invoices...")
cbv.create_sale_invoices()
print("create_purch_invoices...")
cbv.create_purch_invoices()
print("Done!")
return True
Migration.register()