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={}) print("import sale file (step 2)running ...") del_ids=get_model("conv.sale.invoice").search([["conv_id","=",cbv.id]]) get_model('conv.sale.invoice').delete(del_ids) for ar_file in ['ar_fee','ar_epo','ar_srv','ar_other']: cbv.write({ 'date_fmt': '%d/%m/%Y', 'file': '%s.csv'%(ar_file), }) ctx={ 'is_append': True, } get_model("conv.bal").import_sale_file([cbv.id],context=ctx) 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()