V11 Stuff
bzr revid: pinky-2a0f2728ad4ddf0e0d9aa7f2e41adcda4d9b819f
This commit is contained in:
parent
97fe54cf15
commit
20f0d52c90
|
@ -87,7 +87,7 @@ class account_invoice(osv.osv):
|
||||||
('in_refund','Supplier Refund'),
|
('in_refund','Supplier Refund'),
|
||||||
],'Type', readonly=True, states={'draft':[('readonly',False)]}, select=True),
|
],'Type', readonly=True, states={'draft':[('readonly',False)]}, select=True),
|
||||||
|
|
||||||
'number': fields.char('Invoice Number', size=32, readonly=True),
|
'number': fields.char('Invoice Number', size=32), # readonly=True
|
||||||
'reference': fields.char('Invoice Reference', size=64),
|
'reference': fields.char('Invoice Reference', size=64),
|
||||||
'project_id': fields.many2one('account.analytic.account', 'Analytic Account', readonly=True, states={'draft':[('readonly',False)]}),
|
'project_id': fields.many2one('account.analytic.account', 'Analytic Account', readonly=True, states={'draft':[('readonly',False)]}),
|
||||||
'comment': fields.text('Additionnal Information'),
|
'comment': fields.text('Additionnal Information'),
|
||||||
|
|
|
@ -28,13 +28,18 @@
|
||||||
|
|
||||||
|
|
||||||
from osv import osv, fields
|
from osv import osv, fields
|
||||||
|
import time
|
||||||
|
|
||||||
class account_v11(osv.osv):
|
class account_v11(osv.osv):
|
||||||
_name ='account.v11'
|
_name ='account.v11'
|
||||||
_columns = {
|
_columns = {
|
||||||
|
'name': fields.char('Date', size=64), # pe mettre une sequence
|
||||||
'file': fields.binary('V11 file'),
|
'file': fields.binary('V11 file'),
|
||||||
'note': fields.text('Import log'),
|
'note': fields.text('Import log'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_defaults= {
|
||||||
|
'name': lambda *a : time.strftime('%Y-%m-%d'),
|
||||||
|
}
|
||||||
account_v11()
|
account_v11()
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import pooler
|
||||||
import time
|
import time
|
||||||
import wizard
|
import wizard
|
||||||
import ir
|
import ir
|
||||||
from osv.osv import except_osv
|
|
||||||
import netsvc
|
import netsvc
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
|
@ -55,23 +54,20 @@ test_fields = {
|
||||||
|
|
||||||
def _v11_parsing(self, cr, uid, data, context):
|
def _v11_parsing(self, cr, uid, data, context):
|
||||||
|
|
||||||
# TODO:
|
|
||||||
# - verifier que la ligne de somme coincide avec le reste
|
|
||||||
# - verifier que chaque est au bon format : que des num,
|
|
||||||
# bin nbre de num, ... ex: "123".isdigit()
|
|
||||||
# Attention : p-e dependant de la banque ...
|
|
||||||
|
|
||||||
# TODO (trunk) :
|
|
||||||
|
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
v11 = pool.get('account.v11').browse(cr, uid, data['ids'])[0]
|
v11_obj = pool.get('account.v11')
|
||||||
|
|
||||||
|
for v11 in v11_obj.browse(cr, uid, data['ids']):
|
||||||
|
|
||||||
line=""
|
line=""
|
||||||
record={}
|
record={}
|
||||||
total={}
|
total={}
|
||||||
total_compute= 0
|
total_compute= 0
|
||||||
rec_list=[]
|
rec_list=[]
|
||||||
|
log=''
|
||||||
|
|
||||||
|
|
||||||
|
# v11 parsing :
|
||||||
for char in b64decode(v11.file):
|
for char in b64decode(v11.file):
|
||||||
|
|
||||||
if not char == '\n':
|
if not char == '\n':
|
||||||
|
@ -81,10 +77,6 @@ def _v11_parsing(self, cr, uid, data, context):
|
||||||
|
|
||||||
record['genre'] = line[0:3]
|
record['genre'] = line[0:3]
|
||||||
|
|
||||||
print line
|
|
||||||
print line[0:]
|
|
||||||
print record['genre']
|
|
||||||
print
|
|
||||||
if record['genre'] == '999':
|
if record['genre'] == '999':
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,7 +91,6 @@ def _v11_parsing(self, cr, uid, data, context):
|
||||||
|
|
||||||
else :
|
else :
|
||||||
|
|
||||||
|
|
||||||
record={'n_postal': line[3:12],
|
record={'n_postal': line[3:12],
|
||||||
'n_ref': line[12:39],
|
'n_ref': line[12:39],
|
||||||
'montant': line[39:49],
|
'montant': line[39:49],
|
||||||
|
@ -110,6 +101,7 @@ def _v11_parsing(self, cr, uid, data, context):
|
||||||
'internal_ref': line[77:87],
|
'internal_ref': line[77:87],
|
||||||
'reserve2': line[87:96],
|
'reserve2': line[87:96],
|
||||||
'frais_encaissement': line[96:100],
|
'frais_encaissement': line[96:100],
|
||||||
|
'line':line,
|
||||||
}
|
}
|
||||||
|
|
||||||
total_compute+= int(record['montant'])
|
total_compute+= int(record['montant'])
|
||||||
|
@ -117,36 +109,54 @@ def _v11_parsing(self, cr, uid, data, context):
|
||||||
|
|
||||||
line=""
|
line=""
|
||||||
|
|
||||||
#for key in sorted(record.keys()):
|
|
||||||
#print key," : ", record[key]
|
|
||||||
|
|
||||||
|
# check the amounts :
|
||||||
# TODO : raise a correct error message
|
|
||||||
if not total_compute == int(total['tot_montant']):
|
if not total_compute == int(total['tot_montant']):
|
||||||
raise except_osv('warning', 'Incoherent v11 file !')
|
raise wizard.except_wizard('warning', 'Incoherent v11 file !')
|
||||||
else:
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
period_id = pool.get('account.period').find(cr,uid, context=context)
|
period_id = pool.get('account.period').find(cr,uid, context=context)
|
||||||
if not period_id:
|
if not period_id:
|
||||||
raise osv.except_osv('No period found !', 'Unable to find a valid period !')
|
raise wizard.except_wizard('No period found !', 'Unable to find a valid period !')
|
||||||
period_id = period_id[0]
|
period_id = period_id[0]
|
||||||
invoice_obj= pool.browse('account.invoice')
|
invoice_obj= pool.get('account.invoice')
|
||||||
for rec in rec_list:
|
for rec in rec_list:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# recherche sur l'id (pr garder un num absolu):
|
||||||
|
# implique de mettre l'id sur le bvr..
|
||||||
|
invoice_id= invoice_obj.search(cr,uid,[ ('id','=',int(rec['internal_ref'])) ])[0]
|
||||||
|
print invoice_id
|
||||||
|
invoice = invoice_obj.browse(cr, uid, invoice_id)
|
||||||
|
invoice_obj.write(cr,uid,[invoice_id],{'state':'paid'})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# TODO feedbacker en log les erreurs
|
||||||
|
acc2 = pool.get('account.journal').browse(cr,uid,data['form']['journal_id'],context).default_debit_account_id.id
|
||||||
|
if not acc2:
|
||||||
|
raise wizard.except_wizard('Warning !', 'No debit account specified for this journal !')
|
||||||
|
continue
|
||||||
|
|
||||||
|
# TODO idem
|
||||||
|
try:
|
||||||
|
acc1 = invoice.partner_id.property_account_receivable[0]
|
||||||
|
except:
|
||||||
|
raise wizard.except_wizard('Warning !','invoice with number '+str(int(rec['internal_ref'])) +' has no partner !')
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
move_id = pool.get('account.move').create(cr, uid, {
|
move_id = pool.get('account.move').create(cr, uid, {
|
||||||
'name': 'Imported from v11',
|
'name': 'Imported from v11',
|
||||||
'period_id': period_id,
|
'period_id': period_id,
|
||||||
'journal_id': data['form']['journal_id']
|
'journal_id': data['form']['journal_id']
|
||||||
})
|
})
|
||||||
|
|
||||||
invoice_id= invoice_obj.search(cr,uid,[ ('number','=',rec['internal_ref']) ])
|
|
||||||
invoice = invoice_obj.browse(cr, uid, invoice_id)
|
|
||||||
acc1 = invoice.partner_id.property_account_receivable
|
|
||||||
acc2 = journal.default_debit_account_id
|
|
||||||
|
|
||||||
#
|
|
||||||
# Vérifier que tu recois bien un int, sinon [0]
|
|
||||||
#
|
|
||||||
|
|
||||||
pool.get('account.move.line').create(cr,uid,{
|
pool.get('account.move.line').create(cr,uid,{
|
||||||
'name': 'v11',
|
'name': 'v11',
|
||||||
|
@ -174,10 +184,13 @@ def _v11_parsing(self, cr, uid, data, context):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
#print total
|
|
||||||
#print rec_list
|
log= log + 'Number of parsed lines : '+ str(len(rec_list)) +'\nTotal amount for this bvr : '+ str(int(total['tot_montant']))+' '+invoice.currency_id.name
|
||||||
|
|
||||||
|
|
||||||
|
v11.write(cr,uid,[v11.id],{'note': log })
|
||||||
|
|
||||||
|
# peut-etre retourner un nouvel onglet avec la liste des ecritures generee :
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,10 @@
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="V11">
|
<form string="V11">
|
||||||
<field name="file"/>
|
<field name="name" />
|
||||||
<newline/>
|
<field name="file" />
|
||||||
<field name="note"/>
|
<separator colspan="3" />
|
||||||
|
<field name="note" colspan="4" select="1"/>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
Loading…
Reference in New Issue