diff --git a/addons/account_check_writing/__openerp__.py b/addons/account_check_writing/__openerp__.py index f5a2355b002..e01c17d66a7 100644 --- a/addons/account_check_writing/__openerp__.py +++ b/addons/account_check_writing/__openerp__.py @@ -30,6 +30,7 @@ Module for the Check Writing and Check Printing. 'website': 'http://www.openerp.com', 'depends' : ['account_voucher'], 'data': [ + 'wizard/account_check_batch_printing_view.xml', 'account_check_writing_report.xml', 'account_view.xml', 'account_voucher_view.xml', diff --git a/addons/account_check_writing/wizard/__init__.py b/addons/account_check_writing/wizard/__init__.py new file mode 100644 index 00000000000..d39c8716122 --- /dev/null +++ b/addons/account_check_writing/wizard/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import account_check_batch_printing + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_check_writing/wizard/account_check_batch_printing.py b/addons/account_check_writing/wizard/account_check_batch_printing.py new file mode 100644 index 00000000000..76489dee901 --- /dev/null +++ b/addons/account_check_writing/wizard/account_check_batch_printing.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from tools.translate import _ + +from osv import fields, osv + +class account_check_write(osv.osv_memory): + _name = 'account.check.write' + _description = 'Prin Check in Batch' + + _columns = { + 'check_number': fields.integer('Next Check Number', required=True, help="The number of the next check number to be printed."), + } + + def _get_next_number(self, cr, uid, context=None): + dummy, sequence_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_check_writing', 'sequence_check_number') + return self.pool.get('ir.sequence').read(cr, uid, sequence_id, ['number_next'])['number_next'] + + _defaults = { + 'check_number': _get_next_number, + } + + def print_check_write(self, cr, uid, ids, context=None): + if context is None: + context = {} + voucher_obj = self.pool.get('account.voucher') + ir_sequence_obj = self.pool.get('ir.sequence') + + #update the sequence to number the checks from the value encoded in the wizard + dummy, sequence_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_check_writing', 'sequence_check_number') + increment = ir_sequence_obj.read(cr, uid, sequence_id, ['number_increment'])['number_increment'] + new_value = self.browse(cr, uid, ids[0], context=context).check_number + ir_sequence_obj.write(cr, uid, sequence_id, {'number_next': new_value}) + + #validate the checks so that they get a number + voucher_ids = context.get('active_ids', []) + for check in voucher_obj.browse(cr, uid, voucher_ids, context=context): + new_value += increment + if check.number: + raise osv.except_osv(_('Error!'),_("One of the printed check already got a number.")) + voucher_obj.proforma_voucher(cr, uid, voucher_ids, context=context) + + #update the sequence again (because the assignation using next_val was made during the same transaction of + #the first update of sequence) + ir_sequence_obj.write(cr, uid, sequence_id, {'number_next': new_value}) + + #print the checks + check_layout_report = { + 'top' : 'account.print.check.top', + 'middle' : 'account.print.check.middle', + 'bottom' : 'account.print.check.bottom', + } + check_layout = voucher_obj.browse(cr, uid, voucher_ids[0], context=context).company_id.check_layout + if not check_layout: + check_layout = 'top' + return { + 'type': 'ir.actions.report.xml', + 'report_name':check_layout_report[check_layout], + 'datas': { + 'model':'account.voucher', + 'ids': voucher_ids, + 'report_type': 'pdf' + }, + 'nodestroy': True + } + +account_check_write() + diff --git a/addons/account_check_writing/wizard/account_check_batch_printing_view.xml b/addons/account_check_writing/wizard/account_check_batch_printing_view.xml new file mode 100644 index 00000000000..ea81c444d91 --- /dev/null +++ b/addons/account_check_writing/wizard/account_check_batch_printing_view.xml @@ -0,0 +1,28 @@ + + + + + + account.check.form + account.check.write + +
+ + + +
+
+
+
+
+ + + +
+