[IMP] l10n_ch: Converted to osv memory wizards
bzr revid: mra@mra-laptop-20100819045110-xwunpbnuqr1s5h0c
This commit is contained in:
committed by
Mustufa Rangwala
parent
e956c42cd9
commit
e20f4b9b37
@@ -41,4 +41,5 @@ import payment
|
||||
import report
|
||||
import bank
|
||||
import account_move_line
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -87,10 +87,9 @@ TODO :
|
||||
],
|
||||
"update_xml" : [
|
||||
"dta_view.xml",
|
||||
"dta_wizard.xml",
|
||||
"bvr_report.xml",
|
||||
"bvr_wizard.xml",
|
||||
"bvr_view.xml",
|
||||
"wizard/bvr_import_view.xml",
|
||||
"wizard/bvr_report_view.xml",
|
||||
"wizard/create_dta_view.xml",
|
||||
"company_view.xml",
|
||||
"account_invoice.xml",
|
||||
"bank_view.xml",
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
|
||||
from osv import fields, osv
|
||||
|
||||
|
||||
class Bank(osv.osv):
|
||||
"""Inherit res.bank class in order to add swiss specific field"""
|
||||
_inherit = 'res.bank'
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<report
|
||||
id="account_invoice_bvr"
|
||||
string="BVR A4 Sheet"
|
||||
model="account.invoice"
|
||||
name="l10n_ch.bvr"
|
||||
rml="l10n_ch/report/bvr.rml"
|
||||
auto="False"
|
||||
menu="False"
|
||||
header="False"
|
||||
/>
|
||||
<report
|
||||
id="invoice_bvr"
|
||||
string="Invoice with BVR"
|
||||
model="account.invoice"
|
||||
name="l10n_ch.invoice.bvr"
|
||||
rml="l10n_ch/report/invoice.rml"
|
||||
auto="False"
|
||||
menu="False"
|
||||
header="False"
|
||||
|
||||
/>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="view_bank_statement_form">
|
||||
<field name="name">account.bank.statement.form.inherit</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.view_bank_statement_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="balance_end_real" position="after">
|
||||
<button name="%(wizard_bvr_import)d" string="Import BVR" type="action" colspan="2"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<wizard
|
||||
string="BVR"
|
||||
model="account.invoice"
|
||||
name="l10n_ch.bvr.check"
|
||||
id="wizard_bvr_check_report"
|
||||
keyword="client_print_multi"/>
|
||||
|
||||
<wizard
|
||||
string="Invoices BVR"
|
||||
model="account.invoice"
|
||||
name="l10n_ch.invoice.bvr.check"
|
||||
id="wizard_invoice_bvr_check_report"
|
||||
keyword="client_print_multi"/>
|
||||
|
||||
<wizard
|
||||
string="BVR Import"
|
||||
model="account.bank.statement"
|
||||
name="l10n_ch.bvr_import"
|
||||
id="wizard_bvr_import"
|
||||
menu="False"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
|
||||
class res_company(osv.osv):
|
||||
"""override company in order to add bvr vertical and
|
||||
Horizontal print delta"""
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
from osv import osv,fields
|
||||
from osv import osv, fields
|
||||
|
||||
class account_dta(osv.osv):
|
||||
"""class that implements bank DTA File format,
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<wizard
|
||||
string="Create DTA"
|
||||
model="payment.order"
|
||||
name="account.dta_create"
|
||||
menu= "False"
|
||||
id="wizard_account_dta_create"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -30,11 +30,10 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
from osv import fields, osv
|
||||
from tools import mod10r
|
||||
from mx import DateTime
|
||||
|
||||
from osv import fields, osv
|
||||
from tools import mod10r
|
||||
|
||||
class account_invoice(osv.osv):
|
||||
"""Inherit account.invoice in order to add bvr
|
||||
|
||||
@@ -40,13 +40,8 @@ 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):
|
||||
_inherit = "res.partner.bank"
|
||||
_columns = {
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields
|
||||
from osv import osv
|
||||
from osv import osv, fields
|
||||
|
||||
class payment_order(osv.osv):
|
||||
_inherit = 'payment.order'
|
||||
|
||||
@@ -30,5 +30,6 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import bvr
|
||||
import bvr_report
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
</docinit>
|
||||
|
||||
<template pageSize="(210.0mm,297.0mm)" title="Test" author="Martin Simon" allowSplitting="20">
|
||||
<template pageSize="(210.0mm,297.0mm)" title="Invoices BVR" author="Martin Simon" allowSplitting="20">
|
||||
<pageTemplate id="first">
|
||||
<pageGraphics>
|
||||
<!-- You Logo - Change X,Y,Width and Height -->
|
||||
@@ -30,15 +30,16 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
from report import report_sxw
|
||||
from tools import mod10r
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import time
|
||||
from mx.DateTime import *
|
||||
|
||||
from report import report_sxw
|
||||
from tools import mod10r
|
||||
|
||||
class account_invoice_bvr(report_sxw.rml_parse):
|
||||
"""Report class that Allows to print BVR payement vector"""
|
||||
def __init__(self, cr, uid, name, context):
|
||||
@@ -111,14 +112,14 @@ class account_invoice_bvr(report_sxw.rml_parse):
|
||||
report_sxw.report_sxw(
|
||||
'report.l10n_ch.bvr',
|
||||
'account.invoice',
|
||||
'addons/l10n_ch/report/bvr.rml',
|
||||
'addons/l10n_ch/report/bvr_report.rml',
|
||||
parser=account_invoice_bvr,
|
||||
header=False)
|
||||
|
||||
report_sxw.report_sxw(
|
||||
'report.l10n_ch.invoice.bvr',
|
||||
'account.invoice',
|
||||
'addons/l10n_ch/report/invoice.rml',
|
||||
'addons/l10n_ch/report/bvr_invoice_report.rml',
|
||||
parser=account_invoice_bvr,
|
||||
header=False)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<docinit>
|
||||
<registerFont fontFile="/tmp/ocrbb.ttf" expr="{'fontFile':str(police_absolute_path('addons/l10n_ch/report/ocrbb.ttf'))}" fontName="ocrb" />
|
||||
</docinit>
|
||||
<template pageSize="(210.0mm,297.0mm)" title="Test" author="Martin Simon" allowSplitting="20">
|
||||
<template pageSize="(210.0mm,297.0mm)" title="BVR" author="Martin Simon" allowSplitting="20">
|
||||
<pageTemplate id="first">
|
||||
<pageGraphics>
|
||||
<!-- You Logo - Change X,Y,Width and Height -->
|
||||
@@ -30,8 +30,9 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import dta_wizard
|
||||
import wizard_bvr
|
||||
import create_dta
|
||||
import bvr_report
|
||||
import bvr_import
|
||||
import journal_config
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -29,26 +29,15 @@
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
import wizard
|
||||
import pooler
|
||||
|
||||
import base64
|
||||
import time
|
||||
from tools import mod10r
|
||||
import re
|
||||
from tools.translate import _
|
||||
|
||||
ASK_FORM = """<?xml version="1.0"?>
|
||||
<form string="BVR Import">
|
||||
<field name="file"/>
|
||||
</form>"""
|
||||
|
||||
ASK_FIELDS = {
|
||||
'file': {
|
||||
'string': 'BVR file',
|
||||
'type': 'binary',
|
||||
'required': True,
|
||||
},
|
||||
}
|
||||
from osv import osv, fields
|
||||
import pooler
|
||||
|
||||
def _reconstruct_invoice_ref(cursor, user, reference, context):
|
||||
###
|
||||
@@ -104,11 +93,11 @@ def _import(obj, cursor, user, data, context):
|
||||
|
||||
if line[0:3] in ('999', '995'):
|
||||
if find_total:
|
||||
raise wizard.except_wizard(_('Error'),
|
||||
raise osv.except_osv(_('Error'),
|
||||
_('Too much total record found!'))
|
||||
find_total = True
|
||||
if lines:
|
||||
raise wizard.except_wizard(_('Error'),
|
||||
raise osv.except_osv(_('Error'),
|
||||
_('Record found after total record!'))
|
||||
amount = float(line[39:49]) + (float(line[49:51]) / 100)
|
||||
cost = float(line[69:76]) + (float(line[76:78]) / 100)
|
||||
@@ -118,10 +107,10 @@ def _import(obj, cursor, user, data, context):
|
||||
|
||||
if round(amount - total_amount, 2) >= 0.01 \
|
||||
or round(cost - total_cost, 2) >= 0.01:
|
||||
raise wizard.except_wizard(_('Error'),
|
||||
raise osv.except_osv(_('Error'),
|
||||
_('Total record different from the computed!'))
|
||||
if int(line[51:63]) != len(records):
|
||||
raise wizard.except_wizard(_('Error'),
|
||||
raise osv.except_osv(_('Error'),
|
||||
_('Number record different from the computed!'))
|
||||
else:
|
||||
record = {
|
||||
@@ -133,7 +122,7 @@ def _import(obj, cursor, user, data, context):
|
||||
}
|
||||
|
||||
if record['reference'] != mod10r(record['reference'][:-1]):
|
||||
raise wizard.except_wizard(_('Error'),
|
||||
raise osv.except_osv(_('Error'),
|
||||
_('Recursive mod10 is invalid for reference: %s') % \
|
||||
record['reference'])
|
||||
|
||||
@@ -203,7 +192,7 @@ def _import(obj, cursor, user, data, context):
|
||||
else:
|
||||
account_id = account_payable
|
||||
if not account_id :
|
||||
raise wizard.except_wizard(_('Error'),
|
||||
raise osv.except_osv(_('Error'),
|
||||
_('The properties account payable account receivable'))
|
||||
values['account_id'] = account_id
|
||||
values['partner_id'] = partner_id
|
||||
@@ -223,30 +212,23 @@ def _import(obj, cursor, user, data, context):
|
||||
}, context=context)
|
||||
return {}
|
||||
|
||||
class bvr_import_wizard(osv.osv_memory):
|
||||
_name='bvr.import.wizard'
|
||||
_columns={'file':fields.binary('BVR File', required=True)}
|
||||
|
||||
def import_bvr(self, cr, uid, ids, context=None):
|
||||
data={}
|
||||
active_ids = context.get('active_ids', [])
|
||||
active_id = context.get('active_id', False)
|
||||
data['form'] = {}
|
||||
data['ids'] = active_ids
|
||||
data['id'] = active_id
|
||||
data['form']['file'] = ''
|
||||
res = self.read(cr, uid, ids[0], ['file'])
|
||||
if res:
|
||||
data['form']['file'] = res['file']
|
||||
_import(self, cr, uid, data, context)
|
||||
return {}
|
||||
bvr_import_wizard()
|
||||
|
||||
class BVRImport(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'arch': ASK_FORM,
|
||||
'fields': ASK_FIELDS,
|
||||
'state': [
|
||||
('end', 'Cancel', 'gtk-cancel'),
|
||||
('import', 'Import', 'gtk-ok', True),
|
||||
],
|
||||
},
|
||||
},
|
||||
'import': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
'type': 'action',
|
||||
'action': _import,
|
||||
'state': 'end',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
BVRImport('l10n_ch.bvr_import')
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- Import BVR Wizard -->
|
||||
<record id="bvr_import_view" model="ir.ui.view">
|
||||
<field name="name">BVR Import Wizard</field>
|
||||
<field name="model">bvr.import.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="BVR Import">
|
||||
<group width="525" colspan="4">
|
||||
<field name="file"/>
|
||||
<newline/>
|
||||
<group colspan="4">
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel" colspan="2"/>
|
||||
<button name="import_bvr" string="Import" type="object" icon="gtk-ok" colspan="2"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="wizard_bvr_import" model="ir.actions.act_window">
|
||||
<field name="name">BVR Import</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">bvr.import.wizard</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="bvr_import_view"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_bank_statement_form">
|
||||
<field name="name">account.bank.statement.form.inherit</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account.view_bank_statement_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="balance_end_real" position="after">
|
||||
<button name="%(wizard_bvr_import)d" string="Import BVR" type="action" colspan="2"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -30,23 +30,24 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import pooler
|
||||
import re
|
||||
|
||||
import pooler
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
def _check(self, cr, uid, data, context):
|
||||
def _validate_bank_values(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
invoice_obj = pool.get('account.invoice')
|
||||
for invoice in invoice_obj.browse(cr, uid, data['ids'], context):
|
||||
if not invoice.partner_bank_id:
|
||||
raise wizard.except_wizard(_('UserError'),
|
||||
raise osv.except_osv(_('UserError'),
|
||||
_('No bank specified on invoice:\n%s') % \
|
||||
invoice_obj.name_get(cr, uid, [invoice.id], context=context)[0][1])
|
||||
|
||||
if not re.compile('[0-9][0-9]-[0-9]{3,6}-[0-9]').match(
|
||||
invoice.partner_bank_id.bvr_number or ''):
|
||||
raise wizard.except_wizard(_('UserError'),
|
||||
raise osv.except_osv(_('UserError'),
|
||||
_('Your bank BVR number should be of the form 0X-XXX-X!\n' \
|
||||
'Please check your company ' \
|
||||
'information for the invoice:\n%s') % \
|
||||
@@ -55,29 +56,51 @@ def _check(self, cr, uid, data, context):
|
||||
if invoice.partner_bank_id.bvr_adherent_num \
|
||||
and not re.compile('[0-9]*$').match(
|
||||
invoice.partner_bank_id.bvr_adherent_num):
|
||||
raise wizard.except_wizard(_('UserError'),
|
||||
_('Your bank BVR adherent number must contain exactly seven' \
|
||||
raise osv.except_osv(_('UserError'),
|
||||
_('Your bank BVR adherent number must contain exactly seven ' \
|
||||
'digits!\nPlease check your company ' \
|
||||
'information for the invoice:\n%s') % \
|
||||
invoice_obj.name_get(cr, uid, [invoice.id], context=context)[0][1])
|
||||
return {}
|
||||
|
||||
class wizard_report(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_check],
|
||||
'result': {'type':'print', 'report':'l10n_ch.bvr', 'state':'end'}
|
||||
}
|
||||
}
|
||||
wizard_report('l10n_ch.bvr.check')
|
||||
class bvr_report(osv.osv_memory):
|
||||
_name="bvr.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_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 ReportInvoiceBVRCheck(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_check],
|
||||
'result': {'type':'print', 'report':'l10n_ch.invoice.bvr', 'state':'end'}
|
||||
}
|
||||
}
|
||||
ReportInvoiceBVRCheck('l10n_ch.invoice.bvr.check')
|
||||
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={}
|
||||
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:
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- BVR Report -->
|
||||
<record id="bvr_report_view" model="ir.ui.view">
|
||||
<field name="name">bvr Report</field>
|
||||
<field name="model">bvr.report</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="BVR Report">
|
||||
<group width="130">
|
||||
<separator string="Print BVR Report" colspan="4"/>
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="print_bvr_report" string="Print" type="object" icon="gtk-ok"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_bvr_report" model="ir.actions.act_window">
|
||||
<field name="name">BVR</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">bvr.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="bvr_report_view"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="action_account_bvr_report_values">
|
||||
<field name="model_id" ref="model_bvr_report" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">BVR</field>
|
||||
<field name="key2">client_print_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' +str(ref('action_account_bvr_report'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">account.invoice</field>
|
||||
</record>
|
||||
|
||||
<!-- Invoices BVR Report -->
|
||||
<record id="bvr_invoices_report_view" model="ir.ui.view">
|
||||
<field name="name">BVR Invoices Report</field>
|
||||
<field name="model">bvr.invoices.report</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="BVR Invoices Report">
|
||||
<group width="160">
|
||||
<separator string="Print BVR Invoice Report" colspan="4"/>
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="print_bvr_invoices_report" string="Print" type="object" icon="gtk-ok"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_bvr_invoices_report" model="ir.actions.act_window">
|
||||
<field name="name">Invoices BVR</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">bvr.invoices.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="bvr_invoices_report_view"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="action_account_bvr_invoices_report_values">
|
||||
<field name="model_id" ref="model_bvr_invoices_report" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Invoices BVR</field>
|
||||
<field name="key2">client_print_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' +str(ref('action_account_bvr_invoices_report'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">account.invoice</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -29,15 +29,18 @@
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
##############################################################################
|
||||
import pooler
|
||||
import wizard
|
||||
import base64
|
||||
|
||||
import time
|
||||
import pooler
|
||||
import mx.DateTime
|
||||
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 :" />
|
||||
@@ -367,17 +370,17 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
payment = payment_obj.browse(cr, uid, data['id'], context=context)
|
||||
|
||||
if not payment.mode or payment.mode.type.code != 'dta':
|
||||
raise wizard.except_wizard(_('Error'),
|
||||
raise osv.except_osv(_('Error'),
|
||||
_('No payment mode or payment type code invalid.'))
|
||||
bank = payment.mode.bank_id
|
||||
if not bank:
|
||||
raise wizard.except_wizard(_('Error'), _('No bank account for the company.'))
|
||||
raise osv.except_osv(_('Error'), _('No bank account for the company.'))
|
||||
|
||||
v['comp_bank_name']= bank.bank and bank.bank.name or False
|
||||
v['comp_bank_clearing'] = bank.bank.clearing
|
||||
|
||||
if not v['comp_bank_clearing']:
|
||||
raise wizard.except_wizard(_('Error'),
|
||||
raise osv.except_osv(_('Error'),
|
||||
_('You must provide a Clearing Number for your bank account.'))
|
||||
|
||||
user = pool.get('res.users').browse(cr,uid,[uid])[0]
|
||||
@@ -398,7 +401,7 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
else:
|
||||
v['comp_bank_iban'] = ''
|
||||
if not v['comp_bank_iban']:
|
||||
raise wizard.except_wizard(_('Error'),
|
||||
raise osv.except_osv(_('Error'),
|
||||
_('No IBAN for the company bank account.'))
|
||||
|
||||
dta_line_obj = pool.get('account.dta.line')
|
||||
@@ -410,10 +413,10 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
|
||||
for pline in payment.line_ids:
|
||||
if not pline.bank_id:
|
||||
raise wizard.except_wizard(_('Error'), _('No bank account defined\n' \
|
||||
raise osv.except_osv(_('Error'), _('No bank account defined\n' \
|
||||
'on line: %s') % pline.name)
|
||||
if not pline.bank_id.bank:
|
||||
raise wizard.except_wizard(_('Error'), _('No bank defined\n' \
|
||||
raise osv.except_osv(_('Error'), _('No bank defined\n' \
|
||||
'for the bank account: %s\n' \
|
||||
'on the partner: %s\n' \
|
||||
'on line: %s') + (pline.bank_id.state, pline.partner_id.name, pline.name))
|
||||
@@ -426,7 +429,7 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
v['partner_bank_name'] = pline.bank_id.bank.name or False
|
||||
v['partner_bank_clearing'] = pline.bank_id.bank.clearing or False
|
||||
if not v['partner_bank_name'] :
|
||||
raise wizard.except_wizard(_('Error'), _('No bank name defined\n' \
|
||||
raise osv.except_osv(_('Error'), _('No bank name defined\n' \
|
||||
'for the bank account: %s\n' \
|
||||
'on the partner: %s\n' \
|
||||
'on line: %s') % (pline.bank_id.state, pline.partner_id.name, pline.name))
|
||||
@@ -480,7 +483,7 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
v['partner_city']= ''
|
||||
v['partner_zip']= ''
|
||||
v['partner_country']= ''
|
||||
raise wizard.except_wizard('Error', 'No address defined \n' \
|
||||
raise osv.except_osv('Error', 'No address defined \n' \
|
||||
'for the partner: ' + pline.partner_id.name + '\n' \
|
||||
'on line: ' + pline.name)
|
||||
|
||||
@@ -501,7 +504,7 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
v['comp_country'] = co_addr.country_id and co_addr.country_id.code+'-' or ''
|
||||
record_type = record_gt836
|
||||
if not v['partner_bank_iban']:
|
||||
raise wizard.except_wizard(_('Error'), _('No IBAN defined \n' \
|
||||
raise osv.except_osv(_('Error'), _('No IBAN defined \n' \
|
||||
'for the bank account: %s\n' + \
|
||||
'on line: %s') % (res_partner_bank_obj.name_get(cr, uid, [pline.bank_id.id], context)[0][1] , pline.name))
|
||||
|
||||
@@ -517,7 +520,7 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
+ ' ' + v['partner_bank_city'] \
|
||||
+ ' ' + v['partner_bank_country']
|
||||
else:
|
||||
raise wizard.except_wizard(_('Error'), _('You must provide the bank city '
|
||||
raise osv.except_osv(_('Error'), _('You must provide the bank city '
|
||||
'or the bic code for the partner bank: \n %d\n' + \
|
||||
'on line: %s') %(res_partner_bank_obj.name_get(cr, uid, [pline.bank_id.id], context)[0][1], pline.name))
|
||||
|
||||
@@ -529,11 +532,11 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
if not v['reference'] \
|
||||
or (mod10r(v['reference'][:-1]) != v['reference'] and \
|
||||
not len(v['reference']) == 15):
|
||||
raise wizard.except_wizard(_('Error'), _('You must provide ' \
|
||||
raise osv.except_osv(_('Error'), _('You must provide ' \
|
||||
'a valid BVR reference number \n' \
|
||||
'for the line: %s') % pline.name)
|
||||
if not v['partner_bvr']:
|
||||
raise wizard.except_wizard(_('Error'), _('You must provide a BVR number\n'
|
||||
raise osv.except_osv(_('Error'), _('You must provide a BVR number\n'
|
||||
'for the bank account: %s' \
|
||||
'on line: %s') % (res_partner_bank_obj.name_get(cr, uid, [pline.bank_id.id],context)[0][1] ,pline.name))
|
||||
record_type = record_gt826
|
||||
@@ -543,12 +546,12 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
if v['partner_bank_iban'] :
|
||||
v['partner_bank_number']= v['partner_bank_iban']
|
||||
else:
|
||||
raise wizard.except_wizard(_('Error'), _('You must provide ' \
|
||||
raise osv.except_osv(_('Error'), _('You must provide ' \
|
||||
'a bank number \n' \
|
||||
'for the partner bank: %s\n' \
|
||||
'on line: %s') % (res_partner_bank_obj.name_get(cr, uid, [pline.bank_id.id], context)[0][1] , pline.name))
|
||||
if not v['partner_bank_clearing']:
|
||||
raise wizard.except_wizard(_('Error'), _('You must provide ' \
|
||||
raise osv.except_osv(_('Error'), _('You must provide ' \
|
||||
'a Clearing Number\n' \
|
||||
'for the partner bank: %s\n' \
|
||||
'on line %s') % (res_partner_bank_obj.name_get(cr, uid, [pline.bank_id.id], context)[0][1] , pline.name))
|
||||
@@ -556,7 +559,7 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
record_type = record_gt827
|
||||
elif elec_pay == 'bvpost':
|
||||
if not v['partner_post_number']:
|
||||
raise wizard.except_wizard(_('Error'), _('You must provide ' \
|
||||
raise osv.except_osv(_('Error'), _('You must provide ' \
|
||||
'a post number \n' \
|
||||
'for the partner bank: %s\n' \
|
||||
'on line: %s') % (res_partner_bank_obj.name_get(cr, uid, [pline.bank_id.id], context)[0][1] ,pline.name))
|
||||
@@ -564,7 +567,7 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
v['partner_bank_number'] = '/C/'+v['partner_post_number']
|
||||
record_type = record_gt827
|
||||
else:
|
||||
raise wizard.except_wizard(_('Error'), _('The Bank type %s of the bank account: %s is not supported') \
|
||||
raise osv.except_osv(_('Error'), _('The Bank type %s of the bank account: %s is not supported') \
|
||||
% (elec_pay, res_partner_bank_obj.name_get(cr, uid, [pline.bank_id.id], context)[0][1],))
|
||||
|
||||
dta_line = record_type(v).generate()
|
||||
@@ -591,18 +594,36 @@ def _create_dta(obj, cr, uid, data, context):
|
||||
}, context=context)
|
||||
return {'dta': dta_data}
|
||||
|
||||
|
||||
class wizard_dta_create(wizard.interface):
|
||||
states = {
|
||||
'init' : {
|
||||
'actions' : [_create_dta],
|
||||
'result' : {'type' : 'form',
|
||||
'arch' : FORM,
|
||||
'fields' : FIELDS,
|
||||
'state' : [('end', 'OK', 'gtk-ok', True)]
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
wizard_dta_create('account.dta_create')
|
||||
class create_dta_wizard(osv.osv_memory):
|
||||
_name="create.dta.wizard"
|
||||
_columns={'dta_file':fields.binary('DTA File', readonly=True)}
|
||||
def create_dta(self, cr, uid, ids, context=None):
|
||||
if not context:
|
||||
context={}
|
||||
data={}
|
||||
active_ids = context.get('active_ids', [])
|
||||
active_id = context.get('active_id', [])
|
||||
data['form'] = {}
|
||||
data['ids'] = active_ids
|
||||
data['id'] = active_id
|
||||
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):
|
||||
obj_model = self.pool.get('ir.model.data')
|
||||
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')],
|
||||
'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:
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- Create DTA -->
|
||||
<record id="dta_create_view" model="ir.ui.view">
|
||||
<field name="name">Create DTA</field>
|
||||
<field name="model">create.dta.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="DTA file creation - Results">
|
||||
<group width="300" colspan="4">
|
||||
<separator string="Create DTA" colspan="4"/>
|
||||
<group colspan="4">
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel" colspan="2"/>
|
||||
<button name="create_dta" string="Create DTA" type="object" icon="gtk-ok" colspan="2"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_dta_create" model="ir.actions.act_window">
|
||||
<field name="name">Create DTA</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">create.dta.wizard</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="dta_create_view"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="action_account_dtr_create_values">
|
||||
<field name="model_id" ref="model_create_dta_wizard" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Create DTA</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' +str(ref('action_dta_create'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">payment.order</field>
|
||||
</record>
|
||||
|
||||
<!-- Save DTA -->
|
||||
<record id="dta_save_view" model="ir.ui.view">
|
||||
<field name="name">Save DTA</field>
|
||||
<field name="model">create.dta.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="DTA file creation - Results">
|
||||
<group width="500" colspan="4">
|
||||
<separator colspan="4" string="Click on 'Save as' to save the DTA file :" />
|
||||
<field name="dta_file"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user