Merge lp:~therp-nl/banking-addons/6.1-aggregate_payments into lp:banking-addons/6.1

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 175
Proposed branch: lp:~therp-nl/banking-addons/6.1-aggregate_payments
Merge into: lp:banking-addons/6.1
Diff against target: 853 lines (+799/-0)
10 files modified
account_banking_aggregate_payment/__init__.py (+1/-0)
account_banking_aggregate_payment/__openerp__.py (+49/-0)
account_banking_aggregate_payment/data/payment_mode_type.xml (+17/-0)
account_banking_aggregate_payment/i18n/account_banking_aggregate_payment.pot (+175/-0)
account_banking_aggregate_payment/i18n/nl.po (+170/-0)
account_banking_aggregate_payment/model/__init__.py (+2/-0)
account_banking_aggregate_payment/model/export_aggregate.py (+268/-0)
account_banking_aggregate_payment/model/payment_mode.py (+35/-0)
account_banking_aggregate_payment/view/export_aggregate.xml (+30/-0)
account_banking_aggregate_payment/view/payment_mode.xml (+52/-0)
To merge this branch: bzr merge lp:~therp-nl/banking-addons/6.1-aggregate_payments
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Review via email: mp+169288@code.launchpad.net

Description of the change

From the module description that this branch adds:

This module allows for aggregating payments for various creditors and making them payable to a single partner. This is practiced in certain purchasing consortia.

After collection of the payable invoices on a payment order of type 'Aggregate payment', the move lines in the payment order are reconciled by a move on a transit account, the total amount of which is then transferred onto the designated partner's account payable (upon confirmation of the aggregate payment order).

The payment order wizard then proceeds to create a new payment order of a user chosen payment mode with only the aggregate move line in it.

Notes:
- The dependency on account_direct_debit is completely artificial. It only needs the two fields that it adds to the payment mode. This calls for a refactoring which actually has already been carried out for 7.0. I would prefer to leave 6.1 as it is to be honest.
- I am not sure about the English terminology 'Aggregate payment' and 'Transit move & account'. Any suggestions are welcome.

To post a comment you must log in.
180. By Stefan Rijnhart (Opener)

[FIX] License and expected revision number, uneven spacing in xml

Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

Just a small thing:

#700 can reference be False here?

review: Approve (code review)
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

No, should not occur as it is a required field on the payment order that has its own sequence in the default configuration.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_banking_aggregate_payment'
2=== added file 'account_banking_aggregate_payment/__init__.py'
3--- account_banking_aggregate_payment/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_banking_aggregate_payment/__init__.py 2013-06-13 20:06:26 +0000
5@@ -0,0 +1,1 @@
6+import model
7
8=== added file 'account_banking_aggregate_payment/__openerp__.py'
9--- account_banking_aggregate_payment/__openerp__.py 1970-01-01 00:00:00 +0000
10+++ account_banking_aggregate_payment/__openerp__.py 2013-06-13 20:06:26 +0000
11@@ -0,0 +1,49 @@
12+# -*- coding: utf-8 -*-
13+##############################################################################
14+#
15+# OpenERP, Open Source Management Solution
16+# This module copyright (C) 2013 Therp BV (<http://therp.nl>).
17+#
18+# This program is free software: you can redistribute it and/or modify
19+# it under the terms of the GNU Affero General Public License as
20+# published by the Free Software Foundation, either version 3 of the
21+# License, or (at your option) any later version.
22+#
23+# This program is distributed in the hope that it will be useful,
24+# but WITHOUT ANY WARRANTY; without even the implied warranty of
25+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26+# GNU Affero General Public License for more details.
27+#
28+# You should have received a copy of the GNU Affero General Public License
29+# along with this program. If not, see <http://www.gnu.org/licenses/>.
30+#
31+##############################################################################
32+{
33+ 'name': 'Account Banking Aggregate Payment',
34+ 'version': '0.1.173',
35+ 'license': 'AGPL-3',
36+ 'author': 'Therp BV',
37+ 'website': 'https://launchpad.net/banking-addons',
38+ 'category': 'Banking addons',
39+ 'depends': ['account_direct_debit'],
40+ 'data': [
41+ 'data/payment_mode_type.xml',
42+ 'view/payment_mode.xml',
43+ 'view/export_aggregate.xml',
44+ ],
45+ 'description': '''
46+ This module allows for aggregating payments for various creditors
47+ and making them payable to a single partner. This is practiced in
48+ certain purchasing consortia.
49+
50+ After collection of the payable invoices on a payment order of type
51+ 'Aggregate payment', the move lines in the payment order are
52+ reconciled by a move on a transit account, the total amount of which
53+ is then transferred onto the designated partner's account payable
54+ (upon confirmation of the aggregate payment order).
55+
56+ The payment order wizard then proceeds to create a new payment order
57+ of a user chosen payment mode with only the aggregate move line in it.
58+ ''',
59+ 'active': False,
60+}
61
62=== added directory 'account_banking_aggregate_payment/data'
63=== added file 'account_banking_aggregate_payment/data/payment_mode_type.xml'
64--- account_banking_aggregate_payment/data/payment_mode_type.xml 1970-01-01 00:00:00 +0000
65+++ account_banking_aggregate_payment/data/payment_mode_type.xml 2013-06-13 20:06:26 +0000
66@@ -0,0 +1,17 @@
67+<?xml version="1.0" encoding="utf-8"?>
68+<openerp>
69+ <data>
70+
71+ <record model="payment.mode.type"
72+ id="type_aggregate">
73+ <field name="name">Aggregate payment</field>
74+ <field name="code">AGGR</field>
75+ <field name="suitable_bank_types"
76+ eval="[(6, 0, (ref('base_iban.bank_iban'),
77+ ref('base.bank_normal')))]" />
78+ <field name="ir_model_id"
79+ ref="model_banking_export_aggregate"/>
80+ </record>
81+
82+ </data>
83+</openerp>
84
85=== added directory 'account_banking_aggregate_payment/i18n'
86=== added file 'account_banking_aggregate_payment/i18n/account_banking_aggregate_payment.pot'
87--- account_banking_aggregate_payment/i18n/account_banking_aggregate_payment.pot 1970-01-01 00:00:00 +0000
88+++ account_banking_aggregate_payment/i18n/account_banking_aggregate_payment.pot 2013-06-13 20:06:26 +0000
89@@ -0,0 +1,175 @@
90+# Translation of OpenERP Server.
91+# This file contains the translation of the following modules:
92+# * account_banking_aggregate_payment
93+#
94+msgid ""
95+msgstr ""
96+"Project-Id-Version: OpenERP Server 6.1\n"
97+"Report-Msgid-Bugs-To: \n"
98+"POT-Creation-Date: 2013-06-13 19:35+0000\n"
99+"PO-Revision-Date: 2013-06-13 19:35+0000\n"
100+"Last-Translator: <>\n"
101+"Language-Team: \n"
102+"MIME-Version: 1.0\n"
103+"Content-Type: text/plain; charset=UTF-8\n"
104+"Content-Transfer-Encoding: \n"
105+"Plural-Forms: \n"
106+
107+#. module: account_banking_aggregate_payment
108+#: view:payment.mode:0
109+msgid "Aggregate payment"
110+msgstr "Aggregate payment"
111+
112+#. module: account_banking_aggregate_payment
113+#: view:banking.export.aggregate:0
114+msgid "Create"
115+msgstr "Create"
116+
117+#. module: account_banking_aggregate_payment
118+#: help:payment.mode,aggregate_partner_id:0
119+msgid "The single partner on the chained payment order"
120+msgstr "The single partner on the chained payment order"
121+
122+#. module: account_banking_aggregate_payment
123+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:134
124+#, python-format
125+msgid "Aggregate Payment Order %s"
126+msgstr "Aggregate Payment Order %s"
127+
128+#. module: account_banking_aggregate_payment
129+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:230
130+#, python-format
131+msgid "Payment order workflow does not go into state \"done\""
132+msgstr "Payment order workflow does not go into state \"done\""
133+
134+#. module: account_banking_aggregate_payment
135+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:143
136+#, python-format
137+msgid "No move line provided for line %s"
138+msgstr "No move line provided for line %s"
139+
140+#. module: account_banking_aggregate_payment
141+#: model:ir.model,name:account_banking_aggregate_payment.model_payment_mode
142+msgid "Payment Mode"
143+msgstr "Payment Mode"
144+
145+#. module: account_banking_aggregate_payment
146+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:48
147+#, python-format
148+msgid "Please only select a single payment order"
149+msgstr "Please only select a single payment order"
150+
151+#. module: account_banking_aggregate_payment
152+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:147
153+#, python-format
154+msgid "Move line %s has already been paid/reconciled"
155+msgstr "Move line %s has already been paid/reconciled"
156+
157+#. module: account_banking_aggregate_payment
158+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:44
159+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:121
160+#, python-format
161+msgid "Please select a payment order"
162+msgstr "Please select a payment order"
163+
164+#. module: account_banking_aggregate_payment
165+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:125
166+#, python-format
167+msgid "This operation can only be performed on a single payment order"
168+msgstr "This operation can only be performed on a single payment order"
169+
170+#. module: account_banking_aggregate_payment
171+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:155
172+#, python-format
173+msgid "Transit %s"
174+msgstr "Transit %s"
175+
176+#. module: account_banking_aggregate_payment
177+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:191
178+#, python-format
179+msgid "Transit reconciliation"
180+msgstr "Transit reconciliation"
181+
182+#. module: account_banking_aggregate_payment
183+#: view:banking.export.aggregate:0
184+msgid "Export aggregate payment order"
185+msgstr "Export aggregate payment order"
186+
187+#. module: account_banking_aggregate_payment
188+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:208
189+#, python-format
190+msgid "Amount payable"
191+msgstr "Amount payable"
192+
193+#. module: account_banking_aggregate_payment
194+#: field:payment.mode,aggregate_partner_id:0
195+msgid "Aggregate payment beneficiary"
196+msgstr "Aggregate payment beneficiary"
197+
198+#. module: account_banking_aggregate_payment
199+#: help:payment.mode,chained_mode_id:0
200+msgid "The payment type of the chained payment order"
201+msgstr "The payment type of the chained payment order"
202+
203+#. module: account_banking_aggregate_payment
204+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:43
205+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:47
206+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:65
207+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:71
208+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:120
209+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:124
210+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:142
211+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:146
212+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:229
213+#, python-format
214+msgid "Error"
215+msgstr "Error"
216+
217+#. module: account_banking_aggregate_payment
218+#: model:ir.model,name:account_banking_aggregate_payment.model_banking_export_aggregate
219+msgid "Execute aggregate payment"
220+msgstr "Execute aggregate payment"
221+
222+#. module: account_banking_aggregate_payment
223+#: view:banking.export.aggregate:0
224+msgid "When you confirm this order, the total amount will be made payable to the partner that has been set on the payment mode. A new payment order will open in your screen with this one payment."
225+msgstr "When you confirm this order, the total amount will be made payable to the partner that has been set on the payment mode. A new payment order will open in your screen with this one payment."
226+
227+#. module: account_banking_aggregate_payment
228+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:172
229+#, python-format
230+msgid "Reconciliation %s"
231+msgstr "Reconciliation %s"
232+
233+#. module: account_banking_aggregate_payment
234+#: field:banking.export.aggregate,reference:0
235+msgid "Reference"
236+msgstr "Reference"
237+
238+#. module: account_banking_aggregate_payment
239+#: field:banking.export.aggregate,payment_order_id:0
240+msgid "Payment order"
241+msgstr "Payment order"
242+
243+#. module: account_banking_aggregate_payment
244+#: field:payment.mode,chained_mode_id:0
245+msgid "Chained payment mode"
246+msgstr "Chained payment mode"
247+
248+#. module: account_banking_aggregate_payment
249+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:66
250+#, python-format
251+msgid "Cannot reconcile between different accounts"
252+msgstr "Cannot reconcile between different accounts"
253+
254+#. module: account_banking_aggregate_payment
255+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:72
256+#, python-format
257+msgid "Line is already fully reconciled"
258+msgstr "Line is already fully reconciled"
259+
260+#. module: account_banking_aggregate_payment
261+#: view:banking.export.aggregate:0
262+msgid "Cancel"
263+msgstr "Cancel"
264+
265
266=== added file 'account_banking_aggregate_payment/i18n/nl.po'
267--- account_banking_aggregate_payment/i18n/nl.po 1970-01-01 00:00:00 +0000
268+++ account_banking_aggregate_payment/i18n/nl.po 2013-06-13 20:06:26 +0000
269@@ -0,0 +1,170 @@
270+# Translation of OpenERP Server.
271+# This file contains the translation of the following modules:
272+# * account_banking_aggregate_payment
273+#
274+msgid ""
275+msgstr ""
276+"Project-Id-Version: OpenERP Server 6.1\n"
277+"Report-Msgid-Bugs-To: \n"
278+"POT-Creation-Date: 2013-06-13 19:35+0000\n"
279+"PO-Revision-Date: 2013-06-13 19:35+0000\n"
280+"Last-Translator: <stefan@therp.nl>\n"
281+"Language-Team: \n"
282+"MIME-Version: 1.0\n"
283+"Content-Type: text/plain; charset=UTF-8\n"
284+"Content-Transfer-Encoding: \n"
285+"Plural-Forms: \n"
286+
287+#. module: account_banking_aggregate_payment
288+#: view:payment.mode:0
289+msgid "Aggregate payment"
290+msgstr "Verzamelbetaalopdracht"
291+
292+#. module: account_banking_aggregate_payment
293+#: view:banking.export.aggregate:0
294+msgid "Create"
295+msgstr "Aanmaken"
296+
297+#. module: account_banking_aggregate_payment
298+#: help:payment.mode,aggregate_partner_id:0
299+msgid "The single partner on the chained payment order"
300+msgstr "De relatie die geldt als crediteur van het verzameld bedrag"
301+
302+#. module: account_banking_aggregate_payment
303+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:134
304+#, python-format
305+msgid "Aggregate Payment Order %s"
306+msgstr "Verzamelbetaling %s"
307+
308+#. module: account_banking_aggregate_payment
309+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:230
310+#, python-format
311+msgid "Payment order workflow does not go into state \"done\""
312+msgstr "De workflow van de betaalopdracht komt niet in de status \"verwerkt\""
313+
314+#. module: account_banking_aggregate_payment
315+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:143
316+#, python-format
317+msgid "No move line provided for line %s"
318+msgstr "Er is geen boeking voor regel %s"
319+
320+#. module: account_banking_aggregate_payment
321+#: model:ir.model,name:account_banking_aggregate_payment.model_payment_mode
322+msgid "Payment Mode"
323+msgstr "Betaalwijze"
324+
325+#. module: account_banking_aggregate_payment
326+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:48
327+#, python-format
328+msgid "Please only select a single payment order"
329+msgstr "Er kan maar één betaalopdracht worden geselecteerd"
330+
331+#. module: account_banking_aggregate_payment
332+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:147
333+#, python-format
334+msgid "Move line %s has already been paid/reconciled"
335+msgstr "Boekingsregel %s is al afgeletterd"
336+
337+#. module: account_banking_aggregate_payment
338+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:44
339+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:121
340+#, python-format
341+msgid "Please select a payment order"
342+msgstr "Selecteer alstublieft een betaalopdracht"
343+
344+#. module: account_banking_aggregate_payment
345+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:125
346+#, python-format
347+msgid "This operation can only be performed on a single payment order"
348+msgstr "Deze bewerking kan alleen worden uitgevoerd op een enkele betaalopdracht"
349+
350+#. module: account_banking_aggregate_payment
351+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:155
352+#, python-format
353+msgid "Transit %s"
354+msgstr "Tussenboeking %s"
355+
356+#. module: account_banking_aggregate_payment
357+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:191
358+#, python-format
359+msgid "Transit reconciliation"
360+msgstr "Aflettering tussenboeking"
361+
362+#. module: account_banking_aggregate_payment
363+#: view:banking.export.aggregate:0
364+msgid "Export aggregate payment order"
365+msgstr "Verwerken een verzamelbetalingsopdracht"
366+
367+#. module: account_banking_aggregate_payment
368+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:208
369+#, python-format
370+msgid "Amount payable"
371+msgstr "Verschuldigd bedrag"
372+
373+#. module: account_banking_aggregate_payment
374+#: field:payment.mode,aggregate_partner_id:0
375+msgid "Aggregate payment beneficiary"
376+msgstr "Begunstigde van de verzamelbetaling"
377+
378+#. module: account_banking_aggregate_payment
379+#: help:payment.mode,chained_mode_id:0
380+msgid "The payment type of the chained payment order"
381+msgstr "De betaalwijze van de gekoppelde betaalopdracht"
382+
383+#. module: account_banking_aggregate_payment
384+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:43
385+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:47
386+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:65
387+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:71
388+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:120
389+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:124
390+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:142
391+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:146
392+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:229
393+#, python-format
394+msgid "Error"
395+msgstr "Fout"
396+
397+#. module: account_banking_aggregate_payment
398+#: model:ir.model,name:account_banking_aggregate_payment.model_banking_export_aggregate
399+msgid "Execute aggregate payment"
400+msgstr "Verzamelbetaling boeken"
401+
402+#. module: account_banking_aggregate_payment
403+#: view:banking.export.aggregate:0
404+msgid "When you confirm this order, the total amount will be made payable to the partner that has been set on the payment mode. A new payment order will open in your screen with this one payment."
405+msgstr "Als u deze betaalopdracht bevestigd, dan wordt het totaalbedrag betaalbaar gemaakt aan de relatie die op de betaalwijze aangegeven staat. In het scherm wordt een nieuwe betaalopdracht geopend met alleen dit totaalbedrag."
406+
407+#. module: account_banking_aggregate_payment
408+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:172
409+#, python-format
410+msgid "Reconciliation %s"
411+msgstr "Aflettering %s"
412+
413+#. module: account_banking_aggregate_payment
414+#: field:banking.export.aggregate,payment_order_id:0
415+msgid "Payment order"
416+msgstr "Betaalopdracht"
417+
418+#. module: account_banking_aggregate_payment
419+#: field:payment.mode,chained_mode_id:0
420+msgid "Chained payment mode"
421+msgstr "Gekoppelde betaalwijze"
422+
423+#. module: account_banking_aggregate_payment
424+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:66
425+#, python-format
426+msgid "Cannot reconcile between different accounts"
427+msgstr "Kan niet afletteren tussen verschillende grootboekrekeningen"
428+
429+#. module: account_banking_aggregate_payment
430+#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:72
431+#, python-format
432+msgid "Line is already fully reconciled"
433+msgstr "De regel is al afgeletterd"
434+
435+#. module: account_banking_aggregate_payment
436+#: view:banking.export.aggregate:0
437+msgid "Cancel"
438+msgstr "Annuleer"
439+
440
441=== added directory 'account_banking_aggregate_payment/model'
442=== added file 'account_banking_aggregate_payment/model/__init__.py'
443--- account_banking_aggregate_payment/model/__init__.py 1970-01-01 00:00:00 +0000
444+++ account_banking_aggregate_payment/model/__init__.py 2013-06-13 20:06:26 +0000
445@@ -0,0 +1,2 @@
446+import payment_mode
447+import export_aggregate
448
449=== added file 'account_banking_aggregate_payment/model/export_aggregate.py'
450--- account_banking_aggregate_payment/model/export_aggregate.py 1970-01-01 00:00:00 +0000
451+++ account_banking_aggregate_payment/model/export_aggregate.py 2013-06-13 20:06:26 +0000
452@@ -0,0 +1,268 @@
453+# -*- coding: utf-8 -*-
454+##############################################################################
455+#
456+# OpenERP, Open Source Management Solution
457+# This module copyright (C) 2013 Therp BV (<http://therp.nl>).
458+#
459+# This program is free software: you can redistribute it and/or modify
460+# it under the terms of the GNU Affero General Public License as
461+# published by the Free Software Foundation, either version 3 of the
462+# License, or (at your option) any later version.
463+#
464+# This program is distributed in the hope that it will be useful,
465+# but WITHOUT ANY WARRANTY; without even the implied warranty of
466+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
467+# GNU Affero General Public License for more details.
468+#
469+# You should have received a copy of the GNU Affero General Public License
470+# along with this program. If not, see <http://www.gnu.org/licenses/>.
471+#
472+##############################################################################
473+
474+from openerp.osv import orm, fields
475+from openerp.tools.translate import _
476+from openerp import netsvc
477+
478+
479+class banking_export_aggregate(orm.TransientModel):
480+ _name = 'banking.export.aggregate'
481+ _description = 'Execute aggregate payment order'
482+ _rec_name = 'payment_order_id'
483+
484+ _columns = {
485+ 'payment_order_id': fields.many2one(
486+ 'payment.order', 'Payment order',
487+ required=True),
488+ }
489+
490+ def create(self, cr, uid, vals, context=None):
491+ if context is None:
492+ context = {}
493+ if not vals.get('payment_order_id'):
494+ if not context.get('active_ids'):
495+ raise orm.except_orm(
496+ _('Error'),
497+ _('Please select a payment order'))
498+ if len(context['active_ids']) > 1:
499+ raise orm.except_orm(
500+ _('Error'),
501+ _('Please only select a single payment order'))
502+ vals['payment_order_id'] = context['active_ids'][0]
503+ return super(banking_export_aggregate, self).create(
504+ cr, uid, vals, context=context)
505+
506+ def reconcile_lines(self, cr, uid, move_line_ids, context=None):
507+ """
508+ Reconcile move lines lines, really. ERP core functionality.
509+ """
510+ reconcile_obj = self.pool.get('account.move.reconcile')
511+ account_move_line_obj = self.pool.get('account.move.line')
512+ currency_obj = self.pool.get('res.currency')
513+ lines = account_move_line_obj.browse(cr, uid, move_line_ids, context=context)
514+
515+ for line in lines[1:]:
516+ if line.account_id != lines[0].account_id:
517+ raise orm.except_orm(
518+ _('Error'),
519+ _('Cannot reconcile between different accounts'))
520+
521+ if any([line.reconcile_id and line.reconcile_id.line_id
522+ for line in lines]):
523+ raise orm.except_orm(
524+ _('Error'),
525+ _('Line is already fully reconciled'))
526+
527+ currency = lines[0].company_id.currency_id
528+
529+ partials = []
530+ line_ids = []
531+ for line in lines:
532+ if line.id not in line_ids:
533+ line_ids.append(line.id)
534+ if line.reconcile_partial_id:
535+ line_ids += line.reconcile_partial_id.line_partial_ids
536+ if line.reconcile_partial_id.id not in partials:
537+ partials.append(line.reconcile_partial_id.id)
538+
539+ total = account_move_line_obj.get_balance(cr, uid, line_ids)
540+ is_zero = currency_obj.is_zero(cr, uid, currency, total)
541+
542+ vals = {
543+ 'type': 'auto',
544+ 'line_id': is_zero and [(6, 0, line_ids)] or [(6, 0, [])],
545+ 'line_partial_ids': is_zero and [(6, 0, [])] or [(6, 0, line_ids)],
546+ }
547+
548+ if partials:
549+ if len(partials) > 1:
550+ reconcile_obj.unlink(
551+ cr, uid, partials[1:], context=context)
552+ reconcile_obj.write(
553+ cr, uid, partials[0],
554+ vals, context=context)
555+ else:
556+ reconcile_obj.create(
557+ cr, uid, vals, context=context)
558+
559+ for line_id in line_ids:
560+ netsvc.LocalService("workflow").trg_trigger(
561+ uid, 'account.move.line', line_id, cr)
562+ return True
563+
564+ def create_aggregate_order(self, cr, uid, ids, context=None):
565+ wiz = self.browse(cr, uid, ids[0], context=context)
566+ account_move_line_obj = self.pool.get('account.move.line')
567+ account_move_obj = self.pool.get('account.move')
568+ payment_order_obj = self.pool.get('payment.order')
569+ payment_order_line_obj = self.pool.get('payment.line')
570+ payment_order_ids = context.get('active_ids', [])
571+ if not payment_order_ids:
572+ raise orm.except_orm(
573+ _('Error'),
574+ _('Please select a payment order'))
575+ if len(payment_order_ids) > 1:
576+ raise orm.except_orm(
577+ _('Error'),
578+ _('This operation can only be performed on a single '
579+ 'payment order'))
580+
581+ today = fields.date.context_today(self, cr, uid, context=context)
582+ order = payment_order_obj.browse(
583+ cr, uid, payment_order_ids[0], context=context)
584+
585+ move_id = account_move_obj.create(cr, uid, {
586+ 'journal_id': order.mode.transfer_journal_id.id,
587+ 'ref': _('Aggregate Payment Order %s') % order.reference,
588+ }, context=context)
589+
590+ counter_move_line_ids = []
591+ for line in order.line_ids:
592+ # basic checks
593+ if not line.move_line_id:
594+ raise orm.except_orm(
595+ _('Error'),
596+ _('No move line provided for line %s') % line.name)
597+ if line.move_line_id.reconcile_id:
598+ raise orm.except_orm(
599+ _('Error'),
600+ _('Move line %s has already been paid/reconciled') %
601+ line.move_line_id.name
602+ )
603+
604+ # TODO: take multicurrency into account?
605+
606+ # create the move line on the transfer account
607+ vals = {
608+ 'name': _('Transit %s') % (
609+ line.move_line_id.invoice and
610+ line.move_line_id.invoice.number or
611+ line.move_line_id.ref),
612+ 'move_id': move_id,
613+ 'partner_id': line.partner_id and line.partner_id.id or False,
614+ 'account_id': order.mode.transfer_account_id.id,
615+ 'credit': line.amount,
616+ 'debit': 0.0,
617+ 'date': today,
618+ }
619+ counter_move_line_id = account_move_line_obj.create(
620+ cr, uid, vals, context=context)
621+ counter_move_line_ids.append(counter_move_line_id)
622+
623+ # create the debit move line on the receivable account
624+ vals.update({
625+ 'name': _('Reconciliation %s') % (
626+ line.move_line_id.invoice and
627+ line.move_line_id.invoice.number or
628+ line.move_line_id.name),
629+ 'account_id': line.move_line_id.account_id.id,
630+ 'credit': 0.0,
631+ 'debit': line.amount,
632+ })
633+ reconcile_move_line_id = account_move_line_obj.create(
634+ cr, uid, vals, context=context)
635+
636+ self.reconcile_lines(
637+ cr, uid, [reconcile_move_line_id, line.move_line_id.id],
638+ context=context)
639+
640+ total = account_move_line_obj.get_balance(
641+ cr, uid, counter_move_line_ids)
642+
643+ vals = {
644+ 'name': _('Transit reconciliation'),
645+ 'move_id': move_id,
646+ 'partner_id': order.mode.aggregate_partner_id.id,
647+ 'account_id': order.mode.transfer_account_id.id,
648+ 'debit': total < 0 and -total or 0.0,
649+ 'credit': total >= 0 and total or 0.0,
650+ 'date': today,
651+ }
652+ aggregate_move_line_id = account_move_line_obj.create(
653+ cr, uid, vals, context=context)
654+
655+ self.reconcile_lines(
656+ cr, uid, counter_move_line_ids + [aggregate_move_line_id],
657+ context=context)
658+
659+ # create the credit move line on the aggregate partner
660+ vals.update({
661+ 'name': _('Amount payable'),
662+ 'account_id': order.mode.aggregate_partner_id.property_account_payable.id,
663+ 'partner_id': order.mode.aggregate_partner_id.id,
664+ 'debit': total >= 0 and total or 0.0,
665+ 'credit': total < 0 and -total or 0.0,
666+ })
667+
668+ payable_move_line = account_move_line_obj.browse(
669+ cr, uid,
670+ account_move_line_obj.create(
671+ cr, uid, vals, context=context),
672+ context=context)
673+
674+ account_move_obj.post(cr, uid, [move_id], context=context)
675+
676+ wf_service = netsvc.LocalService('workflow')
677+ wf_service.trg_validate(uid, 'payment.order', order.id, 'sent', cr)
678+ wf_service.trg_validate(uid, 'payment.order', order.id, 'done', cr)
679+ order.refresh()
680+ if order.state != 'done':
681+ raise orm.except_orm(
682+ _('Error'),
683+ _('Payment order workflow does not go into state "done"'))
684+
685+ payment_order_id = payment_order_obj.create(
686+ cr, uid, {
687+ 'company_id': order.company_id.id,
688+ 'mode': order.mode.chained_mode_id.id,
689+ }, context=context)
690+
691+ lines2bank = account_move_line_obj.line2bank(
692+ cr, uid, [payable_move_line.id], order.mode.id, context)
693+
694+ payment_order_line_obj.create(cr, uid,{
695+ 'move_line_id': payable_move_line.id,
696+ 'amount_currency': payable_move_line.amount_to_pay,
697+ 'bank_id': lines2bank.get(payable_move_line.id),
698+ 'order_id': payment_order_id,
699+ 'partner_id': order.mode.aggregate_partner_id.id,
700+ 'communication': order.reference.replace('/', ''),
701+ 'communication2': False,
702+ 'state': 'structured',
703+ 'date': today,
704+ 'currency': (
705+ line.move_line_id.journal_id.currency.id or
706+ line.move_line_id.journal_id.company_id.currency_id.id),
707+ }, context=context)
708+
709+ return {
710+ 'name': payment_order_obj._description,
711+ 'view_type': 'form',
712+ 'view_mode': 'form',
713+ 'res_model': payment_order_obj._name,
714+ 'domain': [],
715+ 'context': context,
716+ 'type': 'ir.actions.act_window',
717+ 'target': 'current',
718+ 'res_id': payment_order_id,
719+ 'nodestroy': True,
720+ }
721
722=== added file 'account_banking_aggregate_payment/model/payment_mode.py'
723--- account_banking_aggregate_payment/model/payment_mode.py 1970-01-01 00:00:00 +0000
724+++ account_banking_aggregate_payment/model/payment_mode.py 2013-06-13 20:06:26 +0000
725@@ -0,0 +1,35 @@
726+# -*- coding: utf-8 -*-
727+##############################################################################
728+#
729+# OpenERP, Open Source Management Solution
730+# This module copyright (C) 2013 Therp BV (<http://therp.nl>).
731+#
732+# This program is free software: you can redistribute it and/or modify
733+# it under the terms of the GNU Affero General Public License as
734+# published by the Free Software Foundation, either version 3 of the
735+# License, or (at your option) any later version.
736+#
737+# This program is distributed in the hope that it will be useful,
738+# but WITHOUT ANY WARRANTY; without even the implied warranty of
739+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
740+# GNU Affero General Public License for more details.
741+#
742+# You should have received a copy of the GNU Affero General Public License
743+# along with this program. If not, see <http://www.gnu.org/licenses/>.
744+#
745+##############################################################################
746+
747+from openerp.osv import orm, fields
748+
749+
750+class payment_mode(orm.Model):
751+ _inherit = "payment.mode"
752+ _columns = {
753+ 'aggregate_partner_id': fields.many2one(
754+ 'res.partner', 'Aggregate payment beneficiary',
755+ help="The single partner on the chained payment order",
756+ ),
757+ 'chained_mode_id': fields.many2one(
758+ 'payment.mode', 'Chained payment mode',
759+ help="The payment type of the chained payment order"),
760+ }
761
762=== added directory 'account_banking_aggregate_payment/view'
763=== added file 'account_banking_aggregate_payment/view/export_aggregate.xml'
764--- account_banking_aggregate_payment/view/export_aggregate.xml 1970-01-01 00:00:00 +0000
765+++ account_banking_aggregate_payment/view/export_aggregate.xml 2013-06-13 20:06:26 +0000
766@@ -0,0 +1,30 @@
767+<?xml version="1.0" encoding="utf-8"?>
768+<openerp>
769+ <data>
770+ <record id="banking_export_aggregate_view" model="ir.ui.view">
771+ <field name="name">Export aggregate payment order</field>
772+ <field name="model">banking.export.aggregate</field>
773+ <field name="type">form</field>
774+ <field name="arch" type="xml">
775+ <form string="Export aggregate payment order">
776+ <label string="When you confirm this order, the total
777+ amount will be made payable to the partner
778+ that has been set on the payment mode. A
779+ new payment order will open in your screen
780+ with this one payment."/>
781+ <group col="2" colspan="1">
782+ <button icon="gtk-close"
783+ special="cancel"
784+ string="Cancel"
785+ />
786+ <button icon="gtk-ok"
787+ string="Create"
788+ name="create_aggregate_order"
789+ type="object"
790+ />
791+ </group>
792+ </form>
793+ </field>
794+ </record>
795+ </data>
796+</openerp>
797
798=== added file 'account_banking_aggregate_payment/view/payment_mode.xml'
799--- account_banking_aggregate_payment/view/payment_mode.xml 1970-01-01 00:00:00 +0000
800+++ account_banking_aggregate_payment/view/payment_mode.xml 2013-06-13 20:06:26 +0000
801@@ -0,0 +1,52 @@
802+<?xml version="1.0" encoding="utf-8"?>
803+<openerp>
804+ <data>
805+ <record id="view_payment_mode_form" model="ir.ui.view">
806+ <field name="name">Adaptations for aggregate payment modes</field>
807+ <field name="model">payment.mode</field>
808+ <field name="inherit_id"
809+ ref="account_direct_debit.view_payment_mode_form"/>
810+ <field name="type">form</field>
811+ <field name="arch" type="xml">
812+ <field name="payment_term_ids" position="after">
813+ <group colspan="2" col="2" string="Aggregate payment"
814+ attrs="{
815+ 'invisible': [
816+ ('type', '!=',
817+ %(account_banking_aggregate_payment.type_aggregate)d
818+ )]}">
819+ <field name="aggregate_partner_id"
820+ attrs="{'required': [
821+ ('type', '=',
822+ %(account_banking_aggregate_payment.type_aggregate)d
823+ )]}"
824+ />
825+ <field name="chained_mode_id"
826+ attrs="{'required': [
827+ ('type', '=',
828+ %(account_banking_aggregate_payment.type_aggregate)d
829+ )]}"
830+ />
831+ </group>
832+ </field>
833+
834+ <field name="transfer_account_id" position="attributes">
835+ <attribute name="attrs">{
836+ 'required': [
837+ ('type', '=',
838+ %(account_banking_aggregate_payment.type_aggregate)d
839+ )]}</attribute>
840+ </field>
841+
842+ <field name="transfer_journal_id" position="attributes">
843+ <attribute name="attrs">{
844+ 'required': [
845+ ('type', '=',
846+ %(account_banking_aggregate_payment.type_aggregate)d
847+ )]}</attribute>
848+ </field>
849+
850+ </field>
851+ </record>
852+ </data>
853+</openerp>

Subscribers

People subscribed via source and target branches