clinic/netforce_clinic/migrations/import_acc.py

52 lines
1.4 KiB
Python

from netforce.model import get_model
from netforce import migration
class Migration(migration.Migration):
_name="import.acc"
_version="2.11.0"
def migrate(self):
data={}
lines=get_model("conv.bal").search_browse([])
for conv in lines:
if conv.id==24:
for invoice in conv.sale_invoices:
amount_due=invoice.amount_due or 0
number=invoice.number or ""
if not data.get(number):
data[number]={'amount_due': amount_due}
f=open("/tmp/ar.csv","r")
res=f.read().split("\n")
total=0.0
del res[0]
st=""
no=1
for r in res:
r=r.split(",")
number=r[0]
if not data.get(number):
st+=','.join(r)
st+='\n'
print(no, 'XXX ', r)
no+=1
f=open("res.csv","w")
f.write(st)
f.close()
print("diff ", total)
#cbv_id=24
#cbv=get_model("conv.bal").browse(cbv_id)
#cbv.write({
#'file': 'tb.csv',
#})
#print("import acc file (step 1) running ...")
#cbv.write({
#'file': 'ar.csv',
#})
#print("import sale file (step 2)running ...")
#get_model("conv.bal").import_sale_file([cbv.id],context={})
return True
Migration.register()