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
=== added directory 'account_banking_aggregate_payment'
=== added file 'account_banking_aggregate_payment/__init__.py'
--- account_banking_aggregate_payment/__init__.py 1970-01-01 00:00:00 +0000
+++ account_banking_aggregate_payment/__init__.py 2013-06-13 20:06:26 +0000
@@ -0,0 +1,1 @@
1import model
02
=== added file 'account_banking_aggregate_payment/__openerp__.py'
--- account_banking_aggregate_payment/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_banking_aggregate_payment/__openerp__.py 2013-06-13 20:06:26 +0000
@@ -0,0 +1,49 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2013 Therp BV (<http://therp.nl>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21{
22 'name': 'Account Banking Aggregate Payment',
23 'version': '0.1.173',
24 'license': 'AGPL-3',
25 'author': 'Therp BV',
26 'website': 'https://launchpad.net/banking-addons',
27 'category': 'Banking addons',
28 'depends': ['account_direct_debit'],
29 'data': [
30 'data/payment_mode_type.xml',
31 'view/payment_mode.xml',
32 'view/export_aggregate.xml',
33 ],
34 'description': '''
35 This module allows for aggregating payments for various creditors
36 and making them payable to a single partner. This is practiced in
37 certain purchasing consortia.
38
39 After collection of the payable invoices on a payment order of type
40 'Aggregate payment', the move lines in the payment order are
41 reconciled by a move on a transit account, the total amount of which
42 is then transferred onto the designated partner's account payable
43 (upon confirmation of the aggregate payment order).
44
45 The payment order wizard then proceeds to create a new payment order
46 of a user chosen payment mode with only the aggregate move line in it.
47 ''',
48 'active': False,
49}
050
=== added directory 'account_banking_aggregate_payment/data'
=== added file 'account_banking_aggregate_payment/data/payment_mode_type.xml'
--- account_banking_aggregate_payment/data/payment_mode_type.xml 1970-01-01 00:00:00 +0000
+++ account_banking_aggregate_payment/data/payment_mode_type.xml 2013-06-13 20:06:26 +0000
@@ -0,0 +1,17 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record model="payment.mode.type"
6 id="type_aggregate">
7 <field name="name">Aggregate payment</field>
8 <field name="code">AGGR</field>
9 <field name="suitable_bank_types"
10 eval="[(6, 0, (ref('base_iban.bank_iban'),
11 ref('base.bank_normal')))]" />
12 <field name="ir_model_id"
13 ref="model_banking_export_aggregate"/>
14 </record>
15
16 </data>
17</openerp>
018
=== added directory 'account_banking_aggregate_payment/i18n'
=== added file 'account_banking_aggregate_payment/i18n/account_banking_aggregate_payment.pot'
--- account_banking_aggregate_payment/i18n/account_banking_aggregate_payment.pot 1970-01-01 00:00:00 +0000
+++ account_banking_aggregate_payment/i18n/account_banking_aggregate_payment.pot 2013-06-13 20:06:26 +0000
@@ -0,0 +1,175 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * account_banking_aggregate_payment
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.1\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2013-06-13 19:35+0000\n"
10"PO-Revision-Date: 2013-06-13 19:35+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: account_banking_aggregate_payment
19#: view:payment.mode:0
20msgid "Aggregate payment"
21msgstr "Aggregate payment"
22
23#. module: account_banking_aggregate_payment
24#: view:banking.export.aggregate:0
25msgid "Create"
26msgstr "Create"
27
28#. module: account_banking_aggregate_payment
29#: help:payment.mode,aggregate_partner_id:0
30msgid "The single partner on the chained payment order"
31msgstr "The single partner on the chained payment order"
32
33#. module: account_banking_aggregate_payment
34#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:134
35#, python-format
36msgid "Aggregate Payment Order %s"
37msgstr "Aggregate Payment Order %s"
38
39#. module: account_banking_aggregate_payment
40#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:230
41#, python-format
42msgid "Payment order workflow does not go into state \"done\""
43msgstr "Payment order workflow does not go into state \"done\""
44
45#. module: account_banking_aggregate_payment
46#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:143
47#, python-format
48msgid "No move line provided for line %s"
49msgstr "No move line provided for line %s"
50
51#. module: account_banking_aggregate_payment
52#: model:ir.model,name:account_banking_aggregate_payment.model_payment_mode
53msgid "Payment Mode"
54msgstr "Payment Mode"
55
56#. module: account_banking_aggregate_payment
57#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:48
58#, python-format
59msgid "Please only select a single payment order"
60msgstr "Please only select a single payment order"
61
62#. module: account_banking_aggregate_payment
63#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:147
64#, python-format
65msgid "Move line %s has already been paid/reconciled"
66msgstr "Move line %s has already been paid/reconciled"
67
68#. module: account_banking_aggregate_payment
69#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:44
70#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:121
71#, python-format
72msgid "Please select a payment order"
73msgstr "Please select a payment order"
74
75#. module: account_banking_aggregate_payment
76#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:125
77#, python-format
78msgid "This operation can only be performed on a single payment order"
79msgstr "This operation can only be performed on a single payment order"
80
81#. module: account_banking_aggregate_payment
82#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:155
83#, python-format
84msgid "Transit %s"
85msgstr "Transit %s"
86
87#. module: account_banking_aggregate_payment
88#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:191
89#, python-format
90msgid "Transit reconciliation"
91msgstr "Transit reconciliation"
92
93#. module: account_banking_aggregate_payment
94#: view:banking.export.aggregate:0
95msgid "Export aggregate payment order"
96msgstr "Export aggregate payment order"
97
98#. module: account_banking_aggregate_payment
99#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:208
100#, python-format
101msgid "Amount payable"
102msgstr "Amount payable"
103
104#. module: account_banking_aggregate_payment
105#: field:payment.mode,aggregate_partner_id:0
106msgid "Aggregate payment beneficiary"
107msgstr "Aggregate payment beneficiary"
108
109#. module: account_banking_aggregate_payment
110#: help:payment.mode,chained_mode_id:0
111msgid "The payment type of the chained payment order"
112msgstr "The payment type of the chained payment order"
113
114#. module: account_banking_aggregate_payment
115#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:43
116#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:47
117#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:65
118#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:71
119#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:120
120#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:124
121#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:142
122#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:146
123#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:229
124#, python-format
125msgid "Error"
126msgstr "Error"
127
128#. module: account_banking_aggregate_payment
129#: model:ir.model,name:account_banking_aggregate_payment.model_banking_export_aggregate
130msgid "Execute aggregate payment"
131msgstr "Execute aggregate payment"
132
133#. module: account_banking_aggregate_payment
134#: view:banking.export.aggregate:0
135msgid "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."
136msgstr "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."
137
138#. module: account_banking_aggregate_payment
139#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:172
140#, python-format
141msgid "Reconciliation %s"
142msgstr "Reconciliation %s"
143
144#. module: account_banking_aggregate_payment
145#: field:banking.export.aggregate,reference:0
146msgid "Reference"
147msgstr "Reference"
148
149#. module: account_banking_aggregate_payment
150#: field:banking.export.aggregate,payment_order_id:0
151msgid "Payment order"
152msgstr "Payment order"
153
154#. module: account_banking_aggregate_payment
155#: field:payment.mode,chained_mode_id:0
156msgid "Chained payment mode"
157msgstr "Chained payment mode"
158
159#. module: account_banking_aggregate_payment
160#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:66
161#, python-format
162msgid "Cannot reconcile between different accounts"
163msgstr "Cannot reconcile between different accounts"
164
165#. module: account_banking_aggregate_payment
166#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:72
167#, python-format
168msgid "Line is already fully reconciled"
169msgstr "Line is already fully reconciled"
170
171#. module: account_banking_aggregate_payment
172#: view:banking.export.aggregate:0
173msgid "Cancel"
174msgstr "Cancel"
175
0176
=== added file 'account_banking_aggregate_payment/i18n/nl.po'
--- account_banking_aggregate_payment/i18n/nl.po 1970-01-01 00:00:00 +0000
+++ account_banking_aggregate_payment/i18n/nl.po 2013-06-13 20:06:26 +0000
@@ -0,0 +1,170 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * account_banking_aggregate_payment
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.1\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2013-06-13 19:35+0000\n"
10"PO-Revision-Date: 2013-06-13 19:35+0000\n"
11"Last-Translator: <stefan@therp.nl>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: account_banking_aggregate_payment
19#: view:payment.mode:0
20msgid "Aggregate payment"
21msgstr "Verzamelbetaalopdracht"
22
23#. module: account_banking_aggregate_payment
24#: view:banking.export.aggregate:0
25msgid "Create"
26msgstr "Aanmaken"
27
28#. module: account_banking_aggregate_payment
29#: help:payment.mode,aggregate_partner_id:0
30msgid "The single partner on the chained payment order"
31msgstr "De relatie die geldt als crediteur van het verzameld bedrag"
32
33#. module: account_banking_aggregate_payment
34#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:134
35#, python-format
36msgid "Aggregate Payment Order %s"
37msgstr "Verzamelbetaling %s"
38
39#. module: account_banking_aggregate_payment
40#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:230
41#, python-format
42msgid "Payment order workflow does not go into state \"done\""
43msgstr "De workflow van de betaalopdracht komt niet in de status \"verwerkt\""
44
45#. module: account_banking_aggregate_payment
46#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:143
47#, python-format
48msgid "No move line provided for line %s"
49msgstr "Er is geen boeking voor regel %s"
50
51#. module: account_banking_aggregate_payment
52#: model:ir.model,name:account_banking_aggregate_payment.model_payment_mode
53msgid "Payment Mode"
54msgstr "Betaalwijze"
55
56#. module: account_banking_aggregate_payment
57#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:48
58#, python-format
59msgid "Please only select a single payment order"
60msgstr "Er kan maar één betaalopdracht worden geselecteerd"
61
62#. module: account_banking_aggregate_payment
63#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:147
64#, python-format
65msgid "Move line %s has already been paid/reconciled"
66msgstr "Boekingsregel %s is al afgeletterd"
67
68#. module: account_banking_aggregate_payment
69#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:44
70#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:121
71#, python-format
72msgid "Please select a payment order"
73msgstr "Selecteer alstublieft een betaalopdracht"
74
75#. module: account_banking_aggregate_payment
76#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:125
77#, python-format
78msgid "This operation can only be performed on a single payment order"
79msgstr "Deze bewerking kan alleen worden uitgevoerd op een enkele betaalopdracht"
80
81#. module: account_banking_aggregate_payment
82#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:155
83#, python-format
84msgid "Transit %s"
85msgstr "Tussenboeking %s"
86
87#. module: account_banking_aggregate_payment
88#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:191
89#, python-format
90msgid "Transit reconciliation"
91msgstr "Aflettering tussenboeking"
92
93#. module: account_banking_aggregate_payment
94#: view:banking.export.aggregate:0
95msgid "Export aggregate payment order"
96msgstr "Verwerken een verzamelbetalingsopdracht"
97
98#. module: account_banking_aggregate_payment
99#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:208
100#, python-format
101msgid "Amount payable"
102msgstr "Verschuldigd bedrag"
103
104#. module: account_banking_aggregate_payment
105#: field:payment.mode,aggregate_partner_id:0
106msgid "Aggregate payment beneficiary"
107msgstr "Begunstigde van de verzamelbetaling"
108
109#. module: account_banking_aggregate_payment
110#: help:payment.mode,chained_mode_id:0
111msgid "The payment type of the chained payment order"
112msgstr "De betaalwijze van de gekoppelde betaalopdracht"
113
114#. module: account_banking_aggregate_payment
115#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:43
116#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:47
117#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:65
118#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:71
119#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:120
120#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:124
121#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:142
122#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:146
123#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:229
124#, python-format
125msgid "Error"
126msgstr "Fout"
127
128#. module: account_banking_aggregate_payment
129#: model:ir.model,name:account_banking_aggregate_payment.model_banking_export_aggregate
130msgid "Execute aggregate payment"
131msgstr "Verzamelbetaling boeken"
132
133#. module: account_banking_aggregate_payment
134#: view:banking.export.aggregate:0
135msgid "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."
136msgstr "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."
137
138#. module: account_banking_aggregate_payment
139#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:172
140#, python-format
141msgid "Reconciliation %s"
142msgstr "Aflettering %s"
143
144#. module: account_banking_aggregate_payment
145#: field:banking.export.aggregate,payment_order_id:0
146msgid "Payment order"
147msgstr "Betaalopdracht"
148
149#. module: account_banking_aggregate_payment
150#: field:payment.mode,chained_mode_id:0
151msgid "Chained payment mode"
152msgstr "Gekoppelde betaalwijze"
153
154#. module: account_banking_aggregate_payment
155#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:66
156#, python-format
157msgid "Cannot reconcile between different accounts"
158msgstr "Kan niet afletteren tussen verschillende grootboekrekeningen"
159
160#. module: account_banking_aggregate_payment
161#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:72
162#, python-format
163msgid "Line is already fully reconciled"
164msgstr "De regel is al afgeletterd"
165
166#. module: account_banking_aggregate_payment
167#: view:banking.export.aggregate:0
168msgid "Cancel"
169msgstr "Annuleer"
170
0171
=== added directory 'account_banking_aggregate_payment/model'
=== added file 'account_banking_aggregate_payment/model/__init__.py'
--- account_banking_aggregate_payment/model/__init__.py 1970-01-01 00:00:00 +0000
+++ account_banking_aggregate_payment/model/__init__.py 2013-06-13 20:06:26 +0000
@@ -0,0 +1,2 @@
1import payment_mode
2import export_aggregate
03
=== added file 'account_banking_aggregate_payment/model/export_aggregate.py'
--- account_banking_aggregate_payment/model/export_aggregate.py 1970-01-01 00:00:00 +0000
+++ account_banking_aggregate_payment/model/export_aggregate.py 2013-06-13 20:06:26 +0000
@@ -0,0 +1,268 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2013 Therp BV (<http://therp.nl>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.osv import orm, fields
23from openerp.tools.translate import _
24from openerp import netsvc
25
26
27class banking_export_aggregate(orm.TransientModel):
28 _name = 'banking.export.aggregate'
29 _description = 'Execute aggregate payment order'
30 _rec_name = 'payment_order_id'
31
32 _columns = {
33 'payment_order_id': fields.many2one(
34 'payment.order', 'Payment order',
35 required=True),
36 }
37
38 def create(self, cr, uid, vals, context=None):
39 if context is None:
40 context = {}
41 if not vals.get('payment_order_id'):
42 if not context.get('active_ids'):
43 raise orm.except_orm(
44 _('Error'),
45 _('Please select a payment order'))
46 if len(context['active_ids']) > 1:
47 raise orm.except_orm(
48 _('Error'),
49 _('Please only select a single payment order'))
50 vals['payment_order_id'] = context['active_ids'][0]
51 return super(banking_export_aggregate, self).create(
52 cr, uid, vals, context=context)
53
54 def reconcile_lines(self, cr, uid, move_line_ids, context=None):
55 """
56 Reconcile move lines lines, really. ERP core functionality.
57 """
58 reconcile_obj = self.pool.get('account.move.reconcile')
59 account_move_line_obj = self.pool.get('account.move.line')
60 currency_obj = self.pool.get('res.currency')
61 lines = account_move_line_obj.browse(cr, uid, move_line_ids, context=context)
62
63 for line in lines[1:]:
64 if line.account_id != lines[0].account_id:
65 raise orm.except_orm(
66 _('Error'),
67 _('Cannot reconcile between different accounts'))
68
69 if any([line.reconcile_id and line.reconcile_id.line_id
70 for line in lines]):
71 raise orm.except_orm(
72 _('Error'),
73 _('Line is already fully reconciled'))
74
75 currency = lines[0].company_id.currency_id
76
77 partials = []
78 line_ids = []
79 for line in lines:
80 if line.id not in line_ids:
81 line_ids.append(line.id)
82 if line.reconcile_partial_id:
83 line_ids += line.reconcile_partial_id.line_partial_ids
84 if line.reconcile_partial_id.id not in partials:
85 partials.append(line.reconcile_partial_id.id)
86
87 total = account_move_line_obj.get_balance(cr, uid, line_ids)
88 is_zero = currency_obj.is_zero(cr, uid, currency, total)
89
90 vals = {
91 'type': 'auto',
92 'line_id': is_zero and [(6, 0, line_ids)] or [(6, 0, [])],
93 'line_partial_ids': is_zero and [(6, 0, [])] or [(6, 0, line_ids)],
94 }
95
96 if partials:
97 if len(partials) > 1:
98 reconcile_obj.unlink(
99 cr, uid, partials[1:], context=context)
100 reconcile_obj.write(
101 cr, uid, partials[0],
102 vals, context=context)
103 else:
104 reconcile_obj.create(
105 cr, uid, vals, context=context)
106
107 for line_id in line_ids:
108 netsvc.LocalService("workflow").trg_trigger(
109 uid, 'account.move.line', line_id, cr)
110 return True
111
112 def create_aggregate_order(self, cr, uid, ids, context=None):
113 wiz = self.browse(cr, uid, ids[0], context=context)
114 account_move_line_obj = self.pool.get('account.move.line')
115 account_move_obj = self.pool.get('account.move')
116 payment_order_obj = self.pool.get('payment.order')
117 payment_order_line_obj = self.pool.get('payment.line')
118 payment_order_ids = context.get('active_ids', [])
119 if not payment_order_ids:
120 raise orm.except_orm(
121 _('Error'),
122 _('Please select a payment order'))
123 if len(payment_order_ids) > 1:
124 raise orm.except_orm(
125 _('Error'),
126 _('This operation can only be performed on a single '
127 'payment order'))
128
129 today = fields.date.context_today(self, cr, uid, context=context)
130 order = payment_order_obj.browse(
131 cr, uid, payment_order_ids[0], context=context)
132
133 move_id = account_move_obj.create(cr, uid, {
134 'journal_id': order.mode.transfer_journal_id.id,
135 'ref': _('Aggregate Payment Order %s') % order.reference,
136 }, context=context)
137
138 counter_move_line_ids = []
139 for line in order.line_ids:
140 # basic checks
141 if not line.move_line_id:
142 raise orm.except_orm(
143 _('Error'),
144 _('No move line provided for line %s') % line.name)
145 if line.move_line_id.reconcile_id:
146 raise orm.except_orm(
147 _('Error'),
148 _('Move line %s has already been paid/reconciled') %
149 line.move_line_id.name
150 )
151
152 # TODO: take multicurrency into account?
153
154 # create the move line on the transfer account
155 vals = {
156 'name': _('Transit %s') % (
157 line.move_line_id.invoice and
158 line.move_line_id.invoice.number or
159 line.move_line_id.ref),
160 'move_id': move_id,
161 'partner_id': line.partner_id and line.partner_id.id or False,
162 'account_id': order.mode.transfer_account_id.id,
163 'credit': line.amount,
164 'debit': 0.0,
165 'date': today,
166 }
167 counter_move_line_id = account_move_line_obj.create(
168 cr, uid, vals, context=context)
169 counter_move_line_ids.append(counter_move_line_id)
170
171 # create the debit move line on the receivable account
172 vals.update({
173 'name': _('Reconciliation %s') % (
174 line.move_line_id.invoice and
175 line.move_line_id.invoice.number or
176 line.move_line_id.name),
177 'account_id': line.move_line_id.account_id.id,
178 'credit': 0.0,
179 'debit': line.amount,
180 })
181 reconcile_move_line_id = account_move_line_obj.create(
182 cr, uid, vals, context=context)
183
184 self.reconcile_lines(
185 cr, uid, [reconcile_move_line_id, line.move_line_id.id],
186 context=context)
187
188 total = account_move_line_obj.get_balance(
189 cr, uid, counter_move_line_ids)
190
191 vals = {
192 'name': _('Transit reconciliation'),
193 'move_id': move_id,
194 'partner_id': order.mode.aggregate_partner_id.id,
195 'account_id': order.mode.transfer_account_id.id,
196 'debit': total < 0 and -total or 0.0,
197 'credit': total >= 0 and total or 0.0,
198 'date': today,
199 }
200 aggregate_move_line_id = account_move_line_obj.create(
201 cr, uid, vals, context=context)
202
203 self.reconcile_lines(
204 cr, uid, counter_move_line_ids + [aggregate_move_line_id],
205 context=context)
206
207 # create the credit move line on the aggregate partner
208 vals.update({
209 'name': _('Amount payable'),
210 'account_id': order.mode.aggregate_partner_id.property_account_payable.id,
211 'partner_id': order.mode.aggregate_partner_id.id,
212 'debit': total >= 0 and total or 0.0,
213 'credit': total < 0 and -total or 0.0,
214 })
215
216 payable_move_line = account_move_line_obj.browse(
217 cr, uid,
218 account_move_line_obj.create(
219 cr, uid, vals, context=context),
220 context=context)
221
222 account_move_obj.post(cr, uid, [move_id], context=context)
223
224 wf_service = netsvc.LocalService('workflow')
225 wf_service.trg_validate(uid, 'payment.order', order.id, 'sent', cr)
226 wf_service.trg_validate(uid, 'payment.order', order.id, 'done', cr)
227 order.refresh()
228 if order.state != 'done':
229 raise orm.except_orm(
230 _('Error'),
231 _('Payment order workflow does not go into state "done"'))
232
233 payment_order_id = payment_order_obj.create(
234 cr, uid, {
235 'company_id': order.company_id.id,
236 'mode': order.mode.chained_mode_id.id,
237 }, context=context)
238
239 lines2bank = account_move_line_obj.line2bank(
240 cr, uid, [payable_move_line.id], order.mode.id, context)
241
242 payment_order_line_obj.create(cr, uid,{
243 'move_line_id': payable_move_line.id,
244 'amount_currency': payable_move_line.amount_to_pay,
245 'bank_id': lines2bank.get(payable_move_line.id),
246 'order_id': payment_order_id,
247 'partner_id': order.mode.aggregate_partner_id.id,
248 'communication': order.reference.replace('/', ''),
249 'communication2': False,
250 'state': 'structured',
251 'date': today,
252 'currency': (
253 line.move_line_id.journal_id.currency.id or
254 line.move_line_id.journal_id.company_id.currency_id.id),
255 }, context=context)
256
257 return {
258 'name': payment_order_obj._description,
259 'view_type': 'form',
260 'view_mode': 'form',
261 'res_model': payment_order_obj._name,
262 'domain': [],
263 'context': context,
264 'type': 'ir.actions.act_window',
265 'target': 'current',
266 'res_id': payment_order_id,
267 'nodestroy': True,
268 }
0269
=== added file 'account_banking_aggregate_payment/model/payment_mode.py'
--- account_banking_aggregate_payment/model/payment_mode.py 1970-01-01 00:00:00 +0000
+++ account_banking_aggregate_payment/model/payment_mode.py 2013-06-13 20:06:26 +0000
@@ -0,0 +1,35 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# This module copyright (C) 2013 Therp BV (<http://therp.nl>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from openerp.osv import orm, fields
23
24
25class payment_mode(orm.Model):
26 _inherit = "payment.mode"
27 _columns = {
28 'aggregate_partner_id': fields.many2one(
29 'res.partner', 'Aggregate payment beneficiary',
30 help="The single partner on the chained payment order",
31 ),
32 'chained_mode_id': fields.many2one(
33 'payment.mode', 'Chained payment mode',
34 help="The payment type of the chained payment order"),
35 }
036
=== added directory 'account_banking_aggregate_payment/view'
=== added file 'account_banking_aggregate_payment/view/export_aggregate.xml'
--- account_banking_aggregate_payment/view/export_aggregate.xml 1970-01-01 00:00:00 +0000
+++ account_banking_aggregate_payment/view/export_aggregate.xml 2013-06-13 20:06:26 +0000
@@ -0,0 +1,30 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <record id="banking_export_aggregate_view" model="ir.ui.view">
5 <field name="name">Export aggregate payment order</field>
6 <field name="model">banking.export.aggregate</field>
7 <field name="type">form</field>
8 <field name="arch" type="xml">
9 <form string="Export aggregate payment order">
10 <label string="When you confirm this order, the total
11 amount will be made payable to the partner
12 that has been set on the payment mode. A
13 new payment order will open in your screen
14 with this one payment."/>
15 <group col="2" colspan="1">
16 <button icon="gtk-close"
17 special="cancel"
18 string="Cancel"
19 />
20 <button icon="gtk-ok"
21 string="Create"
22 name="create_aggregate_order"
23 type="object"
24 />
25 </group>
26 </form>
27 </field>
28 </record>
29 </data>
30</openerp>
031
=== added file 'account_banking_aggregate_payment/view/payment_mode.xml'
--- account_banking_aggregate_payment/view/payment_mode.xml 1970-01-01 00:00:00 +0000
+++ account_banking_aggregate_payment/view/payment_mode.xml 2013-06-13 20:06:26 +0000
@@ -0,0 +1,52 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <record id="view_payment_mode_form" model="ir.ui.view">
5 <field name="name">Adaptations for aggregate payment modes</field>
6 <field name="model">payment.mode</field>
7 <field name="inherit_id"
8 ref="account_direct_debit.view_payment_mode_form"/>
9 <field name="type">form</field>
10 <field name="arch" type="xml">
11 <field name="payment_term_ids" position="after">
12 <group colspan="2" col="2" string="Aggregate payment"
13 attrs="{
14 'invisible': [
15 ('type', '!=',
16 %(account_banking_aggregate_payment.type_aggregate)d
17 )]}">
18 <field name="aggregate_partner_id"
19 attrs="{'required': [
20 ('type', '=',
21 %(account_banking_aggregate_payment.type_aggregate)d
22 )]}"
23 />
24 <field name="chained_mode_id"
25 attrs="{'required': [
26 ('type', '=',
27 %(account_banking_aggregate_payment.type_aggregate)d
28 )]}"
29 />
30 </group>
31 </field>
32
33 <field name="transfer_account_id" position="attributes">
34 <attribute name="attrs">{
35 'required': [
36 ('type', '=',
37 %(account_banking_aggregate_payment.type_aggregate)d
38 )]}</attribute>
39 </field>
40
41 <field name="transfer_journal_id" position="attributes">
42 <attribute name="attrs">{
43 'required': [
44 ('type', '=',
45 %(account_banking_aggregate_payment.type_aggregate)d
46 )]}</attribute>
47 </field>
48
49 </field>
50 </record>
51 </data>
52</openerp>

Subscribers

People subscribed via source and target branches