ACCOUNT :
* invoice.py : partner_id is now required for an invoice. * __terp__.py: bug in loading order corrected L10N_CH: * DTA / V11 : simplified gui for the wizards and better log mesages. BASE: * New object : res.partner.bank.type bzr revid: pinky-5454f6c3dde166b0c8fd74b2dd15a590a72f62d6
This commit is contained in:
parent
1bc0af8561
commit
28f0b0f658
|
@ -28,8 +28,9 @@
|
|||
"account_report.xml",
|
||||
"partner_view.xml",
|
||||
"data/account_invoice.xml",
|
||||
"data/account_data.xml",
|
||||
"data/account_data1.xml",
|
||||
"data/account_minimal.xml",
|
||||
"data/account_data2.xml",
|
||||
"account_invoice_workflow.xml",
|
||||
"project/project_view.xml",
|
||||
"project/project_report.xml",
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<!--
|
||||
Account Type
|
||||
-->
|
||||
|
||||
<record model="account.account.type" id="account_type_receivable" >
|
||||
<field name="name">Receivable</field>
|
||||
<field name="code">receivable</field>
|
||||
<field name="partner_account">True</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_payable" >
|
||||
<field name="name">Payable</field>
|
||||
<field name="code">payable</field>
|
||||
<field name="partner_account">True</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_view">
|
||||
<field name="name">View</field>
|
||||
<field name="code">view</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_income" >
|
||||
<field name="name">Income</field>
|
||||
<field name="code">income</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_expense">
|
||||
<field name="name">Expense</field>
|
||||
<field name="code">expense</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_tax">
|
||||
<field name="name">Tax</field>
|
||||
<field name="code">tax</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_cash">
|
||||
<field name="name">Cash</field>
|
||||
<field name="code">cash</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_asset">
|
||||
<field name="name">Asset</field>
|
||||
<field name="code">asset</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_equity">
|
||||
<field name="name">Equity</field>
|
||||
<field name="code">equity</field>
|
||||
</record>
|
||||
</data>
|
||||
</terp>
|
|
@ -1,49 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<!--
|
||||
Account Type
|
||||
-->
|
||||
|
||||
<record model="account.account.type" id="account_type_receivable" >
|
||||
<field name="name">Receivable</field>
|
||||
<field name="code">receivable</field>
|
||||
<field name="partner_account">True</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_payable" >
|
||||
<field name="name">Payable</field>
|
||||
<field name="code">payable</field>
|
||||
<field name="partner_account">True</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_view">
|
||||
<field name="name">View</field>
|
||||
<field name="code">view</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_income" >
|
||||
<field name="name">Income</field>
|
||||
<field name="code">income</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_expense">
|
||||
<field name="name">Expense</field>
|
||||
<field name="code">expense</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_tax">
|
||||
<field name="name">Tax</field>
|
||||
<field name="code">tax</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_cash">
|
||||
<field name="name">Cash</field>
|
||||
<field name="code">cash</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_asset">
|
||||
<field name="name">Asset</field>
|
||||
<field name="code">asset</field>
|
||||
</record>
|
||||
<record model="account.account.type" id="account_type_equity">
|
||||
<field name="name">Equity</field>
|
||||
<field name="code">equity</field>
|
||||
</record>
|
||||
</data>
|
||||
<data noupdate="1">
|
||||
|
||||
<!--
|
|
@ -102,9 +102,9 @@ class account_invoice(osv.osv):
|
|||
'date_invoice': fields.date('Date Invoiced', required=True, states={'open':[('readonly',True)],'close':[('readonly',True)]}),
|
||||
'date_due': fields.date('Due Date', states={'open':[('readonly',True)],'close':[('readonly',True)]}),
|
||||
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, states={'draft':[('readonly',False)]}, relate=True),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}, relate=True),
|
||||
'address_contact_id': fields.many2one('res.partner.address', 'Contact Address', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, states={'draft':[('readonly',False)]}),
|
||||
'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, required=True, states={'draft':[('readonly',False)]}),
|
||||
|
||||
'partner_contact': fields.char('Partner Contact', size=64),
|
||||
'partner_ref': fields.char('Partner Reference', size=64),
|
||||
|
|
|
@ -8,14 +8,15 @@
|
|||
"category" : "Localisation/Europe",
|
||||
"website": "http://www.tinyerp.com",
|
||||
"depends" : ["base", "account"],
|
||||
"init_xml" : [],
|
||||
# "init_xml" : ["zip_code_default.xml"],
|
||||
# "init_xml" : [],
|
||||
"init_xml" : ["zip_code_default.xml"],
|
||||
"demo_xml" : ["vaudtax_data_demo.xml","dta/dta_demo.xml"],
|
||||
"update_xml" : ["dta/dta_view.xml","dta/dta_wizard.xml","dta/dta_demo.xml",
|
||||
"v11/v11_wizard.xml",
|
||||
"account_vat.xml","base_config.xml","account_config.xml",
|
||||
"company_view.xml"],
|
||||
|
||||
"update_xml" : [
|
||||
"dta/dta_view.xml","dta/dta_wizard.xml",
|
||||
"v11/v11_wizard.xml","v11/v11_view.xml",
|
||||
"account_vat.xml","base_config.xml","account_config.xml",
|
||||
"company_view.xml"
|
||||
],
|
||||
"active": False,
|
||||
"installable": True,
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
<terp>
|
||||
<data>
|
||||
|
||||
|
||||
<record model="res.partner.bank" id="main_bank">
|
||||
<field name="name">FORTIS BANK</field>
|
||||
<field name="iban">1234567</field>
|
||||
|
@ -17,15 +16,10 @@
|
|||
<field name="partner_id" ref="base.res_partner_agrolait"/>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record model="res.company" id="base.main_company">
|
||||
<field name="dta_number">Co01</field>
|
||||
<field name="bvr_number">Co01</field>
|
||||
</record>
|
||||
<record model="res.partner" id="base.main_partner">
|
||||
<field name="bank_id" ref="main_bank"/>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="account.invoice" id="dta_invoice">
|
||||
|
|
|
@ -29,20 +29,32 @@ import wizard
|
|||
from base64 import b64encode
|
||||
from osv import osv
|
||||
import time
|
||||
import pooler
|
||||
|
||||
def _bank_get(self, cr, uid, context={}):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
partner_id = pool.get('res.users').browse(cr,uid,[uid])[0].company_id.partner_id
|
||||
|
||||
obj = pool.get('res.partner.bank')
|
||||
ids = obj.search(cr, uid, [('partner_id','=',partner_id.id)])
|
||||
res = obj.read(cr, uid, ids, ['active', 'name'], context)
|
||||
res = [(r['active'], r['name']) for r in res]
|
||||
return res
|
||||
|
||||
|
||||
ask_form = """<?xml version="1.0"?>
|
||||
<form string="DTA file creation wizard">
|
||||
<separator colspan="4" string="Create DTA file :" />
|
||||
<form string="DTA file creation">
|
||||
<separator colspan="4" string="Choose a bank account :" />
|
||||
<field name="bank" colspan="3"/>
|
||||
<newline/>
|
||||
<field name="bank_iban" colspan="3"/>
|
||||
</form>
|
||||
"""
|
||||
|
||||
ask_fields = {
|
||||
'bank' : {
|
||||
'string':'Bank',
|
||||
'type':'char',
|
||||
'string':'Bank Account',
|
||||
'type':'selection',
|
||||
'selection':_bank_get,
|
||||
'required': True,
|
||||
},
|
||||
|
||||
# 'city' : {
|
||||
|
@ -50,17 +62,12 @@ ask_fields = {
|
|||
# 'type':'char',
|
||||
# },
|
||||
|
||||
'bank_iban' : {
|
||||
'string':'Iban',
|
||||
'type':'char',
|
||||
'required':True,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
res_form = """<?xml version="1.0"?>
|
||||
<form string="DTA file creation wizard">
|
||||
<separator colspan="4" string="Results :" />
|
||||
<form string="DTA file creation - Results">
|
||||
<separator colspan="4" string="Clic on 'Save as' to save the DTA file :" />
|
||||
<field name="dta"/>
|
||||
<separator string="Logs" colspan="4"/>
|
||||
<field name="note" colspan="4" nolabel="1"/>
|
||||
|
@ -69,9 +76,10 @@ res_form = """<?xml version="1.0"?>
|
|||
|
||||
res_fields = {
|
||||
'dta' : {
|
||||
'string':'DTA file',
|
||||
'string':'DTA File',
|
||||
'type':'binary',
|
||||
'required':True,
|
||||
'readonly':True,
|
||||
},
|
||||
|
||||
'note' : {'string':'Log','type':'text'}
|
||||
|
@ -126,6 +134,8 @@ def header(date,cpt_benef,creation_date,cpt_donneur,id_fich,num_seq,trans,type):
|
|||
def total(header,tot):
|
||||
return '01'+c_ljust(header,51)+c_ljust(tot,16)+''.ljust(59)
|
||||
def _create_dta(self,cr,uid,data,context):
|
||||
|
||||
|
||||
# cree des gt836
|
||||
|
||||
creation_date= time.strftime('%y%m%d')
|
||||
|
@ -134,6 +144,11 @@ def _create_dta(self,cr,uid,data,context):
|
|||
dta=''
|
||||
valeur=''
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
bank= pool.get('res.partner.bank').browse(cr,uid,[data['form']['bank']])[0]
|
||||
bank_name= bank.name or ''
|
||||
bank_iban = bank.iban or ''
|
||||
if not bank_name and bank_iban :
|
||||
log= log +'\nBank account not well defined.'
|
||||
user = pool.get('res.users').browse(cr,uid,[uid])[0]
|
||||
company= user.company_id
|
||||
co_addr= company.partner_id.address[0]
|
||||
|
@ -151,7 +166,7 @@ def _create_dta(self,cr,uid,data,context):
|
|||
seq= 1
|
||||
amount_tot= 0
|
||||
for i in inv_obj.browse(cr,uid,data['ids']):
|
||||
if i.dta_state != '2bpaid' or i.state == 'draft':
|
||||
if i.dta_state != '2bpaid' or i.state in ['draft','cancel','paid']:
|
||||
skip= skip +'\n Invoice '+ (i.number or '??')+ ' ignored.'
|
||||
continue
|
||||
|
||||
|
@ -201,7 +216,7 @@ def _create_dta(self,cr,uid,data,context):
|
|||
#raise
|
||||
# donnees de la banque
|
||||
try:
|
||||
dta = dta + segment_03(data['form']['bank'],'',data['form']['bank_iban'])
|
||||
dta = dta + segment_03(bank_name,'',bank_iban)
|
||||
except Exception,e :
|
||||
log= log +'\n'+ str(e)
|
||||
#raise
|
||||
|
@ -218,15 +233,16 @@ def _create_dta(self,cr,uid,data,context):
|
|||
log= log +'\n'+ str(e)
|
||||
#raise
|
||||
|
||||
|
||||
amount_tot += i.amount_total
|
||||
inv_obj.write(cr,uid,[i.id],{'dta_state': 'paid'})
|
||||
inv_obj.write(cr,uid,[i.id],{'dta_state':'paid'})
|
||||
seq += 1
|
||||
|
||||
|
||||
# total
|
||||
try:
|
||||
if dta :
|
||||
dta = dta + total(header('000000','',creation_date,company_iban,'idfi',seq,'890','0')\
|
||||
dta = dta + total(header('000000','',creation_date,company_iban,str(uid),seq,'890','0')\
|
||||
, str(amount_tot))
|
||||
except Exception,e :
|
||||
log= log +'\n'+ str(e)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
This sample DTA file is the one generated via the invoice "DTA invoice"
|
|
@ -0,0 +1 @@
|
|||
01000000 000000612191234567idfi 0000183600Co01 2006/001 1234567 EUR54150.0 Tiny sprl 03DFORTIS BANK 1234567 Agrolait 69 rue de Chimay 5478 Wavre Belgium 05 0 01000000 0000006121912345673 000028900054150.0
|
|
@ -1,2 +1,2 @@
|
|||
00201012162700509500000000000000064366600000541500001 000106101706101706101700000000020000000000000
|
||||
00201012162700509500000000000000064366600000541500001 000106101706101706101700000000010000000000000
|
||||
999010121627999999999999999999999999999000000054150000000000025061018000000000000000000
|
||||
|
|
|
@ -32,17 +32,17 @@ from base64 import b64decode
|
|||
from osv import osv
|
||||
|
||||
ask_form = """<?xml version="1.0"?>
|
||||
<form string="V11 parsing">
|
||||
<separator colspan="4" string="Extract V11 data :" />
|
||||
<field name="journal_id" colspan="1"/>
|
||||
<newline/>
|
||||
<form string="V11 file import">
|
||||
<separator colspan="4" string="Select your bank journal :" />
|
||||
<field name="journal_id" colspan="1" domain="[('type','=','cash')]" />
|
||||
<separator string="Clic on 'New' to select your file :" colspan="4"/>
|
||||
<field name="v11"/>
|
||||
</form>
|
||||
"""
|
||||
|
||||
ask_fields = {
|
||||
'journal_id' : {
|
||||
'string':'Destination Journal',
|
||||
'string':'Bank Journal',
|
||||
'type':'many2one',
|
||||
'relation':'account.journal',
|
||||
'required':True,
|
||||
|
@ -56,28 +56,24 @@ ask_fields = {
|
|||
}
|
||||
|
||||
res_form = """<?xml version="1.0"?>
|
||||
<form string="V11 parsing">
|
||||
<form string="Import V11 file">
|
||||
<separator colspan="4" string="Results :" />
|
||||
<field name="journal_id"/>
|
||||
<newline/>
|
||||
<field name="v11"/>
|
||||
<separator string="Logs" colspan="4"/>
|
||||
<field name="note" colspan="4" nolabel="1"/>
|
||||
<field name="note" colspan="4" nolabel="1" width="500"/>
|
||||
</form>
|
||||
"""
|
||||
|
||||
res_fields = {
|
||||
'journal_id' : {
|
||||
'string':'Destination Journal',
|
||||
'type':'many2one',
|
||||
'relation':'account.journal',
|
||||
'required':True,
|
||||
},
|
||||
'v11' : {
|
||||
'string':'V11 file',
|
||||
'type':'binary',
|
||||
'required':True,
|
||||
},
|
||||
# 'journal_id' : {
|
||||
# 'string':'Destination Journal',
|
||||
# 'type':'many2one',
|
||||
# 'relation':'account.journal',
|
||||
# 'required':True,
|
||||
# },
|
||||
# 'v11' : {
|
||||
# 'string':'V11 file',
|
||||
# 'type':'binary',
|
||||
# 'required':True,
|
||||
# },
|
||||
|
||||
'note' : {'string':'Log','type':'text'}
|
||||
|
||||
|
@ -90,8 +86,8 @@ def _v11_parsing(self, cr, uid, data, context):
|
|||
pool = pooler.get_pool(cr.dbname)
|
||||
v11 = data['form']['v11']
|
||||
|
||||
|
||||
line=""
|
||||
lnb=1
|
||||
record={}
|
||||
total={}
|
||||
total_compute= 0
|
||||
|
@ -133,31 +129,31 @@ def _v11_parsing(self, cr, uid, data, context):
|
|||
'invoice_ref': line[77:87],
|
||||
'reserve2': line[87:96],
|
||||
'frais_encaissement': line[96:100],
|
||||
'line':line,
|
||||
'line_number': str(lnb),
|
||||
}
|
||||
|
||||
total_compute+= int(record['montant'])
|
||||
rec_list.append( record )
|
||||
|
||||
lnb+=1
|
||||
line=""
|
||||
|
||||
|
||||
# check the amounts :
|
||||
if not total_compute == int(total['tot_montant']):
|
||||
return {'note': 'Incoherent V11 file ! IMPORT ABORTED.' }
|
||||
return {'note': 'Incorrect total amount V11 file, import aborted.' }
|
||||
|
||||
|
||||
|
||||
period_id = pool.get('account.period').find(cr,uid, context=context)
|
||||
if not period_id:
|
||||
return {'note': 'No period found ! IMPORT ABORTED.' }
|
||||
return {'note': 'No period found, import aborted.' }
|
||||
|
||||
period_id = period_id[0]
|
||||
invoice_obj= pool.get('account.invoice')
|
||||
|
||||
acc2 = pool.get('account.journal').browse(cr,uid,data['form']['journal_id'],context).default_debit_account_id.id
|
||||
if not acc2:
|
||||
return {'note': 'No debit account specified for this journal ! IMPORT ABORTED.' }
|
||||
return {'note': 'No debit account specified for this journal, import aborted.' }
|
||||
|
||||
|
||||
|
||||
|
@ -225,25 +221,28 @@ def _v11_parsing(self, cr, uid, data, context):
|
|||
cr.rollback()
|
||||
nb_err+=1
|
||||
if e.value.startswith('You have to provide an account for the write off entry !'):
|
||||
log= log +'\n * Error amount mismatch for invoice '+ rec['invoice_ref'].lstrip('0')+\
|
||||
log= log +'\n * Line '+rec['line_number'] +', invoice '+rec['invoice_ref'].lstrip('0')+\
|
||||
' : Amount mismatch for invoice '+ rec['invoice_ref'].lstrip('0')+\
|
||||
'( expected amount: '+str(invoice.amount_total)+' got :'+rec['montant'].lstrip('0')+\
|
||||
').\n line : '+rec['line']
|
||||
').'
|
||||
else:
|
||||
log= log +'\n * '+str(e.value)+ ' :\n line : '+rec['line']
|
||||
log= log +'\n * Line '+rec['line_number'] +', invoice '+rec['invoice_ref'].lstrip('0')+\
|
||||
' : '+str(e.value)
|
||||
#raise # REMOVEME
|
||||
|
||||
except Exception, e:
|
||||
cr.rollback()
|
||||
nb_err+=1
|
||||
log= log +'\n * '+str(e)+ ' :\n line : '+rec['line']
|
||||
log= log +'\n * Line '+rec['line_number'] +', invoice '+rec['invoice_ref'].lstrip('0')+\
|
||||
' : '+str(e)
|
||||
#raise # REMOVEME
|
||||
except :
|
||||
cr.rollback()
|
||||
nb_err+=1
|
||||
log= log +'\n * Reconciliation Error\n line : '+rec['line']
|
||||
log= log +'\n * Line '+rec['line_number'] +', invoice '+rec['invoice_ref'].lstrip('0')+' : Reconciliation Error.'
|
||||
#raise
|
||||
|
||||
log= log + '-'*5 +'\nNumber of parsed lines : '+ str(len(rec_list)) +'\nNumber of error : '+ str(nb_err)
|
||||
log= log + '\n\n --' +'\nNumber of parsed lines : '+ str(len(rec_list)) +'\nNumber of error : '+ str(nb_err)
|
||||
|
||||
return {'note':log,'journal_id': data['form']['journal_id'], 'v11': data['form']['v11']}
|
||||
|
||||
|
@ -267,7 +266,7 @@ class v11_import(wizard.interface):
|
|||
'result' : {'type' : 'form',
|
||||
'arch' : res_form,
|
||||
'fields' : res_fields,
|
||||
'state' : [('extraction', 'Retry') ,('end', 'Quit') ]}
|
||||
'state' : [('end', 'Quit') ]}
|
||||
},
|
||||
|
||||
}
|
||||
|
|
|
@ -1,38 +1,8 @@
|
|||
<?xml version="1.0" ?>
|
||||
|
||||
<terp>
|
||||
<data>
|
||||
|
||||
|
||||
|
||||
<!-- <\!-- defini le formulaire -\-> -->
|
||||
<!-- <record model="ir.ui.view" id="view_v11_form"> -->
|
||||
<!-- <field name="name">account.v11.form</field> -->
|
||||
<!-- <field name="model">account.v11</field> -->
|
||||
<!-- <field name="type">form</field> -->
|
||||
<!-- <field name="arch" type="xml"> -->
|
||||
<!-- <form string="V11"> -->
|
||||
<!-- <field name="name" /> -->
|
||||
<!-- <field name="file" /> -->
|
||||
<!-- <field name="state" colors="red:state=='error'"/> -->
|
||||
<!-- <separator colspan="3" /> -->
|
||||
<!-- <field name="note" colspan="4" select="1"/> -->
|
||||
<!-- </form> -->
|
||||
<!-- </field> -->
|
||||
<!-- </record> -->
|
||||
|
||||
<!-- <\!-- defini une action -\-> -->
|
||||
<!-- <record model="ir.actions.act_window" id="open_view_test_form"> -->
|
||||
<!-- <field name="name">account.v11</field> -->
|
||||
<!-- <field name="type">ir.actions.act_window</field> -->
|
||||
<!-- <field name="res_model">account.v11</field> -->
|
||||
<!-- <field name="view_type">form</field> -->
|
||||
<!-- <field name="view_mode">form,tree</field> -->
|
||||
<!-- </record> -->
|
||||
|
||||
<!-- defini l'entree -->
|
||||
|
||||
<!-- <menuitem name="Financial Management/V11" id="menu_account_v11" action=""/> -->
|
||||
<menuitem name="Financial Management/Periodical Processing/Import V11" action="wizard_account_v11_import" type="wizard" id="menu_account_v11" sequence="15"/>
|
||||
|
||||
|
||||
</data>
|
||||
|
|
|
@ -9,8 +9,5 @@
|
|||
id="wizard_account_v11_import"
|
||||
/>
|
||||
|
||||
<menuitem name="Financial Management/Import V11" action="wizard_account_v11_import" type="wizard" id="menu_account_v11" sequence="15"/>
|
||||
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
|
Loading…
Reference in New Issue