Merge lp:~vauxoo/openerp-venezuela-localization/account-voucher-multi-partner-6.0 into lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk
- account-voucher-multi-partner-6.0
- Merge into 6.0-trunk
Proposed by
Javier Duran
Status: | Merged |
---|---|
Merged at revision: | 483 |
Proposed branch: | lp:~vauxoo/openerp-venezuela-localization/account-voucher-multi-partner-6.0 |
Merge into: | lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk |
Diff against target: |
1410 lines (+1368/-0) 8 files modified
account_voucher_multi_partner/__init__.py (+26/-0) account_voucher_multi_partner/__openerp__.py (+46/-0) account_voucher_multi_partner/i18n/es_VE.po (+274/-0) account_voucher_multi_partner/voucher_multi_partner.py (+252/-0) account_voucher_multi_partner/voucher_multi_partner_view.xml (+361/-0) account_voucher_patch/__init__.py (+24/-0) account_voucher_patch/__openerp__.py (+47/-0) account_voucher_patch/account_voucher.py (+338/-0) |
To merge this branch: | bzr merge lp:~vauxoo/openerp-venezuela-localization/account-voucher-multi-partner-6.0 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Javier Duran (community) | Approve | ||
hbto [Vauxoo] http://www.vauxoo.com | Pending | ||
Gabriela Quilarque | Pending | ||
Nhomar - Vauxoo | Pending | ||
Review via email: mp+83675@code.launchpad.net |
Commit message
Description of the change
Se agrega los modulos:
account_
account_
en el cual se refactoriza el método action_
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_multi_partner' |
2 | === added file 'account_voucher_multi_partner/__init__.py' |
3 | --- account_voucher_multi_partner/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ account_voucher_multi_partner/__init__.py 2011-11-28 19:36:47 +0000 |
5 | @@ -0,0 +1,26 @@ |
6 | +# -*- coding: utf-8 -*- |
7 | +############################################################################## |
8 | +# |
9 | +# OpenERP, Open Source Management Solution |
10 | +# Copyright (C) 2004-20011S Tiny SPRL (<http://tiny.be>). All Rights Reserved |
11 | +# This module was developen by Vauxoo Team: |
12 | +# Coded by: javier@vauxoo.com |
13 | +# |
14 | +# |
15 | +# This program is free software: you can redistribute it and/or modify |
16 | +# it under the terms of the GNU Affero General Public License as |
17 | +# published by the Free Software Foundation, either version 3 of the |
18 | +# License, or (at your option) any later version. |
19 | +# |
20 | +# This program is distributed in the hope that it will be useful, |
21 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | +# GNU Affero General Public License for more details. |
24 | +# |
25 | +# You should have received a copy of the GNU Affero General Public License |
26 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
27 | +# |
28 | +############################################################################## |
29 | + |
30 | +import voucher_multi_partner |
31 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
32 | |
33 | === added file 'account_voucher_multi_partner/__openerp__.py' |
34 | --- account_voucher_multi_partner/__openerp__.py 1970-01-01 00:00:00 +0000 |
35 | +++ account_voucher_multi_partner/__openerp__.py 2011-11-28 19:36:47 +0000 |
36 | @@ -0,0 +1,46 @@ |
37 | +# -*- coding: utf-8 -*- |
38 | +############################################################################## |
39 | +# |
40 | +# OpenERP, Open Source Management Solution |
41 | +# Copyright (C) 2004-20011S Tiny SPRL (<http://tiny.be>). All Rights Reserved |
42 | +# This module was developen by Vauxoo Team: |
43 | +# Coded by: javier@vauxoo.com |
44 | +# |
45 | +# |
46 | +# This program is free software: you can redistribute it and/or modify |
47 | +# it under the terms of the GNU Affero General Public License as |
48 | +# published by the Free Software Foundation, either version 3 of the |
49 | +# License, or (at your option) any later version. |
50 | +# |
51 | +# This program is distributed in the hope that it will be useful, |
52 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
53 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
54 | +# GNU Affero General Public License for more details. |
55 | +# |
56 | +# You should have received a copy of the GNU Affero General Public License |
57 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
58 | +# |
59 | +############################################################################## |
60 | +{ |
61 | + "name" : "Account voucher multi partner", |
62 | + "version" : "0.1", |
63 | + "author" : "Vauxoo", |
64 | + "website" : "http://vauxoo.com", |
65 | + "category": 'Generic Modules/Accounting', |
66 | + "description": """ |
67 | + This module extend account voucher funcionality allowed make payments or receipt |
68 | + from several partner |
69 | + """, |
70 | + 'init_xml': [], |
71 | + "depends" : ["account_voucher", "account_voucher_patch"], |
72 | + 'update_xml': [ |
73 | + 'voucher_multi_partner_view.xml', |
74 | + ], |
75 | + 'demo_xml': [], |
76 | + 'test': [], |
77 | + 'installable': True, |
78 | + 'active': False, |
79 | +} |
80 | + |
81 | + |
82 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
83 | |
84 | === added directory 'account_voucher_multi_partner/i18n' |
85 | === added file 'account_voucher_multi_partner/i18n/es_VE.po' |
86 | --- account_voucher_multi_partner/i18n/es_VE.po 1970-01-01 00:00:00 +0000 |
87 | +++ account_voucher_multi_partner/i18n/es_VE.po 2011-11-28 19:36:47 +0000 |
88 | @@ -0,0 +1,274 @@ |
89 | +# Translation of OpenERP Server. |
90 | +# This file contains the translation of the following modules: |
91 | +# * account_voucher_multi_partner |
92 | +# |
93 | +msgid "" |
94 | +msgstr "" |
95 | +"Project-Id-Version: OpenERP Server 6.1beta\n" |
96 | +"Report-Msgid-Bugs-To: \n" |
97 | +"POT-Creation-Date: 2011-11-25 15:44+0000\n" |
98 | +"PO-Revision-Date: 2011-11-25 15:44+0000\n" |
99 | +"Last-Translator: <>\n" |
100 | +"Language-Team: \n" |
101 | +"MIME-Version: 1.0\n" |
102 | +"Content-Type: text/plain; charset=UTF-8\n" |
103 | +"Content-Transfer-Encoding: \n" |
104 | +"Plural-Forms: \n" |
105 | + |
106 | +#. module: account_voucher_multi_partner |
107 | +#: view:account.voucher:0 |
108 | +msgid "Customer Payment" |
109 | +msgstr "Pago cliente" |
110 | + |
111 | +#. module: account_voucher_multi_partner |
112 | +#: view:account.voucher:0 |
113 | +msgid "Payment Ref" |
114 | +msgstr "Ref. pago" |
115 | + |
116 | +#. module: account_voucher_multi_partner |
117 | +#: view:account.voucher:0 |
118 | +msgid "Group By..." |
119 | +msgstr "Agrupar por..." |
120 | + |
121 | +#. module: account_voucher_multi_partner |
122 | +#: view:account.voucher:0 |
123 | +msgid "State" |
124 | +msgstr "Estado" |
125 | + |
126 | +#. module: account_voucher_multi_partner |
127 | +#: view:account.voucher:0 |
128 | +msgid "Draft" |
129 | +msgstr "Borrador" |
130 | + |
131 | +#. module: account_voucher_multi_partner |
132 | +#: view:account.voucher:0 |
133 | +msgid "Set to Draft" |
134 | +msgstr "Cambiar a borrador" |
135 | + |
136 | +#. module: account_voucher_multi_partner |
137 | +#: model:ir.actions.act_window,name:account_voucher_multi_partner.action_vendor_multi_partner_receipt |
138 | +#: model:ir.ui.menu,name:account_voucher_multi_partner.menu_action_vendor_multi_partner_receipt |
139 | +msgid "Several Customer Payment" |
140 | +msgstr "Pago a múltiples clientes" |
141 | + |
142 | +#. module: account_voucher_multi_partner |
143 | +#: view:account.voucher:0 |
144 | +msgid "Draft Vouchers" |
145 | +msgstr "Draft Vouchers" |
146 | + |
147 | +#. module: account_voucher_multi_partner |
148 | +#: view:account.voucher:0 |
149 | +msgid "Bill Payment" |
150 | +msgstr "Pago factura" |
151 | + |
152 | +#. module: account_voucher_multi_partner |
153 | +#: view:account.voucher:0 |
154 | +msgid "Posted Vouchers" |
155 | +msgstr "Comprobantes contabilizados" |
156 | + |
157 | +#. module: account_voucher_multi_partner |
158 | +#: view:account.voucher:0 |
159 | +msgid "Payment Method" |
160 | +msgstr "Método de pago" |
161 | + |
162 | +#. module: account_voucher_multi_partner |
163 | +#: model:ir.actions.act_window,help:account_voucher_multi_partner.action_vendor_multi_partner_payment |
164 | +msgid "The supplier payment form allows you to track the payment you do to your suppliers. When you select a supplier, the payment method and an amount for the payment, OpenERP will propose to reconcile your payment with the open supplier invoices or bills." |
165 | +msgstr "El formulario de pago de proveedor le permite gestionar los pagos que hace a sus proveedores. Cuando selecciona un proveedor, el método de pago y el importe a pagar, OpenERP propondrá la reconciliación de su pago con las facturas de proveedor o recibos pendientes." |
166 | + |
167 | +#. module: account_voucher_multi_partner |
168 | +#: view:account.voucher:0 |
169 | +msgid "Journal" |
170 | +msgstr "Diario" |
171 | + |
172 | +#. module: account_voucher_multi_partner |
173 | +#: code:addons/account_voucher_multi_partner/voucher_multi_partner.py:327 |
174 | +#, python-format |
175 | +msgid "Invalid action !" |
176 | +msgstr "!Acción invalida!" |
177 | + |
178 | +#. module: account_voucher_multi_partner |
179 | +#: view:account.voucher:0 |
180 | +msgid "Residual" |
181 | +msgstr "Residual" |
182 | + |
183 | +#. module: account_voucher_multi_partner |
184 | +#: view:account.voucher:0 |
185 | +msgid "Internal Notes" |
186 | +msgstr "Notas internas" |
187 | + |
188 | +#. module: account_voucher_multi_partner |
189 | +#: view:account.voucher:0 |
190 | +msgid "Credits" |
191 | +msgstr "Haber" |
192 | + |
193 | +#. module: account_voucher_multi_partner |
194 | +#: view:account.voucher:0 |
195 | +msgid "Are you sure to unreconcile this record ?" |
196 | +msgstr "¿Seguro que desea romper la conciliación de este registro?" |
197 | + |
198 | +#. module: account_voucher_multi_partner |
199 | +#: view:account.voucher:0 |
200 | +msgid "Journal Items" |
201 | +msgstr "Apuntes contables" |
202 | + |
203 | +#. module: account_voucher_multi_partner |
204 | +#: view:account.voucher:0 |
205 | +msgid "Other Information" |
206 | +msgstr "Otra información" |
207 | + |
208 | +#. module: account_voucher_multi_partner |
209 | +#: view:account.voucher:0 |
210 | +msgid "Validate" |
211 | +msgstr "Validar" |
212 | + |
213 | +#. module: account_voucher_multi_partner |
214 | +#: view:account.voucher:0 |
215 | +msgid "Extended Filters..." |
216 | +msgstr "Filtros extendidos..." |
217 | + |
218 | +#. module: account_voucher_multi_partner |
219 | +#: view:account.voucher:0 |
220 | +msgid "Unreconcile" |
221 | +msgstr "Romper conciliación" |
222 | + |
223 | +#. module: account_voucher_multi_partner |
224 | +#: view:account.voucher:0 |
225 | +msgid "Payment" |
226 | +msgstr "Pago" |
227 | + |
228 | +#. module: account_voucher_multi_partner |
229 | +#: code:addons/account_voucher_multi_partner/voucher_multi_partner.py:327 |
230 | +#, python-format |
231 | +msgid "Cannot validate Voucher(s) with bad total !" |
232 | +msgstr "!No puede validar Comprobantes con el total incorrecto !" |
233 | + |
234 | +#. module: account_voucher_multi_partner |
235 | +#: view:account.voucher:0 |
236 | +msgid "Posted" |
237 | +msgstr "Contabilizado" |
238 | + |
239 | +#. module: account_voucher_multi_partner |
240 | +#: view:account.voucher:0 |
241 | +msgid "Supplier Invoices and Outstanding transactions" |
242 | +msgstr "Facturas de proveedor y transiciones de salida" |
243 | + |
244 | +#. module: account_voucher_multi_partner |
245 | +#: code:addons/account_voucher_multi_partner/voucher_multi_partner.py:293 |
246 | +#, python-format |
247 | +msgid "No Account Base Code and Account Tax Code!" |
248 | +msgstr "!Sin código base y código de impuesto contable!" |
249 | + |
250 | +#. module: account_voucher_multi_partner |
251 | +#: help:account.voucher,multi_partner:0 |
252 | +msgid "Check this box if there are twice or more supplier or customer for this voucher" |
253 | +msgstr "Marque este cuadro si hay dos o más proveedores o clientes para este comprobante" |
254 | + |
255 | +#. module: account_voucher_multi_partner |
256 | +#: model:ir.actions.act_window,help:account_voucher_multi_partner.action_vendor_multi_partner_receipt |
257 | +msgid "Sales payment allows you to register the payments you receive from your customers. In order to record a payment, you must enter the customer, the payment method (=the journal) and the payment amount. OpenERP will propose to you automatically the reconciliation of this payment with the open invoices or sales receipts." |
258 | +msgstr "Los pagos de venta permiten registrar los pagos recibidos de sus clientes. Para registrar un pago, debe seleccionar el cliente, el método de pago(= el diario) y el importe del pago. OpenERP le propondrá automáticamente la reconciliación de este pago con las facturas o recibos de ventas pendientes." |
259 | + |
260 | +#. module: account_voucher_multi_partner |
261 | +#: view:account.voucher:0 |
262 | +msgid "Cancel" |
263 | +msgstr "Cancelar" |
264 | + |
265 | +#. module: account_voucher_multi_partner |
266 | +#: view:account.voucher:0 |
267 | +msgid "Payment Options" |
268 | +msgstr "Opciones de pago" |
269 | + |
270 | +#. module: account_voucher_multi_partner |
271 | +#: field:account.voucher,multi_partner:0 |
272 | +msgid "Several Supplier or Customer ?" |
273 | +msgstr "¿Múltiples proveedores o clientes?" |
274 | + |
275 | +#. module: account_voucher_multi_partner |
276 | +#: code:addons/account_voucher_multi_partner/voucher_multi_partner.py:293 |
277 | +#, python-format |
278 | +msgid "You have to configure account base code and account tax code on the '%s' tax!" |
279 | +msgstr "¡Debe configurar código de la base contable y código del impuesto contable del impuesto '%s'!" |
280 | + |
281 | +#. module: account_voucher_multi_partner |
282 | +#: view:account.voucher:0 |
283 | +msgid "Invoices and outstanding transactions" |
284 | +msgstr "Facturas y transacciones de salida" |
285 | + |
286 | +#. module: account_voucher_multi_partner |
287 | +#: field:account.voucher.line,amount_residual:0 |
288 | +msgid "Residual Amount" |
289 | +msgstr "Monto Residual" |
290 | + |
291 | +#. module: account_voucher_multi_partner |
292 | +#: view:account.voucher:0 |
293 | +msgid "Supplier" |
294 | +msgstr "Proveedor" |
295 | + |
296 | +#. module: account_voucher_multi_partner |
297 | +#: view:account.voucher:0 |
298 | +msgid "To Review" |
299 | +msgstr "A revisar" |
300 | + |
301 | +#. module: account_voucher_multi_partner |
302 | +#: model:ir.module.module,description:account_voucher_multi_partner.module_meta_information |
303 | +msgid "\n" |
304 | +" This module extend account voucher funcionality allowed make payments or receipt\n" |
305 | +" from several partner\n" |
306 | +" " |
307 | +msgstr "\n" |
308 | +" Este modulo extiende la funcionalidad de los comprobantes de pago/cobro permitiendo realizar pagos o cobros\n" |
309 | +" de varias empresas\n" |
310 | +" " |
311 | + |
312 | +#. module: account_voucher_multi_partner |
313 | +#: model:ir.model,name:account_voucher_multi_partner.model_account_voucher |
314 | +msgid "Accounting Voucher" |
315 | +msgstr "Comprobantes contables" |
316 | + |
317 | +#. module: account_voucher_multi_partner |
318 | +#: view:account.voucher:0 |
319 | +msgid "Period" |
320 | +msgstr "Período" |
321 | + |
322 | +#. module: account_voucher_multi_partner |
323 | +#: model:ir.model,name:account_voucher_multi_partner.model_account_voucher_line |
324 | +msgid "Voucher Lines" |
325 | +msgstr "Líneas de comprobante" |
326 | + |
327 | +#. module: account_voucher_multi_partner |
328 | +#: model:ir.module.module,shortdesc:account_voucher_multi_partner.module_meta_information |
329 | +msgid "Account voucher multi partner" |
330 | +msgstr "Account voucher multi partner" |
331 | + |
332 | +#. module: account_voucher_multi_partner |
333 | +#: view:account.voucher:0 |
334 | +msgid "Search Vouchers" |
335 | +msgstr "Buscar comprobantes" |
336 | + |
337 | +#. module: account_voucher_multi_partner |
338 | +#: field:account.voucher.line,invoice_id:0 |
339 | +msgid "Invoice" |
340 | +msgstr "Factura" |
341 | + |
342 | +#. module: account_voucher_multi_partner |
343 | +#: view:account.voucher:0 |
344 | +msgid "Payment Information" |
345 | +msgstr "Información de pago" |
346 | + |
347 | +#. module: account_voucher_multi_partner |
348 | +#: view:account.voucher:0 |
349 | +msgid "Open Balance" |
350 | +msgstr "Abrir balance" |
351 | + |
352 | +#. module: account_voucher_multi_partner |
353 | +#: view:account.voucher:0 |
354 | +msgid "Paid Amount" |
355 | +msgstr "Importe pagado" |
356 | + |
357 | +#. module: account_voucher_multi_partner |
358 | +#: model:ir.actions.act_window,name:account_voucher_multi_partner.action_vendor_multi_partner_payment |
359 | +#: model:ir.ui.menu,name:account_voucher_multi_partner.menu_action_vendor_multi_partner_payment |
360 | +msgid "Several Supplier Payment" |
361 | +msgstr " Pago a múltiples proveedores" |
362 | + |
363 | |
364 | === added file 'account_voucher_multi_partner/voucher_multi_partner.py' |
365 | --- account_voucher_multi_partner/voucher_multi_partner.py 1970-01-01 00:00:00 +0000 |
366 | +++ account_voucher_multi_partner/voucher_multi_partner.py 2011-11-28 19:36:47 +0000 |
367 | @@ -0,0 +1,252 @@ |
368 | +#!/usr/bin/python |
369 | +# -*- coding: utf-8 -*- |
370 | +############################################################################## |
371 | +# |
372 | +# OpenERP, Open Source Management Solution |
373 | +# Copyright (C) 2004-20011S Tiny SPRL (<http://tiny.be>). All Rights Reserved |
374 | +# This module was developen by Vauxoo Team: |
375 | +# Coded by: javier@vauxoo.com |
376 | +# |
377 | +# |
378 | +# This program is free software: you can redistribute it and/or modify |
379 | +# it under the terms of the GNU Affero General Public License as |
380 | +# published by the Free Software Foundation, either version 3 of the |
381 | +# License, or (at your option) any later version. |
382 | +# |
383 | +# This program is distributed in the hope that it will be useful, |
384 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
385 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
386 | +# GNU Affero General Public License for more details. |
387 | +# |
388 | +# You should have received a copy of the GNU Affero General Public License |
389 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
390 | +# |
391 | +############################################################################## |
392 | + |
393 | +from osv import osv |
394 | +from osv import fields |
395 | +from tools.translate import _ |
396 | +import time |
397 | +import datetime |
398 | +import decimal_precision as dp |
399 | + |
400 | + |
401 | +class account_voucher_line(osv.osv): |
402 | + _inherit = 'account.voucher.line' |
403 | + name = 'acc.voucher.line.multi.partner' |
404 | + |
405 | + |
406 | + def _amount_residual(self, cr, uid, ids, name, args, context=None): |
407 | + currency_pool = self.pool.get('res.currency') |
408 | + for line in self.browse(cr, uid, ids, context=context): |
409 | + ctx = context.copy() |
410 | + ctx.update({'date': line.voucher_id.date}) |
411 | + res = {} |
412 | + company_currency = line.voucher_id.journal_id.company_id.currency_id.id |
413 | + voucher_currency = line.voucher_id.currency_id.id |
414 | + move_line = line.move_line_id or False |
415 | + |
416 | + if not move_line: |
417 | + res[line.id] = 0.0 |
418 | + |
419 | + if move_line: |
420 | + res[line.id] = currency_pool.compute(cr, uid, move_line.currency_id and move_line.currency_id.id or company_currency, voucher_currency, abs(move_line.amount_residual_currency), context=ctx) - line.amount |
421 | + |
422 | + return res |
423 | + |
424 | + _columns={ |
425 | + 'invoice_id' : fields.many2one('account.invoice','Invoice'), |
426 | + 'partner_id' : fields.many2one('res.partner','Partner'), |
427 | + 'amount_residual': fields.function(_amount_residual, method=True, digits_compute=dp.get_precision('Account'), string='Residual Amount', type='float', store=True), |
428 | + } |
429 | + |
430 | + |
431 | + |
432 | + def onchange_partner_id(self, cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, invoice_id, context=None): |
433 | + currency_pool = self.pool.get('res.currency') |
434 | + move_line_pool = self.pool.get('account.move.line') |
435 | +# partner_pool = self.pool.get('res.partner') |
436 | + journal_pool = self.pool.get('account.journal') |
437 | + invoice_pool = self.pool.get('account.invoice') |
438 | +# partner_brw = partner_pool.browse(cr,uid,partner_id,context=context) |
439 | + journal_brw = journal_pool.browse(cr, uid, journal_id, context=context) |
440 | + default = {} |
441 | + default.setdefault('value',{}) |
442 | + |
443 | + currency_id = currency_id or journal_brw.company_id.currency_id.id |
444 | + |
445 | + if not partner_id: |
446 | + return default |
447 | + |
448 | + default['value']['partner_id'] = partner_id |
449 | + |
450 | + total_credit = 0.0 |
451 | + total_debit = 0.0 |
452 | + account_type = 'receivable' |
453 | + if ttype == 'payment': |
454 | + account_type = 'payable' |
455 | + total_debit = price or 0.0 |
456 | + else: |
457 | + total_credit = price or 0.0 |
458 | + |
459 | + |
460 | + if not invoice_id: |
461 | + return default |
462 | + |
463 | + default['value']['invoice_id'] = invoice_id |
464 | + invoice_brw = invoice_pool.browse(cr, uid, invoice_id, context=context) |
465 | + ids = move_line_pool.search(cr, uid, [('state','=','valid'), ('account_id.type', '=', account_type), ('reconcile_id', '=', False), ('partner_id', '=', partner_id), ('move_id', '=', invoice_brw.move_id.id)], context=context) |
466 | + moves = move_line_pool.browse(cr, uid, ids, context=context) |
467 | + |
468 | + |
469 | + company_currency = journal_brw.company_id.currency_id.id |
470 | + for line in moves: |
471 | + if line.credit and line.reconcile_partial_id and ttype == 'receipt': |
472 | + continue |
473 | + if line.debit and line.reconcile_partial_id and ttype == 'payment': |
474 | + continue |
475 | + |
476 | + if line.currency_id and currency_id==line.currency_id.id: |
477 | + total_credit += line.amount_currency <0 and -line.amount_currency or 0.0 |
478 | + total_debit += line.amount_currency >0 and line.amount_currency or 0.0 |
479 | + else: |
480 | + total_credit += currency_pool.compute(cr, uid, company_currency, currency_id, line.credit or 0.0) |
481 | + total_debit += currency_pool.compute(cr, uid, company_currency, currency_id, line.debit or 0.0) |
482 | + |
483 | + for line in moves: |
484 | + if line.credit and line.reconcile_partial_id and ttype == 'receipt': |
485 | + continue |
486 | + if line.debit and line.reconcile_partial_id and ttype == 'payment': |
487 | + continue |
488 | + |
489 | + if line.currency_id and currency_id==line.currency_id.id: |
490 | + amount_original = abs(line.amount_currency) |
491 | + amount_unreconciled = abs(line.amount_residual_currency) |
492 | + else: |
493 | + amount_original = currency_pool.compute(cr, uid, company_currency, currency_id, line.credit or line.debit or 0.0) |
494 | + amount_unreconciled = currency_pool.compute(cr, uid, company_currency, currency_id, abs(line.amount_residual)) |
495 | + |
496 | + #original_amount = line.credit or line.debit or 0.0 |
497 | + #amount_unreconciled = currency_pool.compute(cr, uid, line.currency_id and line.currency_id.id or company_currency, currency_id, abs(line.amount_residual_currency), context=context_multi_currency) |
498 | + default['value'].update({ |
499 | + 'name':line.move_id.name, |
500 | + 'type': line.credit and 'dr' or 'cr', |
501 | + 'move_line_id':line.id, |
502 | + 'account_id':line.account_id.id, |
503 | + 'amount_original': amount_original, |
504 | + 'date_original':line.date, |
505 | + 'date_due':line.date_maturity, |
506 | + 'amount_unreconciled': amount_unreconciled, |
507 | + |
508 | + }) |
509 | + |
510 | + if line.credit: |
511 | + amount = min(amount_unreconciled, total_debit) |
512 | + default['value']['amount'] = amount |
513 | + total_debit -= amount |
514 | + else: |
515 | + amount = min(amount_unreconciled, total_credit) |
516 | + default['value']['amount'] = amount |
517 | + total_credit -= amount |
518 | + |
519 | +# if ttype == 'payment' and len(default['value']['line_cr_ids']) > 0: |
520 | +# default['value']['pre_line'] = 1 |
521 | +# elif ttype == 'receipt' and len(default['value']['line_dr_ids']) > 0: |
522 | +# default['value']['pre_line'] = 1 |
523 | +# default['value']['writeoff_amount'] = self._compute_writeoff_amount(cr, uid, default['value']['line_dr_ids'], default['value']['line_cr_ids'], price) |
524 | + |
525 | + return default |
526 | + |
527 | + |
528 | +account_voucher_line() |
529 | + |
530 | + |
531 | +class account_voucher(osv.osv): |
532 | + _inherit='account.voucher' |
533 | + name='account.voucher.multi.partner' |
534 | + |
535 | + _columns={ |
536 | + 'multi_partner':fields.boolean('Several Supplier or Customer ?', required=False, help="Check this box if there are twice or more supplier or customer for this voucher"), |
537 | + } |
538 | + |
539 | + |
540 | + |
541 | + def onchange_journal_multi_partner(self, cr, uid, ids, journal_id, context=None): |
542 | + vals = {'value': {}} |
543 | + if not journal_id: |
544 | + return vals |
545 | + journal_pool = self.pool.get('account.journal') |
546 | + journal = journal_pool.browse(cr, uid, journal_id, context=context) |
547 | + |
548 | +# vals = self.onchange_price(cr, uid, ids, line_ids, tax_id, partner_id, context) |
549 | + |
550 | + currency_id = False #journal.company_id.currency_id.id |
551 | + if journal.currency: |
552 | + currency_id = journal.currency.id |
553 | + vals['value'].update({'currency_id':currency_id}) |
554 | + |
555 | + # TODO: Debo averiguar cual es la cuenta del voucher, ¿Asumo siempre la del diario? |
556 | +# account_id = False |
557 | +# if journal.type in ('sale','sale_refund'): |
558 | +# account_id = partner.property_account_receivable.id |
559 | +# elif journal.type in ('purchase', 'purchase_refund','expense'): |
560 | +# account_id = partner.property_account_payable.id |
561 | +# else: |
562 | +# account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id |
563 | + account_id = journal.default_credit_account_id.id or journal.default_debit_account_id.id |
564 | + vals['value']['account_id'] = account_id |
565 | + return vals |
566 | + |
567 | + def onchange_date_multi_partner(self, cr, uid, ids, journal_id, date, context=None): |
568 | + """ |
569 | + @param date: latest value from user input for field date |
570 | + @param args: other arguments |
571 | + @param context: context arguments, like lang, time zone |
572 | + @return: Returns a dict which contains new values, and context |
573 | + """ |
574 | + period_pool = self.pool.get('account.period') |
575 | + res = self.onchange_journal_multi_partner(cr, uid, ids, journal_id, context=context) |
576 | + pids = period_pool.search(cr, uid, [('date_start', '<=', date), ('date_stop', '>=', date)]) |
577 | + if pids: |
578 | + if not 'value' in res: |
579 | + res['value'] = {} |
580 | + res['value'].update({'period_id':pids[0]}) |
581 | + return res |
582 | + |
583 | + def first_move_line_get(self, cr, uid, voucher_id, move_id, company_currency, current_currency, context=None): |
584 | + data = super(account_voucher, self).first_move_line_get(cr, uid, voucher_id, move_id, company_currency, current_currency, context) |
585 | + data.update({'partner_id':False}) |
586 | + return data |
587 | + |
588 | + |
589 | + def voucher_move_line_get_item(self, cr, uid, voucher, line, move_id, company_currency, current_currency): |
590 | + data = super(account_voucher, self).voucher_move_line_get_item(cr, uid, voucher, line, move_id, company_currency, current_currency) |
591 | + data.update({'partner_id':line.partner_id.id}) |
592 | + return data |
593 | + |
594 | + |
595 | + def writeoff_move_line_get(self, cr, uid, voucher_id, line_total, move_id, name, company_currency, current_currency, context=None): |
596 | + voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context) |
597 | + if voucher_brw.multi_partner: |
598 | + #TODO hacer cuenta contable de ajuste en la compañía y evaluar un monto mínimo para realizar el asiento de ajuste |
599 | + return {} |
600 | + return super(account_voucher, self).writeoff_move_line_get(cr, uid, voucher_id, line_total, move_id, name, company_currency, current_currency, context) |
601 | + |
602 | + |
603 | + def check_amount_total(self, cr, uid, ids, context=None): |
604 | + for voucher_brw in self.browse(cr, uid, ids,context): |
605 | + amount = 0.0 |
606 | + for line in voucher_brw.line_ids: |
607 | + amount+= line.amount |
608 | + if amount != voucher_brw.amount and voucher_brw.multi_partner or amount == 0.0: |
609 | + raise osv.except_osv(_('Invalid action !'), _('Cannot validate Voucher(s) with bad total !')) |
610 | + return True |
611 | + |
612 | + def proforma_voucher(self, cr, uid, ids, context=None): |
613 | + self.check_amount_total(cr, uid, ids, context=context) |
614 | + return super(account_voucher, self).proforma_voucher(cr, uid, ids, context) |
615 | + |
616 | +account_voucher() |
617 | + |
618 | + |
619 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
620 | |
621 | === added file 'account_voucher_multi_partner/voucher_multi_partner_view.xml' |
622 | --- account_voucher_multi_partner/voucher_multi_partner_view.xml 1970-01-01 00:00:00 +0000 |
623 | +++ account_voucher_multi_partner/voucher_multi_partner_view.xml 2011-11-28 19:36:47 +0000 |
624 | @@ -0,0 +1,361 @@ |
625 | +<?xml version="1.0"?> |
626 | +<openerp> |
627 | + <data> |
628 | + |
629 | + <record id="view_multi_partner_filter_vendor_pay" model="ir.ui.view"> |
630 | + <field name="name">multi.partner.purchase.pay.select</field> |
631 | + <field name="model">account.voucher</field> |
632 | + <field name="type">search</field> |
633 | + <field name="arch" type="xml"> |
634 | + <search string="Search Vouchers"> |
635 | + <group col='8' colspan='4'> |
636 | + <filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Vouchers"/> |
637 | + <filter icon="terp-camera_test" string="Posted" domain="[('state','=','posted')]" help="Posted Vouchers"/> |
638 | + <separator orientation="vertical"/> |
639 | + <filter icon="terp-gtk-jump-to-ltr" string="To Review" domain="[('state','=','posted')]" groups="base.group_extended" help="To Review"/> |
640 | + <separator orientation="vertical"/> |
641 | + <field name="date"/> |
642 | + <field name="number"/> |
643 | + </group> |
644 | + <newline/> |
645 | + <group col='8' colspan='4'> |
646 | + <field name="journal_id" widget="selection" context="{'journal_id': self, 'set_visible':False}" domain="[('type','in',('bank','cash'))]"/> |
647 | + <field name="period_id" groups="base.group_extended"/> |
648 | + </group> |
649 | + <newline/> |
650 | + <group expand="0" string="Extended Filters..." col='8' colspan='4'> |
651 | + <field name="reference"/> |
652 | + <field name="name"/> |
653 | + <field name="narration"/> |
654 | + <field name="amount"/> |
655 | + </group> |
656 | + <newline/> |
657 | + <group expand="0" string="Group By..." colspan="4" col="10"> |
658 | + <filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/> |
659 | + <filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id','visible':True}"/> |
660 | + <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/> |
661 | + </group> |
662 | + </search> |
663 | + </field> |
664 | + </record> |
665 | + |
666 | + <record model="ir.ui.view" id="view_vendor_multi_partner_payment_form"> |
667 | + <field name="name">multi.partner.payment.form</field> |
668 | + <field name="model">account.voucher</field> |
669 | + <field name="type">form</field> |
670 | + <field name="arch" type="xml"> |
671 | + <form string="Bill Payment"> |
672 | + <group col="6" colspan="4"> |
673 | + <field name="amount"/> |
674 | + <field name="journal_id" |
675 | + domain="[('type','in',['bank', 'cash'])]" |
676 | + widget="selection" select="1" |
677 | + on_change="onchange_journal_multi_partner(journal_id)" |
678 | + string="Payment Method"/> |
679 | + <field name="date" select="1" on_change="onchange_date_multi_partner(journal_id, date)"/> |
680 | + <field name="reference" select="1" string="Payment Ref"/> |
681 | + <field name="name" colspan="2"/> |
682 | + <field name="company_id" select="1" widget="selection" groups="base.group_multi_company"/> |
683 | + <field name="account_id" |
684 | + widget="selection" |
685 | + invisible="False"/> |
686 | + <field name="pre_line" invisible="1"/> |
687 | + <field name="type" invisible="True"/> |
688 | + <field name="multi_partner" invisible="True"/> |
689 | + </group> |
690 | + <notebook colspan="4"> |
691 | + <page string="Payment Information"> |
692 | + <field name="line_dr_ids" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140"> |
693 | + <tree string="Supplier Invoices and Outstanding transactions" editable="bottom"> |
694 | + <field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':partner_id}" |
695 | + on_change="onchange_move_line_id(move_line_id)" |
696 | + domain="[('account_id.type','=','payable'), ('reconcile_id','=', False), ('partner_id','=',partner_id)]" |
697 | + /> |
698 | + <field name="partner_id" domain="[('supplier','=',True)]" required="1" on_change="onchange_partner_id(partner_id, parent.journal_id, parent.amount, parent.currency_id, parent.type, invoice_id, context)" string="Supplier"/> |
699 | + <field name="invoice_id" widget='many2one' domain="[('partner_id','=',partner_id)]" on_change="onchange_partner_id(partner_id, parent.journal_id, parent.amount, parent.currency_id, parent.type, invoice_id, context)"/> |
700 | + <field name="account_id" groups="base.group_no_one" domain="[('type','=','payable')]"/> |
701 | + <field name="date_original" readonly="1"/> |
702 | + <field name="date_due" readonly="1"/> |
703 | + <field name="amount_original" readonly="1"/> |
704 | + <field name="amount_unreconciled" sum="Open Balance" readonly="1"/> |
705 | + <field name="amount" sum="Payment"/> |
706 | + <field name="amount_residual" sum="Residual"/> |
707 | + </tree> |
708 | + </field> |
709 | + <field name="line_cr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('pre_line','=',False)]}" default_get="{'journal_id':journal_id, 'partner_id':partner_id}"> |
710 | + <tree string="Credits" editable="bottom"> |
711 | + <field name="move_line_id"/> |
712 | + <field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]"/> |
713 | + <field name="date_original"/> |
714 | + <field name="amount_original"/> |
715 | + <field name="amount" sum="Payment"/> |
716 | + </tree> |
717 | + </field> |
718 | + <group col="2" colspan="3"> |
719 | + <separator string="Internal Notes" colspan="2"/> |
720 | + <field name="narration" colspan="2" nolabel="1"/> |
721 | + </group> |
722 | + <group col="2" colspan="1"> |
723 | + <group col="2" colspan="1"> |
724 | + <field name="analytic_id" |
725 | + groups="analytic.group_analytic_accounting"/> |
726 | + <separator string="Payment Options" colspan="2"/> |
727 | + <field name="payment_option" required="1"/> |
728 | + <field name="writeoff_amount" |
729 | + attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/> |
730 | + <field name="writeoff_acc_id" |
731 | + attrs="{'invisible':[('payment_option','!=','with_writeoff')], 'required':[('payment_option','=','with_writeoff')]}" |
732 | + domain="[('type','=','other')]"/> |
733 | + <field name="comment" |
734 | + attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/> |
735 | + |
736 | + </group> |
737 | + <separator string="Other Information" colspan="2"/> |
738 | + <group col="4" colspan="1"> |
739 | + <field name="currency_id" invisible="True"/> |
740 | + <field name="number"/> |
741 | + </group> |
742 | + </group> |
743 | + </page> |
744 | + <page string="Journal Items" groups="base.group_extended" attrs="{'invisible': [('state','!=','posted')]}"> |
745 | + <group col="6" colspan="4"> |
746 | + <field name="period_id"/> |
747 | + <field name="audit"/> |
748 | + </group> |
749 | + <field name="move_ids" colspan="4" nolabel="1" readonly="1"> |
750 | + <tree string="Journal Items"> |
751 | + <field name="move_id"/> |
752 | + <field name="ref"/> |
753 | + <field name="date"/> |
754 | + <field name="statement_id"/> |
755 | + <field name="partner_id"/> |
756 | + <field name="account_id"/> |
757 | + <field name="name"/> |
758 | + <field name="debit"/> |
759 | + <field name="credit"/> |
760 | + <field name="state"/> |
761 | + <field name="reconcile_id"/> |
762 | + <field name="amount_currency"/> |
763 | + <field name="currency_id"/> |
764 | + </tree> |
765 | + </field> |
766 | + </page> |
767 | + </notebook> |
768 | + <group col="10" colspan="4"> |
769 | + <field name="state"/> |
770 | + <button name="cancel_voucher" string="Cancel" states="draft,proforma" icon="gtk-cancel"/> |
771 | + <button name="cancel_voucher" string="Unreconcile" type="object" states="posted" icon="terp-stock_effects-object-colorize" confirm="Are you sure to unreconcile this record ?"/> |
772 | + <button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize"/> |
773 | + <button name="proforma_voucher" string="Validate" states="draft" icon="gtk-go-forward"/> |
774 | + </group> |
775 | + </form> |
776 | + </field> |
777 | + </record> |
778 | + |
779 | + |
780 | + <record id="action_vendor_multi_partner_payment" model="ir.actions.act_window"> |
781 | + <field name="name">Several Supplier Payment</field> |
782 | + <field name="res_model">account.voucher</field> |
783 | + <field name="view_type">form</field> |
784 | + <field name="domain">[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','payment'), ('multi_partner','=',True)]</field> |
785 | + <field name="context">{'type':'payment','multi_partner':True}</field> |
786 | + <field name="view_id" eval="False"/> |
787 | + <field name="search_view_id" ref="view_multi_partner_filter_vendor_pay"/> |
788 | + <field name="target">current</field> |
789 | + <field name="help">The supplier payment form allows you to track the payment you do to your suppliers. When you select a supplier, the payment method and an amount for the payment, OpenERP will propose to reconcile your payment with the open supplier invoices or bills.</field> |
790 | + </record> |
791 | + <record id="action_vendor_multi_partner_payment_tree" model="ir.actions.act_window.view"> |
792 | + <field eval="1" name="sequence"/> |
793 | + <field name="view_mode">tree</field> |
794 | + <field name="act_window_id" ref="action_vendor_multi_partner_payment"/> |
795 | + </record> |
796 | + <record id="action_vendor_multi_partner_payment_form" model="ir.actions.act_window.view"> |
797 | + <field eval="2" name="sequence"/> |
798 | + <field name="view_mode">form</field> |
799 | + <field name="view_id" ref="view_vendor_multi_partner_payment_form"/> |
800 | + <field name="act_window_id" ref="action_vendor_multi_partner_payment"/> |
801 | + </record> |
802 | + |
803 | + <menuitem action="action_vendor_multi_partner_payment" id="menu_action_vendor_multi_partner_payment" icon="STOCK_JUSTIFY_FILL" |
804 | + sequence="12" parent="account.menu_finance_payables"/> |
805 | + |
806 | + |
807 | + |
808 | + |
809 | + <record id="view_multi_partner_filter_customer_pay" model="ir.ui.view"> |
810 | + <field name="name">multi.partner.customer.pay.select</field> |
811 | + <field name="model">account.voucher</field> |
812 | + <field name="type">search</field> |
813 | + <field name="arch" type="xml"> |
814 | + <search string="Search Vouchers"> |
815 | + <group col='8' colspan='4'> |
816 | + <filter icon="terp-document-new" string="Draft" domain="[('state','=','draft')]" help="Draft Vouchers"/> |
817 | + <filter icon="terp-camera_test" string="Posted" domain="[('state','=','posted')]" help="Posted Vouchers"/> |
818 | + <separator orientation="vertical"/> |
819 | + <filter icon="terp-gtk-jump-to-ltr" string="To Review" domain="[('state','=','posted')]" groups="base.group_extended" help="To Review"/> |
820 | + <separator orientation="vertical"/> |
821 | + <field name="date"/> |
822 | + <field name="number"/> |
823 | + </group> |
824 | + <newline/> |
825 | + <group col='8' colspan='4'> |
826 | + <field name="journal_id" widget="selection" context="{'journal_id': self, 'set_visible':False}" domain="[('type','in',('bank','cash'))]"/> |
827 | + <field name="period_id" groups="base.group_extended"/> |
828 | + </group> |
829 | + <newline/> |
830 | + <group expand="0" string="Extended Filters..." col='8' colspan='4'> |
831 | + <field name="reference"/> |
832 | + <field name="name"/> |
833 | + <field name="narration"/> |
834 | + <field name="amount"/> |
835 | + </group> |
836 | + <newline/> |
837 | + <group expand="0" string="Group By..." colspan="4" col="10"> |
838 | + <filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/> |
839 | + <filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id','visible':True}"/> |
840 | + <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/> |
841 | + </group> |
842 | + </search> |
843 | + </field> |
844 | + </record> |
845 | + |
846 | + <record model="ir.ui.view" id="view_vendor_multi_partner_receipt_form"> |
847 | + <field name="name">multi.partner.receipt.form</field> |
848 | + <field name="model">account.voucher</field> |
849 | + <field name="type">form</field> |
850 | + <field name="arch" type="xml"> |
851 | + <form string="Customer Payment"> |
852 | + <group col="6" colspan="4"> |
853 | + <field name="journal_id" on_change= "onchange_journal_multi_partner(journal_id)" |
854 | + domain="[('type','in',['bank', 'cash'])]" |
855 | + widget="selection" select="1" |
856 | + string="Payment Method"/> |
857 | + <field name="amount" |
858 | + string="Paid Amount"/> |
859 | + <field name="date" select="1"/> |
860 | + <field name="reference" select="1" string="Payment Ref"/> |
861 | + <field name="name" colspan="2"/> |
862 | + <field name="company_id" select="1" widget="selection" groups="base.group_multi_company"/> |
863 | + <field name="account_id" |
864 | + widget="selection"/> |
865 | + <field name="pre_line" invisible="1"/> |
866 | + <field name="type" invisible="False"/> |
867 | + <field name="multi_partner" invisible="True"/> |
868 | + </group> |
869 | + <notebook colspan="4"> |
870 | + <page string="Payment Information"> |
871 | + <field name="line_cr_ids" default_get="{'journal_id':journal_id, 'type':type, 'partner_id':partner_id}" colspan="4" nolabel="1" height="140" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount)"> |
872 | + <tree string="Invoices and outstanding transactions" editable="bottom"> |
873 | + <field name="move_line_id" context="{'journal_id':parent.journal_id, 'partner_id':parent.partner_id}" |
874 | + on_change="onchange_move_line_id(move_line_id)" |
875 | + domain="[('account_id.type','in',('receivable','payable')), ('reconcile_id','=', False), ('partner_id','=',parent.partner_id)]" |
876 | + required="1" |
877 | + /> |
878 | + <field name="partner_id" domain="[('customer','=',True)]" required="1" on_change="onchange_partner_id(partner_id, parent.journal_id, parent.amount, parent.currency_id, parent.type, invoice_id, context)"/> |
879 | + <field name="invoice_id" widget='many2one' domain="[('partner_id','=',partner_id)]" on_change="onchange_partner_id(partner_id, parent.journal_id, parent.amount, parent.currency_id, parent.type, invoice_id, context)"/> |
880 | + <field name="account_id" groups="base.group_no_one" domain="[('type','=','receivable')]"/> |
881 | + <field name="date_original" readonly="1"/> |
882 | + <field name="date_due" readonly="1"/> |
883 | + <field name="amount_original" readonly="1"/> |
884 | + <field name="amount_unreconciled" sum="Open Balance" readonly="1"/> |
885 | + <field name="amount" sum="Payment"/> |
886 | + </tree> |
887 | + </field> |
888 | + <field name="line_dr_ids" colspan="4" nolabel="1" attrs="{'invisible': [('pre_line','=',False)]}" default_get="{'journal_id':journal_id}" on_change="onchange_line_ids(line_dr_ids, line_cr_ids, amount)"> |
889 | + <tree string="Credits" editable="bottom"> |
890 | + <field name="move_line_id"/> |
891 | + <field name="account_id" groups="base.group_extended" domain="[('type','=','receivable')]"/> |
892 | + <field name="date_original"/> |
893 | + <field name="amount_original"/> |
894 | + <field name="amount" sum="Payment"/> |
895 | + </tree> |
896 | + </field> |
897 | + <group col="2" colspan="3"> |
898 | + <separator string="Internal Notes" colspan="2"/> |
899 | + <field name="narration" colspan="2" nolabel="1"/> |
900 | + </group> |
901 | + <group col="2" colspan="1"> |
902 | + <group col="2" colspan="1"> |
903 | + <separator string="Payment Options" colspan="2"/> |
904 | + <field name="analytic_id" |
905 | + groups="analytic.group_analytic_accounting"/> |
906 | + <field name="payment_option" required="1"/> |
907 | + <field name="writeoff_amount" |
908 | + attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/> |
909 | + <field name="writeoff_acc_id" |
910 | + attrs="{'invisible':[('payment_option','!=','with_writeoff')], 'required':[('payment_option','=','with_writeoff')]}" |
911 | + domain="[('type','=','other')]"/> |
912 | + <field name="comment" |
913 | + attrs="{'invisible':[('payment_option','!=','with_writeoff')]}"/> |
914 | + </group> |
915 | + <separator string="Other Information" colspan="2"/> |
916 | + <group col="4" colspan="1"> |
917 | + <field name="currency_id" invisible="True"/> |
918 | + <field name="number"/> |
919 | + </group> |
920 | + </group> |
921 | + </page> |
922 | + <page string="Journal Items" groups="base.group_extended" attrs="{'invisible': [('state','!=','posted')]}"> |
923 | + <group col="6" colspan="4"> |
924 | + <field name="period_id"/> |
925 | + <field name="audit"/> |
926 | + </group> |
927 | + <field name="move_ids" colspan="4" nolabel="1" readonly="1"> |
928 | + <tree string="Journal Items"> |
929 | + <field name="move_id"/> |
930 | + <field name="ref"/> |
931 | + <field name="date"/> |
932 | + <field name="statement_id"/> |
933 | + <field name="account_id"/> |
934 | + <field name="name"/> |
935 | + <field name="debit"/> |
936 | + <field name="credit"/> |
937 | + <field name="state"/> |
938 | + <field name="reconcile_id"/> |
939 | + <field name="amount_currency"/> |
940 | + <field name="currency_id"/> |
941 | + </tree> |
942 | + </field> |
943 | + </page> |
944 | + </notebook> |
945 | + <group col="10" colspan="4"> |
946 | + <field name="state"/> |
947 | + <button name="cancel_voucher" string="Cancel" states="draft,proforma" icon="gtk-cancel"/> |
948 | + <button name="cancel_voucher" string="Unreconcile" type="object" states="posted" icon="terp-stock_effects-object-colorize" confirm="Are you sure to unreconcile this record ?"/> |
949 | + <button name="action_cancel_draft" type="object" states="cancel" string="Set to Draft" icon="terp-stock_effects-object-colorize"/> |
950 | + <button name="proforma_voucher" string="Validate" states="draft" icon="gtk-go-forward"/> |
951 | + </group> |
952 | + </form> |
953 | + </field> |
954 | + </record> |
955 | + |
956 | + <record id="action_vendor_multi_partner_receipt" model="ir.actions.act_window"> |
957 | + <field name="name">Several Customer Payment</field> |
958 | + <field name="res_model">account.voucher</field> |
959 | + <field name="view_type">form</field> |
960 | + <field name="domain">[('journal_id.type', 'in', ['bank', 'cash']), ('type','=','receipt'), ('multi_partner','=',True)]</field> |
961 | + <field name="context">{'type':'receipt','multi_partner':True}</field> |
962 | + <field name="search_view_id" ref="view_multi_partner_filter_customer_pay"/> |
963 | + <field name="view_id" eval="False"/> |
964 | + <field name="target">current</field> |
965 | + <field name="help">Sales payment allows you to register the payments you receive from your customers. In order to record a payment, you must enter the customer, the payment method (=the journal) and the payment amount. OpenERP will propose to you automatically the reconciliation of this payment with the open invoices or sales receipts.</field> |
966 | + </record> |
967 | + <record id="action_vendor_multi_partner_receipt_tree" model="ir.actions.act_window.view"> |
968 | + <field eval="1" name="sequence"/> |
969 | + <field name="view_mode">tree</field> |
970 | + <field name="act_window_id" ref="action_vendor_multi_partner_receipt"/> |
971 | + </record> |
972 | + <record id="action_vendor_multi_partner_receipt_form" model="ir.actions.act_window.view"> |
973 | + <field eval="2" name="sequence"/> |
974 | + <field name="view_mode">form</field> |
975 | + <field name="view_id" ref="view_vendor_multi_partner_receipt_form"/> |
976 | + <field name="act_window_id" ref="action_vendor_multi_partner_receipt"/> |
977 | + </record> |
978 | + |
979 | + <menuitem action="action_vendor_multi_partner_receipt" icon="STOCK_JUSTIFY_FILL" sequence="12" |
980 | + id="menu_action_vendor_multi_partner_receipt" parent="account.menu_finance_receivables"/> |
981 | + |
982 | + |
983 | + |
984 | + </data> |
985 | +</openerp> |
986 | |
987 | === added directory 'account_voucher_patch' |
988 | === added file 'account_voucher_patch/__init__.py' |
989 | --- account_voucher_patch/__init__.py 1970-01-01 00:00:00 +0000 |
990 | +++ account_voucher_patch/__init__.py 2011-11-28 19:36:47 +0000 |
991 | @@ -0,0 +1,24 @@ |
992 | +# -*- coding: utf-8 -*- |
993 | +############################################################################## |
994 | +# |
995 | +# OpenERP, Open Source Management Solution |
996 | +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). |
997 | +# |
998 | +# This program is free software: you can redistribute it and/or modify |
999 | +# it under the terms of the GNU Affero General Public License as |
1000 | +# published by the Free Software Foundation, either version 3 of the |
1001 | +# License, or (at your option) any later version. |
1002 | +# |
1003 | +# This program is distributed in the hope that it will be useful, |
1004 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1005 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1006 | +# GNU Affero General Public License for more details. |
1007 | +# |
1008 | +# You should have received a copy of the GNU Affero General Public License |
1009 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1010 | +# |
1011 | +############################################################################## |
1012 | + |
1013 | +import account_voucher |
1014 | + |
1015 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
1016 | |
1017 | === added file 'account_voucher_patch/__openerp__.py' |
1018 | --- account_voucher_patch/__openerp__.py 1970-01-01 00:00:00 +0000 |
1019 | +++ account_voucher_patch/__openerp__.py 2011-11-28 19:36:47 +0000 |
1020 | @@ -0,0 +1,47 @@ |
1021 | +# -*- coding: utf-8 -*- |
1022 | +############################################################################## |
1023 | +# |
1024 | +# OpenERP, Open Source Management Solution |
1025 | +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). |
1026 | +# |
1027 | +# This program is free software: you can redistribute it and/or modify |
1028 | +# it under the terms of the GNU Affero General Public License as |
1029 | +# published by the Free Software Foundation, either version 3 of the |
1030 | +# License, or (at your option) any later version. |
1031 | +# |
1032 | +# This program is distributed in the hope that it will be useful, |
1033 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1034 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1035 | +# GNU Affero General Public License for more details. |
1036 | +# |
1037 | +# You should have received a copy of the GNU Affero General Public License |
1038 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1039 | +# |
1040 | +############################################################################## |
1041 | + |
1042 | +{ |
1043 | + "name" : "Accounting Voucher Entries", |
1044 | + "version" : "1.0", |
1045 | + "author" : 'OpenERP SA', |
1046 | + "description": """Account Voucher module includes all the basic requirements of |
1047 | + Voucher Entries for Bank, Cash, Sales, Purchase, Expanse, Contra, etc... |
1048 | + * Voucher Entry |
1049 | + * Voucher Receipt |
1050 | + * Cheque Register |
1051 | + """, |
1052 | + "category" : "Generic Modules/Accounting", |
1053 | + "website" : "http://tinyerp.com", |
1054 | + "depends" : ["account"], |
1055 | + "init_xml" : [], |
1056 | + |
1057 | + "demo_xml" : [], |
1058 | + |
1059 | + "update_xml" : [ |
1060 | + ], |
1061 | + "test" : [ |
1062 | + ], |
1063 | + "active": False, |
1064 | + "installable": True, |
1065 | +} |
1066 | + |
1067 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
1068 | |
1069 | === added file 'account_voucher_patch/account_voucher.py' |
1070 | --- account_voucher_patch/account_voucher.py 1970-01-01 00:00:00 +0000 |
1071 | +++ account_voucher_patch/account_voucher.py 2011-11-28 19:36:47 +0000 |
1072 | @@ -0,0 +1,338 @@ |
1073 | +# -*- coding: utf-8 -*- |
1074 | +############################################################################## |
1075 | +# |
1076 | +# OpenERP, Open Source Management Solution |
1077 | +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). |
1078 | +# |
1079 | +# This program is free software: you can redistribute it and/or modify |
1080 | +# it under the terms of the GNU Affero General Public License as |
1081 | +# published by the Free Software Foundation, either version 3 of the |
1082 | +# License, or (at your option) any later version. |
1083 | +# |
1084 | +# This program is distributed in the hope that it will be useful, |
1085 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1086 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1087 | +# GNU Affero General Public License for more details. |
1088 | +# |
1089 | +# You should have received a copy of the GNU Affero General Public License |
1090 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1091 | +# |
1092 | +############################################################################## |
1093 | + |
1094 | +import time |
1095 | +from lxml import etree |
1096 | + |
1097 | +import netsvc |
1098 | +from osv import osv, fields |
1099 | +import decimal_precision as dp |
1100 | +from tools.translate import _ |
1101 | + |
1102 | + |
1103 | +class account_voucher(osv.osv): |
1104 | + _inherit='account.voucher' |
1105 | + |
1106 | + |
1107 | + |
1108 | + def _get_company_currency(self, cr, uid, voucher_id, context=None): |
1109 | + ''' |
1110 | + Get the currency of the actual company. |
1111 | + |
1112 | + :param voucher_id: Id of the voucher what i want to obtain company currency. |
1113 | + :return: currency id of the company of the voucher |
1114 | + :rtype: int |
1115 | + ''' |
1116 | + return self.pool.get('account.voucher').browse(cr,uid,voucher_id,context).journal_id.company_id.currency_id.id |
1117 | + |
1118 | + def _get_current_currency(self, cr, uid, voucher_id, context=None): |
1119 | + ''' |
1120 | + Get the currency of the voucher. |
1121 | + |
1122 | + :param voucher_id: Id of the voucher what i want to obtain current currency. |
1123 | + :return: currency id of the voucher |
1124 | + :rtype: int |
1125 | + ''' |
1126 | + voucher = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context) |
1127 | + return voucher.currency_id.id or self._get_company_currency(cr,uid,voucher.id,context) |
1128 | + |
1129 | + |
1130 | + def _sel_context(self, cr, uid, voucher_id,context=None): |
1131 | + """ |
1132 | + Select the context to use accordingly if it needs to be multicurrency or not. |
1133 | + |
1134 | + :param voucher_id: Id of the actual voucher |
1135 | + :return: The returned context will be the same as given in parameter if the voucher currency is the same |
1136 | + than the company currency, otherwise it's a copy of the parameter with an extra key 'date' containing |
1137 | + the date of the voucher. |
1138 | + :rtype: dict |
1139 | + """ |
1140 | + company_currency = self._get_company_currency(cr, uid, voucher_id, context) |
1141 | + current_currency = self._get_current_currency(cr, uid, voucher_id, context) |
1142 | + if current_currency <> company_currency: |
1143 | + context_multi_currency = context.copy() |
1144 | + voucher_brw = self.pool.get('account.voucher').browse(cr, uid, voucher_id, context) |
1145 | + context_multi_currency.update({'date': voucher_brw.date}) |
1146 | + return context_multi_currency |
1147 | + return context |
1148 | + |
1149 | + |
1150 | + def account_move_get(self, cr, uid, voucher_id, context=None): |
1151 | + ''' |
1152 | + This method prepare the creation of the account move related to the given voucher. |
1153 | + |
1154 | + :param voucher_id: Id of voucher for which we are creating account_move. |
1155 | + :return: mapping between fieldname and value of account move to create |
1156 | + :rtype: dict |
1157 | + ''' |
1158 | + move_obj = self.pool.get('account.move') |
1159 | + seq_obj = self.pool.get('ir.sequence') |
1160 | + voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context) |
1161 | + if voucher_brw.number: |
1162 | + name = voucher_brw.number |
1163 | + elif voucher_brw.journal_id.sequence_id: |
1164 | + name = seq_obj.get_id(cr, uid, voucher_brw.journal_id.sequence_id.id) |
1165 | + else: |
1166 | + raise osv.except_osv(_('Error !'), _('Please define a sequence on the journal !')) |
1167 | + if not voucher_brw.reference: |
1168 | + ref = name.replace('/','') |
1169 | + else: |
1170 | + ref = voucher_brw.reference |
1171 | + |
1172 | + move = { |
1173 | + 'name': name, |
1174 | + 'journal_id': voucher_brw.journal_id.id, |
1175 | + 'narration': voucher_brw.narration, |
1176 | + 'date': voucher_brw.date, |
1177 | + 'ref': ref, |
1178 | + 'period_id': voucher_brw.period_id and voucher_brw.period_id.id or False |
1179 | + } |
1180 | + move_id = move_obj.create(cr, uid, move) |
1181 | + return move |
1182 | + |
1183 | + |
1184 | + def first_move_line_get(self, cr, uid, voucher_id, move_id, company_currency, current_currency, context=None): |
1185 | + ''' |
1186 | + Return a dict to be use to create the first account move line of given voucher. |
1187 | + |
1188 | + :param voucher_id: Id of voucher what we are creating account_move. |
1189 | + :param move_id: Id of account move where this line will be added. |
1190 | + :param company_currency: id of currency of the company to which the voucher belong |
1191 | + :param current_currency: id of currency of the voucher |
1192 | + :return: mapping between fieldname and value of account move line to create |
1193 | + :rtype: dict |
1194 | + ''' |
1195 | + move_line_obj = self.pool.get('account.move.line') |
1196 | + currency_obj = self.pool.get('res.currency') |
1197 | + voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context) |
1198 | + debit = credit = 0.0 |
1199 | + # TODO: is there any other alternative then the voucher type ?? |
1200 | + # -for sale, purchase we have but for the payment and receipt we do not have as based on the bank/cash journal we can not know its payment or receipt |
1201 | + if voucher_brw.type in ('purchase', 'payment'): |
1202 | + credit = currency_obj.compute(cr, uid, current_currency, company_currency, voucher_brw.amount, context=context) |
1203 | + elif voucher_brw.type in ('sale', 'receipt'): |
1204 | + debit = currency_obj.compute(cr, uid, current_currency, company_currency, voucher_brw.amount, context=context) |
1205 | + if debit < 0: |
1206 | + credit = -debit |
1207 | + debit = 0.0 |
1208 | + if credit < 0: |
1209 | + debit = -credit |
1210 | + credit = 0.0 |
1211 | + sign = debit - credit < 0 and -1 or 1 |
1212 | + #set the first line of the voucher |
1213 | + move_line = { |
1214 | + 'name': voucher_brw.name or '/', |
1215 | + 'debit': debit, |
1216 | + 'credit': credit, |
1217 | + 'account_id': voucher_brw.account_id.id, |
1218 | + 'move_id': move_id, |
1219 | + 'journal_id': voucher_brw.journal_id.id, |
1220 | + 'period_id': voucher_brw.period_id.id, |
1221 | + 'partner_id': voucher_brw.partner_id.id, |
1222 | + 'currency_id': company_currency <> current_currency and current_currency or False, |
1223 | + 'amount_currency': company_currency <> current_currency and sign * voucher_brw.amount or 0.0, |
1224 | + 'date': voucher_brw.date, |
1225 | + 'date_maturity': voucher_brw.date_due |
1226 | + } |
1227 | + return move_line |
1228 | + |
1229 | + |
1230 | + def voucher_move_line_get_item(self, cr, uid, voucher, line, move_id, company_currency, current_currency): |
1231 | + return { |
1232 | + 'journal_id': voucher.journal_id.id, |
1233 | + 'period_id': voucher.period_id.id, |
1234 | + 'name': line.name and line.name or '/', |
1235 | + 'account_id': line.account_id.id, |
1236 | + 'move_id': move_id, |
1237 | + 'partner_id': voucher.partner_id.id, |
1238 | + 'currency_id': company_currency <> current_currency and current_currency or False, |
1239 | + 'analytic_account_id': line.account_analytic_id and line.account_analytic_id.id or False, |
1240 | + 'quantity': 1, |
1241 | + 'credit': 0.0, |
1242 | + 'debit': 0.0, |
1243 | + 'date': voucher.date |
1244 | + } |
1245 | + |
1246 | + |
1247 | + def voucher_move_line_create(self, cr, uid, voucher_id, line_total, move_id, company_currency, current_currency, context=None): |
1248 | + ''' |
1249 | + Create one account move line, on the given account move, per voucher line where amount is not 0.0. |
1250 | + It returns Tuple with tot_line what is total of difference between debit and credit and |
1251 | + a list of lists with ids to be reconciled with this format (total_deb_cred,list_of_lists). |
1252 | + |
1253 | + :param voucher_id: Voucher id what we are working with |
1254 | + :param line_total: Amount of the first line, which correspond to the amount we should totally split among all voucher lines. |
1255 | + :param move_id: Account move wher those lines will be joined. |
1256 | + :param company_currency: id of currency of the company to which the voucher belong |
1257 | + :param current_currency: id of currency of the voucher |
1258 | + :return: Tuple build as (remaining amount not allocated on voucher lines, list of account_move_line created in this method) |
1259 | + :rtype: tuple(int, list of int) |
1260 | + ''' |
1261 | + move_line_obj = self.pool.get('account.move.line') |
1262 | + currency_obj = self.pool.get('res.currency') |
1263 | + tot_line = line_total |
1264 | + rec_lst_ids = [] |
1265 | + |
1266 | + if context is None: |
1267 | + context = {} |
1268 | + |
1269 | + voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context) |
1270 | + for line in voucher_brw.line_ids: |
1271 | + #create one move line per voucher line where amount is not 0.0 |
1272 | + if not line.amount: |
1273 | + continue |
1274 | + #we check if the voucher line is fully paid or not and create a move line to balance the payment and initial invoice if needed |
1275 | + if line.amount == line.amount_unreconciled: |
1276 | + amount = line.move_line_id.amount_residual #residual amount in company currency |
1277 | + else: |
1278 | + amount = currency_obj.compute(cr, uid, current_currency, company_currency, line.untax_amount or line.amount, context=context) |
1279 | + move_line = self.voucher_move_line_get_item(cr, uid, voucher_brw, line, move_id, company_currency, current_currency) |
1280 | + if amount < 0: |
1281 | + amount = -amount |
1282 | + if line.type == 'dr': |
1283 | + line.type = 'cr' |
1284 | + else: |
1285 | + line.type = 'dr' |
1286 | + |
1287 | + if (line.type=='dr'): |
1288 | + tot_line += amount |
1289 | + move_line['debit'] = amount |
1290 | + else: |
1291 | + tot_line -= amount |
1292 | + move_line['credit'] = amount |
1293 | + |
1294 | + if voucher_brw.tax_id and voucher_brw.type in ('sale', 'purchase'): |
1295 | + move_line.update({ |
1296 | + 'account_tax_id': voucher_brw.tax_id.id, |
1297 | + }) |
1298 | + if move_line.get('account_tax_id', False): |
1299 | + tax_data = tax_obj.browse(cr, uid, [move_line['account_tax_id']], context=context)[0] |
1300 | + if not (tax_data.base_code_id and tax_data.tax_code_id): |
1301 | + raise osv.except_osv(_('No Account Base Code and Account Tax Code!'),_("You have to configure account base code and account tax code on the '%s' tax!") % (tax_data.name)) |
1302 | + sign = (move_line['debit'] - move_line['credit']) < 0 and -1 or 1 |
1303 | + move_line['amount_currency'] = company_currency <> current_currency and sign * line.amount or 0.0 |
1304 | + voucher_line = move_line_obj.create(cr, uid, move_line) |
1305 | + if line.move_line_id.id: |
1306 | + rec_ids = [voucher_line, line.move_line_id.id] |
1307 | + rec_lst_ids.append(rec_ids) |
1308 | + |
1309 | + return (tot_line, rec_lst_ids) |
1310 | + |
1311 | + def writeoff_move_line_get(self, cr, uid, voucher_id, line_total, move_id, name, company_currency, current_currency, context=None): |
1312 | + ''' |
1313 | + Set a dict to be use to create the writeoff move line. |
1314 | + |
1315 | + :param voucher_id: Id of voucher what we are creating account_move. |
1316 | + :param line_total: Amount remaining to be allocated on lines. |
1317 | + :param move_id: Id of account move where this line will be added. |
1318 | + :param name: Description of account move line. |
1319 | + :param company_currency: id of currency of the company to which the voucher belong |
1320 | + :param current_currency: id of currency of the voucher |
1321 | + :return: mapping between fieldname and value of account move line to create |
1322 | + :rtype: dict |
1323 | + ''' |
1324 | + move_line_obj = self.pool.get('account.move.line') |
1325 | + currency_obj = self.pool.get('res.currency') |
1326 | + move_line = {} |
1327 | + |
1328 | + voucher_brw = self.pool.get('account.voucher').browse(cr,uid,voucher_id,context) |
1329 | + inv_currency_id = voucher_brw.currency_id or voucher_brw.journal_id.currency or voucher_brw.journal_id.company_id.currency_id |
1330 | + |
1331 | + if not currency_obj.is_zero(cr, uid, inv_currency_id, line_total): |
1332 | + diff = line_total |
1333 | + account_id = False |
1334 | + if voucher_brw.payment_option == 'with_writeoff': |
1335 | + account_id = voucher_brw.writeoff_acc_id.id |
1336 | + elif voucher_brw.type in ('sale', 'receipt'): |
1337 | + account_id = voucher_brw.partner_id.property_account_receivable.id |
1338 | + else: |
1339 | + account_id = voucher_brw.partner_id.property_account_payable.id |
1340 | + move_line = { |
1341 | + 'name': name, |
1342 | + 'account_id': account_id, |
1343 | + 'move_id': move_id, |
1344 | + 'partner_id': voucher_brw.partner_id.id, |
1345 | + 'date': voucher_brw.date, |
1346 | + 'credit': diff > 0 and diff or 0.0, |
1347 | + 'debit': diff < 0 and -diff or 0.0, |
1348 | + #'amount_currency': company_currency <> current_currency and currency_obj.compute(cr, uid, company_currency, current_currency, diff * -1, context=context) or 0.0, |
1349 | + #'currency_id': company_currency <> current_currency and current_currency or False, |
1350 | + } |
1351 | + |
1352 | + return move_line |
1353 | + |
1354 | + |
1355 | + def action_move_line_create(self, cr, uid, ids, context=None): |
1356 | + ''' |
1357 | + Confirm the vouchers given in ids and create the journal entries for each of them |
1358 | + ''' |
1359 | + if context is None: |
1360 | + context = {} |
1361 | + move_pool = self.pool.get('account.move') |
1362 | + move_line_pool = self.pool.get('account.move.line') |
1363 | + currency_pool = self.pool.get('res.currency') |
1364 | + tax_obj = self.pool.get('account.tax') |
1365 | + |
1366 | + for voucher in self.browse(cr, uid, ids, context=context): |
1367 | + if voucher.move_id: |
1368 | + continue |
1369 | + company_currency = self._get_company_currency(cr, uid, voucher.id, context) |
1370 | + current_currency = self._get_current_currency(cr, uid, voucher.id, context) |
1371 | + context = self._sel_context(cr, uid, voucher.id, context) |
1372 | + #Create the account move record. |
1373 | + move_id = move_pool.create(cr, uid, self.account_move_get(cr, uid, voucher.id, context=context), context=context) |
1374 | + # Get the name of the account_move just created |
1375 | + name = move_pool.browse(cr, uid, move_id, context=context).name |
1376 | + #create the first line manually |
1377 | + move_line_id = move_line_pool.create(cr, uid, self.first_move_line_get(cr,uid,voucher.id, move_id, company_currency, current_currency, context), context) |
1378 | + mov_line_brw = move_line_pool.browse(cr, uid, move_line_id, context=context) |
1379 | + rec_list_ids = [] |
1380 | + line_total = mov_line_brw.debit - mov_line_brw.credit |
1381 | + if voucher.type == 'sale': |
1382 | + line_total = line_total - currency_pool.compute(cr, uid, voucher.currency_id.id, company_currency, voucher.tax_amount, context=context) |
1383 | + elif voucher.type == 'purchase': |
1384 | + line_total = line_total + currency_pool.compute(cr, uid, voucher.currency_id.id, company_currency, voucher.tax_amount, context=context) |
1385 | + |
1386 | + #create one move line per voucher line where amount is not 0.0 |
1387 | + line_total, rec_list_ids = self.voucher_move_line_create(cr, uid, voucher.id, line_total, move_id, company_currency, current_currency, context) |
1388 | + #create the writeoff line if needed |
1389 | + ml_writeoff = self.writeoff_move_line_get(cr, uid, voucher.id, line_total, move_id, name, company_currency, current_currency, context) |
1390 | + if ml_writeoff: |
1391 | + ml_writeoff_id = move_line_pool.create(cr, uid, ml_writeoff, context) |
1392 | + #We post the voucher. |
1393 | + self.write(cr, uid, [voucher.id], { |
1394 | + 'move_id': move_id, |
1395 | + 'state': 'posted', |
1396 | + 'number': name, |
1397 | + }) |
1398 | + move_pool.post(cr, uid, [move_id], context={}) |
1399 | + #reconcile move line |
1400 | + for rec_ids in rec_list_ids: |
1401 | + if len(rec_ids) >= 2: |
1402 | + move_line_pool.reconcile_partial(cr, uid, rec_ids) |
1403 | + return True |
1404 | + |
1405 | + |
1406 | + |
1407 | +account_voucher() |
1408 | + |
1409 | + |
1410 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
Unido al trunk:
revno: 483 [merge] squezee- vir-20111128193 928-5y1rz0bchsn yuy14
revision-id: javier@