Merge lp:~rr.clearcorp/openerp-ccorp-addons/6.1-account_voucher_reverse_feature into lp:openerp-ccorp-addons/6.1
- 6.1-account_voucher_reverse_feature
- Merge into 6.1
Proposed by
Ronald Rubi
Status: | Merged |
---|---|
Merged at revision: | 577 |
Proposed branch: | lp:~rr.clearcorp/openerp-ccorp-addons/6.1-account_voucher_reverse_feature |
Merge into: | lp:openerp-ccorp-addons/6.1 |
Diff against target: |
343 lines (+317/-0) 5 files modified
account_voucher_reverse/__init__.py (+23/-0) account_voucher_reverse/__openerp__.py (+48/-0) account_voucher_reverse/account_voucher_reverse.py (+141/-0) account_voucher_reverse/account_voucher_reverse_view.xml (+84/-0) account_voucher_reverse/workflow/account_voucher_reverse_workflow.xml (+21/-0) |
To merge this branch: | bzr merge lp:~rr.clearcorp/openerp-ccorp-addons/6.1-account_voucher_reverse_feature |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
ClearCorp drivers | Pending | ||
Review via email: mp+113468@code.launchpad.net |
Commit message
Description of the change
Add module account_
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'account_voucher_reverse' |
2 | === added file 'account_voucher_reverse/__init__.py' |
3 | --- account_voucher_reverse/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ account_voucher_reverse/__init__.py 2012-07-04 23:00:26 +0000 |
5 | @@ -0,0 +1,23 @@ |
6 | +# -*- coding: utf-8 -*- |
7 | +############################################################################## |
8 | +# |
9 | +# OpenERP, Open Source Management Solution |
10 | +# Addons modules by CLEARCORP S.A. |
11 | +# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>). |
12 | +# |
13 | +# This program is free software: you can redistribute it and/or modify |
14 | +# it under the terms of the GNU Affero General Public License as |
15 | +# published by the Free Software Foundation, either version 3 of the |
16 | +# License, or (at your option) any later version. |
17 | +# |
18 | +# This program is distributed in the hope that it will be useful, |
19 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | +# GNU Affero General Public License for more details. |
22 | +# |
23 | +# You should have received a copy of the GNU Affero General Public License |
24 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
25 | +# |
26 | +############################################################################## |
27 | + |
28 | +import account_voucher_reverse |
29 | |
30 | === added file 'account_voucher_reverse/__openerp__.py' |
31 | --- account_voucher_reverse/__openerp__.py 1970-01-01 00:00:00 +0000 |
32 | +++ account_voucher_reverse/__openerp__.py 2012-07-04 23:00:26 +0000 |
33 | @@ -0,0 +1,48 @@ |
34 | +# -*- coding: utf-8 -*- |
35 | +############################################################################## |
36 | +# |
37 | +# OpenERP, Open Source Management Solution |
38 | +# Addons modules by CLEARCORP S.A. |
39 | +# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>). |
40 | +# |
41 | +# This program is free software: you can redistribute it and/or modify |
42 | +# it under the terms of the GNU Affero General Public License as |
43 | +# published by the Free Software Foundation, either version 3 of the |
44 | +# License, or (at your option) any later version. |
45 | +# |
46 | +# This program is distributed in the hope that it will be useful, |
47 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
48 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
49 | +# GNU Affero General Public License for more details. |
50 | +# |
51 | +# You should have received a copy of the GNU Affero General Public License |
52 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
53 | +# |
54 | +############################################################################## |
55 | + |
56 | +{ |
57 | + "name" : "Account Voucher Reverse", |
58 | + "version" : '1.0', |
59 | + "author" : 'CLEARCORP S.A.', |
60 | + 'complexity': 'normal', |
61 | + "description": """ |
62 | +Module for reverse account vouchers |
63 | + """, |
64 | + "category": 'Accounting & Finance', |
65 | + "sequence": 4, |
66 | + "website" : "http://clearcorp.co.cr", |
67 | + "images" : [], |
68 | + "icon" : False, |
69 | + "depends" : ["account_voucher"], |
70 | + "init_xml" : [], |
71 | + "demo_xml" : [], |
72 | + "update_xml" : [ |
73 | + "account_voucher_reverse_view.xml", |
74 | + "workflow/account_voucher_reverse_workflow.xml", |
75 | + ], |
76 | + "test" : [], |
77 | + "auto_install": False, |
78 | + "application": False, |
79 | + "installable": True, |
80 | + 'license': 'AGPL-3', |
81 | +} |
82 | |
83 | === added file 'account_voucher_reverse/account_voucher_reverse.py' |
84 | --- account_voucher_reverse/account_voucher_reverse.py 1970-01-01 00:00:00 +0000 |
85 | +++ account_voucher_reverse/account_voucher_reverse.py 2012-07-04 23:00:26 +0000 |
86 | @@ -0,0 +1,141 @@ |
87 | +# -*- coding: utf-8 -*- |
88 | +############################################################################## |
89 | +# |
90 | +# OpenERP, Open Source Management Solution |
91 | +# Addons modules by CLEARCORP S.A. |
92 | +# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>). |
93 | +# |
94 | +# This program is free software: you can redistribute it and/or modify |
95 | +# it under the terms of the GNU Affero General Public License as |
96 | +# published by the Free Software Foundation, either version 3 of the |
97 | +# License, or (at your option) any later version. |
98 | +# |
99 | +# This program is distributed in the hope that it will be useful, |
100 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
101 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
102 | +# GNU Affero General Public License for more details. |
103 | +# |
104 | +# You should have received a copy of the GNU Affero General Public License |
105 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
106 | +# |
107 | +############################################################################## |
108 | + |
109 | +from osv import osv, fields |
110 | + |
111 | +class account_voucher_reverse(osv.osv): |
112 | + _name = 'account.voucher' |
113 | + _inherit = 'account.voucher' |
114 | + |
115 | + _columns = { |
116 | + 'state':fields.selection( |
117 | + [('draft','Draft'), |
118 | + ('proforma','Pro-forma'), |
119 | + ('posted','Posted'), |
120 | + ('reverse','Reverse'), |
121 | + ('cancel','Cancelled') |
122 | + ], 'State', readonly=True, size=32, |
123 | + help=' * The \'Draft\' state is used when a user is encoding a new and unconfirmed Voucher. \ |
124 | + \n* The \'Pro-forma\' when voucher is in Pro-forma state,voucher does not have an voucher number. \ |
125 | + \n* The \'Posted\' state is used when user create voucher,a voucher number is generated and voucher entries are created in account \ |
126 | + \n* The \'Reverse\' state is used when user reverse voucher \ |
127 | + \n* The \'Cancelled\' state is used when user cancel voucher.'), |
128 | + } |
129 | + |
130 | + def reverse_voucher(self, cr, uid, ids, context=None): |
131 | + |
132 | + self.write(cr, uid, ids, {'state' : 'reverse'}, context=context) |
133 | + |
134 | + #To create a move reverse |
135 | + self.account_voucher_move_reverse(cr, uid, ids, context=context) |
136 | + |
137 | + return True |
138 | + |
139 | + def account_voucher_move_reverse(self, cr, uid, ids, context=None): |
140 | + # Initialize voucher variables and check if voucher has a move, a journal and an account |
141 | + # If not, exit and return original result |
142 | + voucher = self.browse(cr,uid,ids,context=context)[0] |
143 | + if not voucher.move_id: |
144 | + return False |
145 | + |
146 | + original_move = voucher.move_id |
147 | + |
148 | + if not original_move.line_id: |
149 | + return False |
150 | + |
151 | + move = { |
152 | + 'name':'Reverse: ' + original_move.name, |
153 | + 'ref':original_move.ref, |
154 | + 'journal_id':original_move.journal_id.id, |
155 | + 'period_id':original_move.period_id.id, |
156 | + 'to_check':False, |
157 | + 'partner_id':original_move.partner_id.id, |
158 | + 'date':original_move.date, |
159 | + 'narration':original_move.narration, |
160 | + 'company_id':original_move.company_id.id, |
161 | + } |
162 | + move_id = self.pool.get('account.move').create(cr, uid, move) |
163 | + |
164 | + move_reconcile_obj = self.pool.get('account.move.reconcile') |
165 | + |
166 | + lines = original_move.line_id |
167 | + for line in lines: |
168 | + move_line = { |
169 | + 'name':line.name, |
170 | + 'debit':line.credit, |
171 | + 'credit':line.debit, |
172 | + 'account_id':line.account_id.id, |
173 | + 'move_id': move_id, |
174 | + 'amount_currency':line.amount_currency * -1, |
175 | + 'period_id':line.period_id.id, |
176 | + 'journal_id':line.journal_id.id, |
177 | + 'partner_id':line.partner_id.id, |
178 | + 'currency_id':line.currency_id.id, |
179 | + 'date_maturity':line.date_maturity, |
180 | + 'date':line.date, |
181 | + 'date_created':line.date_created, |
182 | + 'state':'valid', |
183 | + 'company_id':line.company_id.id, |
184 | + } |
185 | + |
186 | + line_created_id = self.pool.get('account.move.line').create(cr, uid, move_line) |
187 | + |
188 | + if (original_move.journal_id.entry_posted): |
189 | + self.pool.get('account.move').post(cr, uid, [move_id], context={}) |
190 | + |
191 | + if line.reconcile_id: |
192 | + reconcile = move_reconcile_obj.browse(cr,uid,[line.reconcile_id.id],context=context)[0] |
193 | + if len(reconcile.line_id) > 2: |
194 | + self.pool.get('account.move.line').write(cr,uid,line.id,{'reconcile_id': False }) |
195 | + for line in reconcile.line_id: |
196 | + self.pool.get('account.move.line').write(cr,uid,line.id,{'reconcile_id': False,'reconcile_partial_id':line.reconcile_id.id}) |
197 | + else: |
198 | + move_reconcile_obj.unlink(cr,uid,[line.reconcile_id.id],context=context) |
199 | + |
200 | + if line.reconcile_partial_id: |
201 | + reconcile = move_reconcile_obj.browse(cr,uid,[line.reconcile_partial_id.id],context=context)[0] |
202 | + if len(reconcile.line_partial_ids) > 2: |
203 | + self.pool.get('account.move.line').write(cr,uid,line.id,{'reconcile_partial_id': False }) |
204 | + else: |
205 | + move_reconcile_obj.unlink(cr,uid,[line.reconcile_partial_id.id],context=context) |
206 | + |
207 | + if line.account_id.reconcile: |
208 | + reconcile_id = self.pool.get('account.move.reconcile').create(cr, uid, {'type': 'Account Reverse'}) |
209 | + self.pool.get('account.move.line').write(cr,uid,[line.id],{'reconcile_id': reconcile_id}) |
210 | + self.pool.get('account.move.line').write(cr,uid,[line_created_id],{'reconcile_id': reconcile_id}) |
211 | + |
212 | + return True |
213 | + |
214 | + |
215 | + |
216 | + |
217 | + |
218 | + |
219 | + |
220 | + |
221 | + |
222 | + |
223 | + |
224 | + |
225 | + |
226 | + |
227 | + |
228 | |
229 | === added file 'account_voucher_reverse/account_voucher_reverse_view.xml' |
230 | --- account_voucher_reverse/account_voucher_reverse_view.xml 1970-01-01 00:00:00 +0000 |
231 | +++ account_voucher_reverse/account_voucher_reverse_view.xml 2012-07-04 23:00:26 +0000 |
232 | @@ -0,0 +1,84 @@ |
233 | +<?xml version="1.0" encoding="UTF-8"?> |
234 | +<openerp> |
235 | + <data> |
236 | + <record id="view_vendor_receipt_reverse_form" model="ir.ui.view"> |
237 | + <field name="name">account.voucher.receipt.reverse.form</field> |
238 | + <field name="model">account.voucher</field> |
239 | + <field name="type">form</field> |
240 | + <field name="inherit_id" ref="account_voucher.view_vendor_receipt_form"/> |
241 | + <field name="arch" type="xml"> |
242 | + <data> |
243 | + <xpath expr = "/form/group/field[@name='state']" position = "after"> |
244 | + <button name="reverse_voucher" string="Reverse" type="object" states="posted" invisible="context.get('line_type', False)" icon="STOCK_REVERT_TO_SAVED" confirm="Are you sure to reverse this record ?"/> |
245 | + </xpath> |
246 | + <xpath expr = "/form/notebook/page[@string='Journal Items']" position = "replace"> |
247 | + <page string="Journal Items" groups="base.group_extended" attrs="{'invisible': ['|','|',('state','=','draft'),('state','=','proforma'),('state','=','cancel')]}"> |
248 | + <group col="6" colspan="4"> |
249 | + <field name="period_id"/> |
250 | + <field name="audit"/> |
251 | + </group> |
252 | + <field name="number" colspan="4"/> |
253 | + <field name="move_ids" colspan="4" nolabel="1" readonly="1"> |
254 | + <tree string="Journal Items"> |
255 | + <field name="move_id"/> |
256 | + <field name="ref"/> |
257 | + <field name="date"/> |
258 | + <field name="statement_id"/> |
259 | + <field name="partner_id"/> |
260 | + <field name="account_id"/> |
261 | + <field name="name"/> |
262 | + <field name="debit"/> |
263 | + <field name="credit"/> |
264 | + <field name="state"/> |
265 | + <field name="reconcile_id"/> |
266 | + <field name="amount_currency"/> |
267 | + <field name="currency_id"/> |
268 | + </tree> |
269 | + </field> |
270 | + </page> |
271 | + </xpath> |
272 | + </data> |
273 | + </field> |
274 | + </record> |
275 | + |
276 | + <record id="view_vendor_payment_reverse_form" model="ir.ui.view"> |
277 | + <field name="name">account.voucher.payment.reverse.form</field> |
278 | + <field name="model">account.voucher</field> |
279 | + <field name="type">form</field> |
280 | + <field name="inherit_id" ref="account_voucher.view_vendor_payment_form"/> |
281 | + <field name="arch" type="xml"> |
282 | + <data> |
283 | + <xpath expr = "/form/group/field[@name='state']" position = "after"> |
284 | + <button name="reverse_voucher" string="Reverse" type="object" states="posted" invisible="context.get('line_type', False)" icon="STOCK_REVERT_TO_SAVED" confirm="Are you sure to reverse this record ?"/> |
285 | + </xpath> |
286 | + <xpath expr = "/form/notebook/page[@string='Journal Items']" position = "replace"> |
287 | + <page string="Journal Items" groups="base.group_extended" attrs="{'invisible': ['|','|',('state','=','draft'),('state','=','proforma'),('state','=','cancel')]}"> |
288 | + <group col="6" colspan="4"> |
289 | + <field name="period_id"/> |
290 | + <field name="audit"/> |
291 | + </group> |
292 | + <field name="number" colspan="4"/> |
293 | + <field name="move_ids" colspan="4" nolabel="1" readonly="1"> |
294 | + <tree string="Journal Items"> |
295 | + <field name="move_id"/> |
296 | + <field name="ref"/> |
297 | + <field name="date"/> |
298 | + <field name="statement_id"/> |
299 | + <field name="partner_id"/> |
300 | + <field name="account_id"/> |
301 | + <field name="name"/> |
302 | + <field name="debit"/> |
303 | + <field name="credit"/> |
304 | + <field name="state"/> |
305 | + <field name="reconcile_id"/> |
306 | + <field name="amount_currency"/> |
307 | + <field name="currency_id"/> |
308 | + </tree> |
309 | + </field> |
310 | + </page> |
311 | + </xpath> |
312 | + </data> |
313 | + </field> |
314 | + </record> |
315 | + </data> |
316 | +</openerp> |
317 | |
318 | === added directory 'account_voucher_reverse/workflow' |
319 | === added file 'account_voucher_reverse/workflow/account_voucher_reverse_workflow.xml' |
320 | --- account_voucher_reverse/workflow/account_voucher_reverse_workflow.xml 1970-01-01 00:00:00 +0000 |
321 | +++ account_voucher_reverse/workflow/account_voucher_reverse_workflow.xml 2012-07-04 23:00:26 +0000 |
322 | @@ -0,0 +1,21 @@ |
323 | +<?xml version="1.0" encoding="UTF-8"?> |
324 | +<openerp> |
325 | + <data> |
326 | + |
327 | + <record id="act_reverse" model="workflow.activity"> |
328 | + <field name="wkf_id" ref="account_voucher.wkf"/> |
329 | + <field name="name">reverse</field> |
330 | + <field name="flow_stop">True</field> |
331 | + <field name="action">reverse_voucher()</field> |
332 | + <field name="kind">function</field> |
333 | + </record> |
334 | + |
335 | + <record id="account_voucher_done2reverse" model="workflow.transition"> |
336 | + <field name="act_from" ref="account_voucher.act_done" /> |
337 | + <field name="act_to" ref="act_reverse" /> |
338 | + <!-- <field name="group_id" ref="account.Accountant" /> --> |
339 | + <field name="signal">reverse_voucher</field> |
340 | + </record> |
341 | + |
342 | + </data> |
343 | +</openerp> |