2015-02-12 01:12:06 +00:00
|
|
|
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
|
2015-02-12 01:12:06 +00:00
|
|
|
|
|
|
|
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"
|
2015-02-12 01:12:06 +00:00
|
|
|
|
|
|
|
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-09-02 00:44:03 +00:00
|
|
|
|
|
|
|
# delete old account payable
|
|
|
|
dom=[
|
|
|
|
['memo','=','Conversion balance 2015-06-30'],
|
|
|
|
['type','=','in'],
|
|
|
|
['state','=','waiting_payment'],
|
|
|
|
]
|
|
|
|
for inv in get_model('account.invoice').search_browse(dom):
|
|
|
|
print('delete invoice... ', inv.number)
|
|
|
|
inv.to_draft()
|
|
|
|
inv.delete()
|
|
|
|
|
|
|
|
# delete old account rereivable
|
|
|
|
dom=[
|
|
|
|
['memo','=','Conversion balance 2015-06-30'],
|
|
|
|
['type','=','out'],
|
|
|
|
['state','=','waiting_payment'],
|
|
|
|
]
|
|
|
|
for inv in get_model('account.invoice').search_browse(dom):
|
|
|
|
print('delete invoice... ', inv.number)
|
|
|
|
inv.to_draft()
|
|
|
|
inv.delete()
|
|
|
|
# remove journal entry
|
|
|
|
dom=[
|
|
|
|
['number','=','OPENING ENTRY'],
|
|
|
|
]
|
|
|
|
for move in get_model('account.move').search_browse(dom):
|
|
|
|
print('delete accout.move... ', move.number)
|
|
|
|
move.to_draft()
|
|
|
|
move.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',
|
2015-09-02 00:44:03 +00:00
|
|
|
'date': '2015-06-30',
|
2015-08-06 01:37:48 +00:00
|
|
|
})
|
|
|
|
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
|
|
|
print("import sale file (step 2)running ...")
|
2015-08-26 15:01:45 +00:00
|
|
|
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)
|
2015-08-06 01:37:48 +00:00
|
|
|
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',
|
2015-09-02 00:44:03 +00:00
|
|
|
#'date_fmt': '%d/%m/%Y',
|
|
|
|
'date_fmt': '%Y-%m-%d',
|
2015-08-06 01:37:48 +00:00
|
|
|
})
|
|
|
|
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!")
|
2015-02-12 01:12:06 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
Migration.register()
|