1 # -*- encoding: utf-8 -*-
6 # Created by Nicolas Bessi based on Credric Krier contribution
8 # Copyright (c) 2010 CamptoCamp. All rights reserved.
9 ##############################################################################
10 # WARNING: This program as such is intended to be used by professional
11 # programmers who take the whole responsability of assessing all potential
12 # consequences resulting from its eventual inadequacies and bugs
13 # End users who are looking for a ready-to-use solution with commercial
14 # garantees and support are strongly adviced to contract a Free Software
17 # This program is Free Software; you can redistribute it and/or
18 # modify it under the terms of the GNU General Public License
19 # as published by the Free Software Foundation; either version 2
20 # of the License, or (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write to the Free Software
29 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 ##############################################################################
32 """Wizzard use for printing ESR/BVR"""
38 def _check(self, cursor, uid, data, context):
39 """Check if the invoice is ready to be printed"""
40 pool = pooler.get_pool(cursor.dbname)
41 invoice_obj = pool.get('account.invoice')
42 for invoice in invoice_obj.browse(cursor, uid, data['ids'], context):
43 if not invoice.partner_bank:
44 raise wizard.except_wizard('UserError',
45 'No bank specified on invoice:\n' + \
46 invoice_obj.name_get(cursor, uid, [invoice.id],
47 context=context)[0][1])
48 if not re.compile('[0-9][0-9]-[0-9]{3,6}-[0-9]').match(
49 invoice.partner_bank.bvr_number or ''):
50 raise wizard.except_wizard('UserError',
51 "Your bank BVR number should be of the form 0X-XXX-X! " +
52 'Please check your company ' +
53 'information for the invoice:\n' +
54 invoice_obj.name_get(cursor, uid, [invoice.id],
55 context=context)[0][1])
56 if invoice.partner_bank.bvr_adherent_num \
57 and not re.compile('[0-9]*$').match(
58 invoice.partner_bank.bvr_adherent_num):
59 raise wizard.except_wizard('UserError',
60 'Your bank BVR adherent number must contain exactly seven' +
61 'digits!\nPlease check your company ' +
62 'information for the invoice:\n' + +
63 invoice_obj.name_get(cursor, uid, [invoice.id],
64 context=context)[0][1])
67 class WizardReport(wizard.interface):
68 """Wizzard use for printing ESR/BVR without invoice layout"""
73 'result': {'type':'print', 'report':'l10n_ch.bvr', 'state':'end'}
76 WizardReport('l10n_ch.bvr.check')
78 class ReportInvoiceBVRCheck(wizard.interface):
79 """Wizzard use for printing ESR/BVR without with layout"""
85 'report':'l10n_ch.invoice.bvr',
90 ReportInvoiceBVRCheck('l10n_ch.invoice.bvr.check')