Merge lp:~openerp-dev/openobject-addons/trunk-account_check_writing-rpr into lp:openobject-addons

Proposed by Rajesh Prajapati (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-account_check_writing-rpr
Merge into: lp:openobject-addons
Diff against target: 166 lines (+140/-0)
4 files modified
account_check_writing/__openerp__.py (+1/-0)
account_check_writing/wizard/__init__.py (+24/-0)
account_check_writing/wizard/account_check_batch_printing.py (+87/-0)
account_check_writing/wizard/account_check_batch_printing_view.xml (+28/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-account_check_writing-rpr
Reviewer Review Type Date Requested Status
DJ Patel (OpenERP) (community) Approve
OpenERP Core Team Pending
Review via email: mp+135868@code.launchpad.net

Description of the change

Hello

     Improved check writing module as per requirement

Thanks,
Rajesh

To post a comment you must log in.
Revision history for this message
DJ Patel (OpenERP) (mdi-openerp) :
review: Approve
8112. By Rajesh Prajapati (OpenERP)

[IMP] check_writing : method updated

8113. By DJ Patel (OpenERP)

[Merge] Merge with main addons.

8114. By Quentin (OpenERP) <email address hidden>

[FIX] account_check_writing: print check in batch

8115. By Quentin (OpenERP) <email address hidden>

[IMP] account_check_writing: improved name of files

8116. By Quentin (OpenERP) <email address hidden>

[MERGE] trunk

Unmerged revisions

8116. By Quentin (OpenERP) <email address hidden>

[MERGE] trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_check_writing/__openerp__.py'
2--- account_check_writing/__openerp__.py 2012-11-29 22:26:45 +0000
3+++ account_check_writing/__openerp__.py 2012-12-06 11:58:28 +0000
4@@ -30,6 +30,7 @@
5 'website': 'http://www.openerp.com',
6 'depends' : ['account_voucher'],
7 'data': [
8+ 'wizard/account_check_batch_printing_view.xml',
9 'account_check_writing_report.xml',
10 'account_view.xml',
11 'account_voucher_view.xml',
12
13=== added directory 'account_check_writing/wizard'
14=== added file 'account_check_writing/wizard/__init__.py'
15--- account_check_writing/wizard/__init__.py 1970-01-01 00:00:00 +0000
16+++ account_check_writing/wizard/__init__.py 2012-12-06 11:58:28 +0000
17@@ -0,0 +1,24 @@
18+# -*- coding: utf-8 -*-
19+##############################################################################
20+#
21+# OpenERP, Open Source Management Solution
22+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
23+#
24+# This program is free software: you can redistribute it and/or modify
25+# it under the terms of the GNU Affero General Public License as
26+# published by the Free Software Foundation, either version 3 of the
27+# License, or (at your option) any later version.
28+#
29+# This program is distributed in the hope that it will be useful,
30+# but WITHOUT ANY WARRANTY; without even the implied warranty of
31+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32+# GNU Affero General Public License for more details.
33+#
34+# You should have received a copy of the GNU Affero General Public License
35+# along with this program. If not, see <http://www.gnu.org/licenses/>.
36+#
37+##############################################################################
38+
39+import account_check_batch_printing
40+
41+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
42
43=== added file 'account_check_writing/wizard/account_check_batch_printing.py'
44--- account_check_writing/wizard/account_check_batch_printing.py 1970-01-01 00:00:00 +0000
45+++ account_check_writing/wizard/account_check_batch_printing.py 2012-12-06 11:58:28 +0000
46@@ -0,0 +1,87 @@
47+# -*- coding: utf-8 -*-
48+##############################################################################
49+#
50+# OpenERP, Open Source Management Solution
51+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
52+#
53+# This program is free software: you can redistribute it and/or modify
54+# it under the terms of the GNU Affero General Public License as
55+# published by the Free Software Foundation, either version 3 of the
56+# License, or (at your option) any later version.
57+#
58+# This program is distributed in the hope that it will be useful,
59+# but WITHOUT ANY WARRANTY; without even the implied warranty of
60+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61+# GNU Affero General Public License for more details.
62+#
63+# You should have received a copy of the GNU Affero General Public License
64+# along with this program. If not, see <http://www.gnu.org/licenses/>.
65+#
66+##############################################################################
67+
68+from tools.translate import _
69+
70+from osv import fields, osv
71+
72+class account_check_write(osv.osv_memory):
73+ _name = 'account.check.write'
74+ _description = 'Prin Check in Batch'
75+
76+ _columns = {
77+ 'check_number': fields.integer('Next Check Number', required=True, help="The number of the next check number to be printed."),
78+ }
79+
80+ def _get_next_number(self, cr, uid, context=None):
81+ dummy, sequence_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_check_writing', 'sequence_check_number')
82+ return self.pool.get('ir.sequence').read(cr, uid, sequence_id, ['number_next'])['number_next']
83+
84+ _defaults = {
85+ 'check_number': _get_next_number,
86+ }
87+
88+ def print_check_write(self, cr, uid, ids, context=None):
89+ if context is None:
90+ context = {}
91+ voucher_obj = self.pool.get('account.voucher')
92+ ir_sequence_obj = self.pool.get('ir.sequence')
93+
94+ #update the sequence to number the checks from the value encoded in the wizard
95+ dummy, sequence_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_check_writing', 'sequence_check_number')
96+ increment = ir_sequence_obj.read(cr, uid, sequence_id, ['number_increment'])['number_increment']
97+ new_value = self.browse(cr, uid, ids[0], context=context).check_number
98+ ir_sequence_obj.write(cr, uid, sequence_id, {'number_next': new_value})
99+
100+ #validate the checks so that they get a number
101+ voucher_ids = context.get('active_ids', [])
102+ for check in voucher_obj.browse(cr, uid, voucher_ids, context=context):
103+ new_value += increment
104+ if check.number:
105+ raise osv.except_osv(_('Error!'),_("One of the printed check already got a number."))
106+ voucher_obj.proforma_voucher(cr, uid, voucher_ids, context=context)
107+
108+ #update the sequence again (because the assignation using next_val was made during the same transaction of
109+ #the first update of sequence)
110+ ir_sequence_obj.write(cr, uid, sequence_id, {'number_next': new_value})
111+
112+ #print the checks
113+ check_layout_report = {
114+ 'top' : 'account.print.check.top',
115+ 'middle' : 'account.print.check.middle',
116+ 'bottom' : 'account.print.check.bottom',
117+ }
118+ check_layout = voucher_obj.browse(cr, uid, voucher_ids[0], context=context).company_id.check_layout
119+ if not check_layout:
120+ check_layout = 'top'
121+ return {
122+ 'type': 'ir.actions.report.xml',
123+ 'report_name':check_layout_report[check_layout],
124+ 'datas': {
125+ 'model':'account.voucher',
126+ 'ids': voucher_ids,
127+ 'report_type': 'pdf'
128+ },
129+ 'nodestroy': True
130+ }
131+
132+account_check_write()
133+
134
135=== added file 'account_check_writing/wizard/account_check_batch_printing_view.xml'
136--- account_check_writing/wizard/account_check_batch_printing_view.xml 1970-01-01 00:00:00 +0000
137+++ account_check_writing/wizard/account_check_batch_printing_view.xml 2012-12-06 11:58:28 +0000
138@@ -0,0 +1,28 @@
139+<?xml version="1.0" encoding="utf-8"?>
140+<openerp>
141+ <data noupdate="0">
142+
143+ <record id="view_account_check_write" model="ir.ui.view">
144+ <field name="name">account.check.form</field>
145+ <field name="model">account.check.write</field>
146+ <field name="arch" type="xml">
147+ <form string="Check" version="7.0">
148+ <group col="4">
149+ <field name="check_number"/>
150+ </group>
151+ <footer>
152+ <button name="print_check_write" string="Print Check" type="object" class="oe_highlight"/> or
153+ <button string="Cancel" class="oe_link" special="cancel"/>
154+ </footer>
155+ </form>
156+ </field>
157+ </record>
158+
159+ <act_window id="action_account_check_write"
160+ multi="True"
161+ name="Print Check in Batch"
162+ res_model="account.check.write" src_model="account.voucher"
163+ view_mode="form" target="new" view_type="form" />
164+
165+ </data>
166+</openerp>

Subscribers

People subscribed via source and target branches

to all changes: