[IMP] l10n_ch: Improve code
bzr revid: mra@mra-laptop-20100819054405-eb1dugq3pj8msqod
This commit is contained in:
@@ -43,19 +43,19 @@ You can also add with this module one of the following account plan:
|
||||
- l10n_ch_c2c_pcg
|
||||
|
||||
|
||||
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Module incluant la localisation Suisse de TinyERP revu et corrigé par Camptocamp. Cette nouvelle version
|
||||
comprend la gestion et l'émissionde BVR, le paiement électronique via DTA (pour les banques, le système postal est en développement)
|
||||
et l'import du relevé de compte depuis la banque de manière automatisée.
|
||||
|
||||
Module incluant la localisation Suisse de TinyERP revu et corrigé par Camptocamp. Cette nouvelle version
|
||||
comprend la gestion et l'émissionde BVR, le paiement électronique via DTA (pour les banques, le système postal est en développement)
|
||||
et l'import du relevé de compte depuis la banque de manière automatisée.
|
||||
De plus, nous avons intégré la définition de toutes les banques Suisses(adresse, swift et clearing).
|
||||
|
||||
Par ailleurs, conjointement à ce module, nous proposons 1 plan comptables issus de l'USAM :
|
||||
|
||||
|
||||
- l10n_ch_c2c_pcg
|
||||
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
TODO :
|
||||
- Implement bvr import partial reconciliation
|
||||
@@ -70,11 +70,9 @@ TODO :
|
||||
"author" : "Camptocamp SA",
|
||||
"category" : "Localisation/Europe",
|
||||
"website": "http://www.camptocamp.com",
|
||||
|
||||
|
||||
"depends" : [
|
||||
"base",
|
||||
"account",
|
||||
"base_vat",
|
||||
"base_vat",
|
||||
"base_iban",
|
||||
"account_payment",
|
||||
],
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
from osv import fields, osv
|
||||
|
||||
class AccountMoveLine(osv.osv):
|
||||
""" Inherit account.move.line in order to add a custom link
|
||||
between supplier invoice line and bank. The original link
|
||||
""" Inherit account.move.line in order to add a custom link
|
||||
between supplier invoice line and bank. The original link
|
||||
was defined in account_payment between line """
|
||||
|
||||
_inherit = 'account.move.line'
|
||||
@@ -43,12 +43,13 @@ class AccountMoveLine(osv.osv):
|
||||
## @param self The object pointer.
|
||||
## @param cr a psycopg cursor
|
||||
## @param uid res.user.id that is currently loged
|
||||
## @param payment_type manual
|
||||
## @parma context a standard dict
|
||||
## @param payment_type manual
|
||||
## @parma context a standard dict
|
||||
## @return a dict who has the account move line id as key and the bank id as value
|
||||
|
||||
def line2bank(self, cr, uid, ids, payment_type='manual', context=None):
|
||||
"""add a link to account.move.line in order to link
|
||||
supplier invoice line and bank. The original link
|
||||
"""add a link to account.move.line in order to link
|
||||
supplier invoice line and bank. The original link
|
||||
was defined in account_payment"""
|
||||
payment_mode_obj = self.pool.get('payment.mode')
|
||||
line2bank = {}
|
||||
@@ -69,4 +70,5 @@ class AccountMoveLine(osv.osv):
|
||||
return line2bank
|
||||
|
||||
AccountMoveLine()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -46,9 +46,12 @@ Bank()
|
||||
class bvr_checkbox(osv.osv):
|
||||
""" Add function to generate function """
|
||||
_inherit = "res.partner.bank"
|
||||
|
||||
_columns = {
|
||||
'print_bank' : fields.boolean('Print Bank on BVR'),
|
||||
'print_account' : fields.boolean('Print Account Number on BVR'),
|
||||
}
|
||||
|
||||
bvr_checkbox()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -31,13 +31,13 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
|
||||
class res_company(osv.osv):
|
||||
"""override company in order to add bvr vertical and
|
||||
"""override company in order to add bvr vertical and
|
||||
Horizontal print delta"""
|
||||
_inherit = "res.company"
|
||||
|
||||
_columns = {
|
||||
### horiz. delta in mm 1.2 will print the bvz 1.2mm lefter
|
||||
'bvr_delta_horz': fields.float('BVR Horz. Delta (mm)',
|
||||
@@ -46,6 +46,7 @@ class res_company(osv.osv):
|
||||
'bvr_delta_vert': fields.float('BVR Vert. Delta (mm)',
|
||||
help='vert. delta in mm 1.2 will print the bvz 1.2mm lefter'),
|
||||
}
|
||||
|
||||
res_company()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
+12
-12
@@ -34,22 +34,22 @@ import time
|
||||
from osv import osv, fields
|
||||
|
||||
class account_dta(osv.osv):
|
||||
"""class that implements bank DTA File format,
|
||||
"""class that implements bank DTA File format,
|
||||
used to transfert bulk batch payment instruction to a bank"""
|
||||
_name = "account.dta"
|
||||
_description = "DTA History"
|
||||
_columns = {
|
||||
### name of the file
|
||||
### name of the file
|
||||
'name': fields.binary('DTA file', readonly=True),
|
||||
### list of dta line linked to the dta order
|
||||
'dta_line_ids': fields.one2many('account.dta.line','dta_id','DTA lines', readonly=True),
|
||||
'dta_line_ids': fields.one2many('account.dta.line','dta_id','DTA lines', readonly=True),
|
||||
## textual notes
|
||||
'note': fields.text('Creation log', readonly=True,
|
||||
'note': fields.text('Creation log', readonly=True,
|
||||
help="Displays the problem during dta generation"),
|
||||
### bank how will execute DTA order
|
||||
'bank': fields.many2one('res.partner.bank','Bank', readonly=True,select=True,
|
||||
help="Bank how will execute DTA order"),
|
||||
### date of DTA order generation
|
||||
### date of DTA order generation
|
||||
'date': fields.date('Creation Date', readonly=True,select=True,
|
||||
help="Date of DTA order generation"),
|
||||
### user how generate the DTA order
|
||||
@@ -58,12 +58,12 @@ class account_dta(osv.osv):
|
||||
account_dta()
|
||||
|
||||
class account_dta_line(osv.osv):
|
||||
"""Class that represent a DTA order line,
|
||||
"""Class that represent a DTA order line,
|
||||
each line corressponds to a payment instruction"""
|
||||
_name = "account.dta.line"
|
||||
_description = "DTA line"
|
||||
_columns = {
|
||||
### name of the line
|
||||
### name of the line
|
||||
'name' : fields.many2one('account.invoice','Invoice', required=True, size=256),
|
||||
### partner how will receive payments
|
||||
'partner_id' : fields.many2one('res.partner','Partner',
|
||||
@@ -74,13 +74,13 @@ class account_dta_line(osv.osv):
|
||||
'invoice_date' : fields.date('Invoice date'),
|
||||
### cash discount date
|
||||
'cashdisc_date' : fields.date('Cash Discount date'),
|
||||
### amount effectively paied on this line
|
||||
'amount_to_pay' : fields.float('Amount to pay',
|
||||
### amount effectively paied on this line
|
||||
'amount_to_pay' : fields.float('Amount to pay',
|
||||
help="Amount effectively paid"),
|
||||
### amount that was on the supplier invoice
|
||||
'amount_invoice': fields.float('Invoiced Amount',
|
||||
help="Amount to pay base on the supplier invoice"),
|
||||
### Cash discount amount
|
||||
### Cash discount amount
|
||||
'amount_cashdisc': fields.float('Cash Discount Amount'),
|
||||
### Linke to the main dta order
|
||||
'dta_id': fields.many2one('account.dta','Associated DTA', required=True, ondelete='cascade'),
|
||||
@@ -90,7 +90,7 @@ class account_dta_line(osv.osv):
|
||||
_defaults = {
|
||||
'state' : lambda *a :'draft',
|
||||
}
|
||||
|
||||
account_dta_line()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -206,6 +206,7 @@ class account_tax_code(osv.osv):
|
||||
### The case code of the taxt code
|
||||
'code': fields.char('Case Code', size=512),
|
||||
}
|
||||
|
||||
account_tax_code()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -30,7 +30,6 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
|
||||
class res_partner(osv.osv):
|
||||
@@ -40,6 +39,7 @@ class res_partner(osv.osv):
|
||||
'ref_companies': fields.one2many('res.company', 'partner_id',
|
||||
'Companies that refers to partner'),
|
||||
}
|
||||
|
||||
res_partner()
|
||||
|
||||
class res_partner_bank(osv.osv):
|
||||
@@ -51,7 +51,7 @@ class res_partner_bank(osv.osv):
|
||||
'bvr_adherent_num': fields.char('BVR adherent number', size=11),
|
||||
'dta_code': fields.char('DTA code', size=5),
|
||||
}
|
||||
|
||||
|
||||
# def _default_value(self, cursor, user, field, context=None):
|
||||
# if field in ('country_id', 'state_id'):
|
||||
# value = False
|
||||
@@ -68,8 +68,8 @@ class res_partner_bank(osv.osv):
|
||||
# else :
|
||||
# value = False
|
||||
# return value
|
||||
|
||||
|
||||
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
if not len(ids):
|
||||
return []
|
||||
@@ -84,9 +84,11 @@ class res_partner_bank(osv.osv):
|
||||
for r in self.read(cr, uid, ids, ['name','state'], context):
|
||||
res.append((r['id'], r['name']+' : '+bank_type_names[r['state']]))
|
||||
return res
|
||||
|
||||
|
||||
_sql_constraints = [
|
||||
('bvr_adherent_uniq', 'unique (bvr_adherent_num)', 'The BVR adherent number must be unique !')
|
||||
]
|
||||
|
||||
res_partner_bank()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -30,14 +30,17 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
from osv import osv
|
||||
|
||||
class payment_order(osv.osv):
|
||||
_inherit = 'payment.order'
|
||||
|
||||
def get_wizard(self,mode):
|
||||
if mode == 'dta':
|
||||
return 'l10n_ch','wizard_account_dta_create'
|
||||
return 'l10n_ch', 'action_account_dtr_create_values'
|
||||
|
||||
return super(payment_order,self).get_wizard(mode)
|
||||
|
||||
payment_order()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -32,19 +32,19 @@
|
||||
|
||||
import base64
|
||||
import time
|
||||
from tools import mod10r
|
||||
import re
|
||||
from tools.translate import _
|
||||
|
||||
from tools.translate import _
|
||||
from osv import osv, fields
|
||||
from tools import mod10r
|
||||
import pooler
|
||||
|
||||
def _reconstruct_invoice_ref(cursor, user, reference, context):
|
||||
def _reconstruct_invoice_ref(cursor, user, reference, context=None):
|
||||
###
|
||||
id_invoice = False
|
||||
# On fait d'abord une recherche sur toutes les factures
|
||||
# we now searhc for company
|
||||
user_obj=pooler.get_pool(cursor.dbname).get('res.users')
|
||||
user_obj = pooler.get_pool(cursor.dbname).get('res.users')
|
||||
user_current=user_obj.browse(cursor, user, user)
|
||||
|
||||
##
|
||||
@@ -68,7 +68,8 @@ def _reconstruct_invoice_ref(cursor, user, reference, context):
|
||||
else:
|
||||
return []
|
||||
return True
|
||||
def _import(obj, cursor, user, data, context):
|
||||
|
||||
def _import(obj, cursor, user, data, context=None):
|
||||
|
||||
pool = pooler.get_pool(cursor.dbname)
|
||||
statement_line_obj = pool.get('account.bank.statement.line')
|
||||
@@ -79,12 +80,13 @@ def _import(obj, cursor, user, data, context):
|
||||
attachment_obj = pool.get('ir.attachment')
|
||||
file = data['form']['file']
|
||||
statement_id = data['id']
|
||||
|
||||
records = []
|
||||
total_amount = 0
|
||||
total_cost = 0
|
||||
find_total = False
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
for lines in base64.decodestring(file).split("\n"):
|
||||
# Manage files without carriage return
|
||||
while lines:
|
||||
@@ -168,7 +170,7 @@ def _import(obj, cursor, user, data, context):
|
||||
('account_id.type', 'in', ['receivable', 'payable']),
|
||||
], order='date desc', context=context)
|
||||
if not line_ids:
|
||||
line_ids = _reconstruct_invoice_ref(cursor,user,reference,None)
|
||||
line_ids = _reconstruct_invoice_ref(cursor, user, reference, None)
|
||||
|
||||
line2reconcile = False
|
||||
partner_id = False
|
||||
@@ -210,14 +212,19 @@ def _import(obj, cursor, user, data, context):
|
||||
'res_model': 'account.bank.statement',
|
||||
'res_id': statement_id,
|
||||
}, context=context)
|
||||
|
||||
return {}
|
||||
|
||||
class bvr_import_wizard(osv.osv_memory):
|
||||
_name='bvr.import.wizard'
|
||||
_columns={'file':fields.binary('BVR File', required=True)}
|
||||
|
||||
_name = 'bvr.import.wizard'
|
||||
_columns = {
|
||||
'file':fields.binary('BVR File', required=True)
|
||||
}
|
||||
|
||||
def import_bvr(self, cr, uid, ids, context=None):
|
||||
data={}
|
||||
data = {}
|
||||
if context is None:
|
||||
context = {}
|
||||
active_ids = context.get('active_ids', [])
|
||||
active_id = context.get('active_id', False)
|
||||
data['form'] = {}
|
||||
@@ -227,8 +234,9 @@ class bvr_import_wizard(osv.osv_memory):
|
||||
res = self.read(cr, uid, ids[0], ['file'])
|
||||
if res:
|
||||
data['form']['file'] = res['file']
|
||||
_import(self, cr, uid, data, context)
|
||||
_import(self, cr, uid, data, context=context)
|
||||
return {}
|
||||
|
||||
bvr_import_wizard()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -36,10 +36,12 @@ import pooler
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
def _validate_bank_values(self, cr, uid, data, context):
|
||||
def _validate_bank_values(self, cr, uid, data, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
invoice_obj = pool.get('account.invoice')
|
||||
for invoice in invoice_obj.browse(cr, uid, data['ids'], context):
|
||||
for invoice in invoice_obj.browse(cr, uid, data['ids'], context=context):
|
||||
if not invoice.partner_bank_id:
|
||||
raise osv.except_osv(_('UserError'),
|
||||
_('No bank specified on invoice:\n%s') % \
|
||||
@@ -64,43 +66,57 @@ def _validate_bank_values(self, cr, uid, data, context):
|
||||
return {}
|
||||
|
||||
class bvr_report(osv.osv_memory):
|
||||
_name="bvr.report"
|
||||
_columns={'name':fields.char('Name', size=10)}
|
||||
|
||||
_name = "bvr.report"
|
||||
_columns = {
|
||||
'name':fields.char('Name', size=16)
|
||||
}
|
||||
|
||||
def view_init(self, cr, uid, fields_list, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
data = {}
|
||||
active_ids = context.get('active_ids', [])
|
||||
data['form'] = {}
|
||||
data['ids'] = active_ids
|
||||
_validate_bank_values(self, cr, uid, data, context)
|
||||
pass
|
||||
|
||||
def print_bvr_report(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
data = {}
|
||||
active_ids = context.get('active_ids', [])
|
||||
data['form'] = {}
|
||||
data['ids'] = active_ids
|
||||
return {'type': 'ir.actions.report.xml', 'report_name': 'l10n_ch.bvr', 'datas': data}
|
||||
|
||||
bvr_report()
|
||||
|
||||
class bvr_invoices_report(osv.osv_memory):
|
||||
_name = "bvr.invoices.report"
|
||||
_columns = {
|
||||
'name':fields.char('Name', size=16)
|
||||
}
|
||||
|
||||
def view_init(self, cr, uid, fields_list, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
data={}
|
||||
active_ids = context.get('active_ids', [])
|
||||
data['form'] = {}
|
||||
data['ids'] = active_ids
|
||||
_validate_bank_values(self, cr, uid, data, context)
|
||||
pass
|
||||
|
||||
def print_bvr_report(self, cr, uid, ids, context):
|
||||
data={}
|
||||
active_ids = context.get('active_ids', [])
|
||||
data['form'] = {}
|
||||
data['ids'] = active_ids
|
||||
return {'type': 'ir.actions.report.xml', 'report_name': 'l10n_ch.bvr', 'datas': data}
|
||||
bvr_report()
|
||||
|
||||
class bvr_invoices_report(osv.osv_memory):
|
||||
_name="bvr.invoices.report"
|
||||
_columns={'name':fields.char('Name', size=10)}
|
||||
|
||||
def view_init(self, cr, uid, fields_list, context=None):
|
||||
data={}
|
||||
active_ids = context.get('active_ids', [])
|
||||
data['form'] = {}
|
||||
data['ids'] = active_ids
|
||||
_validate_bank_values(self, cr, uid, data, context)
|
||||
pass
|
||||
|
||||
def print_bvr_invoices_report(self, cr, uid, ids, context):
|
||||
data={}
|
||||
def print_bvr_invoices_report(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
data = {}
|
||||
active_ids = context.get('active_ids', [])
|
||||
data['form'] = {}
|
||||
data['ids'] = active_ids
|
||||
return {'type': 'ir.actions.report.xml', 'report_name': 'l10n_ch.invoice.bvr', 'datas': data}
|
||||
|
||||
bvr_invoices_report()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -36,25 +36,8 @@ import base64
|
||||
|
||||
from osv import osv, fields
|
||||
import pooler
|
||||
|
||||
from tools.translate import _
|
||||
|
||||
|
||||
|
||||
FORM = """<?xml version="1.0"?>
|
||||
<form string="DTA file creation - Results">
|
||||
<separator colspan="4" string="Clic on 'Save as' to save the DTA file :" />
|
||||
<field name="dta"/>
|
||||
</form>"""
|
||||
|
||||
FIELDS = {
|
||||
'dta': {
|
||||
'string': 'DTA File',
|
||||
'type': 'binary',
|
||||
'readonly': True,
|
||||
},
|
||||
}
|
||||
|
||||
TRANS=[
|
||||
(u'é','e'),
|
||||
(u'è','e'),
|
||||
@@ -82,7 +65,6 @@ def tr(string_in):
|
||||
|
||||
|
||||
class record:
|
||||
|
||||
def __init__(self, global_context_dict):
|
||||
for i in global_context_dict:
|
||||
global_context_dict[i] = global_context_dict[i] \
|
||||
@@ -357,16 +339,17 @@ def c_ljust(s, size):
|
||||
s = s.decode('utf-8').encode('latin1','replace').ljust(size)
|
||||
return s
|
||||
|
||||
def _create_dta(obj, cr, uid, data, context):
|
||||
v={}
|
||||
def _create_dta(obj, cr, uid, data, context=None):
|
||||
v = {}
|
||||
v['uid'] = str(uid)
|
||||
v['creation_date']= time.strftime('%y%m%d')
|
||||
dta=''
|
||||
v['creation_date'] = time.strftime('%y%m%d')
|
||||
dta = ''
|
||||
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
payment_obj = pool.get('payment.order')
|
||||
attachment_obj = pool.get('ir.attachment')
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
payment = payment_obj.browse(cr, uid, data['id'], context=context)
|
||||
|
||||
if not payment.mode or payment.mode.type.code != 'dta':
|
||||
@@ -384,9 +367,9 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
_('You must provide a Clearing Number for your bank account.'))
|
||||
|
||||
user = pool.get('res.users').browse(cr,uid,[uid])[0]
|
||||
company= user.company_id
|
||||
company = user.company_id
|
||||
#XXX dirty code use get_addr
|
||||
co_addr= company.partner_id.address[0]
|
||||
co_addr = company.partner_id.address[0]
|
||||
v['comp_country'] = co_addr.country_id and co_addr.country_id.name or ''
|
||||
v['comp_street'] = co_addr.street or ''
|
||||
v['comp_zip'] = co_addr.zip
|
||||
@@ -394,7 +377,6 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
v['comp_name'] = co_addr.name
|
||||
v['comp_dta'] = bank.dta_code or '' #XXX not mandatory in pratice
|
||||
|
||||
|
||||
v['comp_bank_number'] = bank.acc_number or ''
|
||||
if bank.iban:
|
||||
v['comp_bank_iban'] = bank.iban.replace(' ','') or ''
|
||||
@@ -407,7 +389,7 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
dta_line_obj = pool.get('account.dta.line')
|
||||
res_partner_bank_obj = pool.get('res.partner.bank')
|
||||
|
||||
seq= 1
|
||||
seq = 1
|
||||
amount_tot = 0
|
||||
amount_currency_tot = 0
|
||||
|
||||
@@ -434,8 +416,8 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
'on the partner: %s\n' \
|
||||
'on line: %s') % (pline.bank_id.state, pline.partner_id.name, pline.name))
|
||||
|
||||
v['partner_bank_iban']= pline.bank_id.iban or False
|
||||
v['partner_bank_number']= pline.bank_id.acc_number \
|
||||
v['partner_bank_iban'] = pline.bank_id.iban or False
|
||||
v['partner_bank_number'] = pline.bank_id.acc_number \
|
||||
and pline.bank_id.acc_number.replace('.','').replace('-','') \
|
||||
or False
|
||||
v['partner_post_number']= pline.bank_id.post_number \
|
||||
@@ -462,12 +444,12 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
v['partner_name'] = pline.bank_id.owner_name
|
||||
else:
|
||||
v['partner_name'] = pline.partner_id and pline.partner_id.name or ''
|
||||
|
||||
|
||||
if pline.partner_id and pline.partner_id.address \
|
||||
and pline.partner_id.address[0]:
|
||||
v['partner_street'] = pline.partner_id.address[0].street
|
||||
v['partner_city']= pline.partner_id.address[0].city
|
||||
v['partner_zip']= pline.partner_id.address[0].zip
|
||||
v['partner_city'] = pline.partner_id.address[0].city
|
||||
v['partner_zip'] = pline.partner_id.address[0].zip
|
||||
# If iban => country=country code for space reason
|
||||
elec_pay = pline.bank_id.state #Bank type
|
||||
if elec_pay == 'iban':
|
||||
@@ -487,17 +469,17 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
'for the partner: ' + pline.partner_id.name + '\n' \
|
||||
'on line: ' + pline.name)
|
||||
|
||||
if pline.order_id.date_planned :
|
||||
if pline.order_id.date_planned:
|
||||
date_value = mx.DateTime.strptime(pline.order_id.date_planned, '%Y-%m-%d')
|
||||
elif pline.date :
|
||||
elif pline.date:
|
||||
date_value = mx.DateTime.strptime(pline.date, '%Y-%m-%d')
|
||||
else :
|
||||
else:
|
||||
date_value = mx.DateTime.now()
|
||||
v['date_value'] = date_value.strftime("%y%m%d")
|
||||
|
||||
# si compte iban -> iban (836)
|
||||
# si payment structure -> bvr (826)
|
||||
# si non -> (827)
|
||||
# si non -> (827)
|
||||
|
||||
if elec_pay == 'dta_iban':
|
||||
# If iban => country=country code for space reason
|
||||
@@ -544,7 +526,7 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
elif elec_pay == 'bvbank':
|
||||
if not v['partner_bank_number'] :
|
||||
if v['partner_bank_iban'] :
|
||||
v['partner_bank_number']= v['partner_bank_iban']
|
||||
v['partner_bank_number']= v['partner_bank_iban']
|
||||
else:
|
||||
raise osv.except_osv(_('Error'), _('You must provide ' \
|
||||
'a bank number \n' \
|
||||
@@ -579,11 +561,11 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
|
||||
# segment total
|
||||
v['amount_total'] = str(amount_currency_tot).replace('.',',')
|
||||
v['sequence'] = str(seq).rjust(5).replace(' ','0')
|
||||
v['sequence'] = str(seq).rjust(5).replace(' ','0')
|
||||
if dta :
|
||||
dta = dta + record_gt890(v).generate()
|
||||
|
||||
dta_data= base64.encodestring(dta)
|
||||
dta_data = base64.encodestring(dta)
|
||||
payment_obj.set_done(cr, uid, data['id'], context)
|
||||
attachment_obj.create(cr, uid, {
|
||||
'name': 'DTA',
|
||||
@@ -596,11 +578,14 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
|
||||
class create_dta_wizard(osv.osv_memory):
|
||||
_name="create.dta.wizard"
|
||||
_columns={'dta_file':fields.binary('DTA File', readonly=True)}
|
||||
|
||||
_columns={
|
||||
'dta_file':fields.binary('DTA File', readonly=True)
|
||||
}
|
||||
def create_dta(self, cr, uid, ids, context=None):
|
||||
if not context:
|
||||
context={}
|
||||
data={}
|
||||
context = {}
|
||||
data = {}
|
||||
active_ids = context.get('active_ids', [])
|
||||
active_id = context.get('active_id', [])
|
||||
data['form'] = {}
|
||||
@@ -609,21 +594,24 @@ class create_dta_wizard(osv.osv_memory):
|
||||
dta_file = _create_dta(self, cr, uid, data, context)
|
||||
context.update({'dta_file':dta_file})
|
||||
return self.save_dta(cr, uid, ids, context)
|
||||
|
||||
def save_dta(self, cr, uid, ids, context):
|
||||
|
||||
def save_dta(self, cr, uid, ids, context=None):
|
||||
obj_model = self.pool.get('ir.model.data')
|
||||
model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','dta_save_view')])
|
||||
if context is None:
|
||||
context = {}
|
||||
model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'), ('name','=','dta_save_view')])
|
||||
resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id']
|
||||
return {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'create.dta.wizard',
|
||||
'views': [(resource_id,'form')],
|
||||
'views': [(resource_id, 'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'context': context,
|
||||
}
|
||||
return {}
|
||||
|
||||
|
||||
create_dta_wizard()
|
||||
#wizard_dta_create('account.dta_create')
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
Reference in New Issue
Block a user