Merge lp:~therp-nl/banking-addons/ba70-aggregate_payment into lp:banking-addons

Proposed by Stefan Rijnhart (Opener)
Status: Work in progress
Proposed branch: lp:~therp-nl/banking-addons/ba70-aggregate_payment
Merge into: lp:banking-addons
Diff against target: 866 lines (+788/-2)
12 files modified
account_banking/res_partner_bank.py (+5/-0)
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 (+252/-0)
account_banking_aggregate_payment/model/payment_mode.py (+35/-0)
account_banking_aggregate_payment/view/export_aggregate.xml (+29/-0)
account_banking_aggregate_payment/view/payment_mode.xml (+51/-0)
account_banking_payment/model/account_payment.py (+2/-2)
To merge this branch: bzr merge lp:~therp-nl/banking-addons/ba70-aggregate_payment
Reviewer Review Type Date Requested Status
Maxime Chambreuil (http://www.savoirfairelinux.com) code review Approve
Holger Brunn (Therp) Needs Fixing
Guewen Baconnier @ Camptocamp Needs Information
Review via email: mp+178466@code.launchpad.net

Commit message

[MIG] Aggregate payment module

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Is there a reason why you didn't use the account_move_line.reconcile() / account_move_line.partial_reconcile()?
I think there is one, but I'm curious to know why you couldn't use it (performance?).

Aside of this question, from a code point of view, sounds good to me.

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

#521 if you know where it goes wrong, please tell the user
#591 i think you shouldn't be using context_today here. That's only for passing stuff to the user

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

...forget about the comment about #591, by now I think you're doing the right thing here

Revision history for this message
Maxime Chambreuil (http://www.savoirfairelinux.com) (max3903) :
review: Approve (code review)
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks for the pointer, Guewen. I will look into it.

180. By Stefan Rijnhart (Opener)

[MRG] parent branch

181. By Stefan Rijnhart (Opener)

[FIX] Search

Unmerged revisions

181. By Stefan Rijnhart (Opener)

[FIX] Search

180. By Stefan Rijnhart (Opener)

[MRG] parent branch

179. By Stefan Rijnhart (Opener)

[RFR] Adapt aggregate payment module to new payment order workflow
[RFR] Finetune names and references of created moves and move lines
[RFR] Adapt reference to view that moved to another module
[RFR] Remove view types as per OpenERP 7.0 API change

178. By Stefan Rijnhart (Opener)

[ADD] Version 6.1 of the aggregate payment module

Preview Diff

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

Subscribers

People subscribed via source and target branches

to status/vote changes: