Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/banking-addons/ba70-aggregate_payment into lp:banking-addons/banking-addons-70.
Commit message: [MIG] Aggregate payment module Requested reviews: Banking Addons Core Editors (banking-addons-team) For more details, see: https://code.launchpad.net/~therp-nl/banking-addons/ba70-aggregate_payment/+merge/178466 -- https://code.launchpad.net/~therp-nl/banking-addons/ba70-aggregate_payment/+merge/178466 Your team Banking Addons Core Editors is requested to review the proposed merge of lp:~therp-nl/banking-addons/ba70-aggregate_payment into lp:banking-addons/banking-addons-70.
=== 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-08-04 17:37:29 +0000 @@ -0,0 +1,1 @@ +import model === 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-08-04 17:37:29 +0000 @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2013 Therp BV (<http://therp.nl>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## +{ + 'name': 'Account Banking Aggregate Payment', + 'version': '0.1.173', + 'license': 'AGPL-3', + 'author': 'Therp BV', + 'website': 'https://launchpad.net/banking-addons', + 'category': 'Banking addons', + 'depends': ['account_direct_debit'], + 'data': [ + 'data/payment_mode_type.xml', + 'view/payment_mode.xml', + 'view/export_aggregate.xml', + ], + 'description': ''' + 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. + ''', + 'active': False, +} === 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-08-04 17:37:29 +0000 @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record model="payment.mode.type" + id="type_aggregate"> + <field name="name">Aggregate payment</field> + <field name="code">AGGR</field> + <field name="suitable_bank_types" + eval="[(6, 0, (ref('base_iban.bank_iban'), + ref('base.bank_normal')))]" /> + <field name="ir_model_id" + ref="model_banking_export_aggregate"/> + </record> + + </data> +</openerp> === 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-08-04 17:37:29 +0000 @@ -0,0 +1,175 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_banking_aggregate_payment +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-06-13 19:35+0000\n" +"PO-Revision-Date: 2013-06-13 19:35+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_banking_aggregate_payment +#: view:payment.mode:0 +msgid "Aggregate payment" +msgstr "Aggregate payment" + +#. module: account_banking_aggregate_payment +#: view:banking.export.aggregate:0 +msgid "Create" +msgstr "Create" + +#. module: account_banking_aggregate_payment +#: help:payment.mode,aggregate_partner_id:0 +msgid "The single partner on the chained payment order" +msgstr "The single partner on the chained payment order" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:134 +#, python-format +msgid "Aggregate Payment Order %s" +msgstr "Aggregate Payment Order %s" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:230 +#, python-format +msgid "Payment order workflow does not go into state \"done\"" +msgstr "Payment order workflow does not go into state \"done\"" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:143 +#, python-format +msgid "No move line provided for line %s" +msgstr "No move line provided for line %s" + +#. module: account_banking_aggregate_payment +#: model:ir.model,name:account_banking_aggregate_payment.model_payment_mode +msgid "Payment Mode" +msgstr "Payment Mode" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:48 +#, python-format +msgid "Please only select a single payment order" +msgstr "Please only select a single payment order" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:147 +#, python-format +msgid "Move line %s has already been paid/reconciled" +msgstr "Move line %s has already been paid/reconciled" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:44 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:121 +#, python-format +msgid "Please select a payment order" +msgstr "Please select a payment order" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:125 +#, python-format +msgid "This operation can only be performed on a single payment order" +msgstr "This operation can only be performed on a single payment order" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:155 +#, python-format +msgid "Transit %s" +msgstr "Transit %s" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:191 +#, python-format +msgid "Transit reconciliation" +msgstr "Transit reconciliation" + +#. module: account_banking_aggregate_payment +#: view:banking.export.aggregate:0 +msgid "Export aggregate payment order" +msgstr "Export aggregate payment order" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:208 +#, python-format +msgid "Amount payable" +msgstr "Amount payable" + +#. module: account_banking_aggregate_payment +#: field:payment.mode,aggregate_partner_id:0 +msgid "Aggregate payment beneficiary" +msgstr "Aggregate payment beneficiary" + +#. module: account_banking_aggregate_payment +#: help:payment.mode,chained_mode_id:0 +msgid "The payment type of the chained payment order" +msgstr "The payment type of the chained payment order" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:43 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:47 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:65 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:71 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:120 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:124 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:142 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:146 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:229 +#, python-format +msgid "Error" +msgstr "Error" + +#. module: account_banking_aggregate_payment +#: model:ir.model,name:account_banking_aggregate_payment.model_banking_export_aggregate +msgid "Execute aggregate payment" +msgstr "Execute aggregate payment" + +#. module: account_banking_aggregate_payment +#: view:banking.export.aggregate:0 +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." +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." + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:172 +#, python-format +msgid "Reconciliation %s" +msgstr "Reconciliation %s" + +#. module: account_banking_aggregate_payment +#: field:banking.export.aggregate,reference:0 +msgid "Reference" +msgstr "Reference" + +#. module: account_banking_aggregate_payment +#: field:banking.export.aggregate,payment_order_id:0 +msgid "Payment order" +msgstr "Payment order" + +#. module: account_banking_aggregate_payment +#: field:payment.mode,chained_mode_id:0 +msgid "Chained payment mode" +msgstr "Chained payment mode" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:66 +#, python-format +msgid "Cannot reconcile between different accounts" +msgstr "Cannot reconcile between different accounts" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:72 +#, python-format +msgid "Line is already fully reconciled" +msgstr "Line is already fully reconciled" + +#. module: account_banking_aggregate_payment +#: view:banking.export.aggregate:0 +msgid "Cancel" +msgstr "Cancel" + === 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-08-04 17:37:29 +0000 @@ -0,0 +1,170 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_banking_aggregate_payment +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-06-13 19:35+0000\n" +"PO-Revision-Date: 2013-06-13 19:35+0000\n" +"Last-Translator: <[email protected]>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_banking_aggregate_payment +#: view:payment.mode:0 +msgid "Aggregate payment" +msgstr "Verzamelbetaalopdracht" + +#. module: account_banking_aggregate_payment +#: view:banking.export.aggregate:0 +msgid "Create" +msgstr "Aanmaken" + +#. module: account_banking_aggregate_payment +#: help:payment.mode,aggregate_partner_id:0 +msgid "The single partner on the chained payment order" +msgstr "De relatie die geldt als crediteur van het verzameld bedrag" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:134 +#, python-format +msgid "Aggregate Payment Order %s" +msgstr "Verzamelbetaling %s" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:230 +#, python-format +msgid "Payment order workflow does not go into state \"done\"" +msgstr "De workflow van de betaalopdracht komt niet in de status \"verwerkt\"" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:143 +#, python-format +msgid "No move line provided for line %s" +msgstr "Er is geen boeking voor regel %s" + +#. module: account_banking_aggregate_payment +#: model:ir.model,name:account_banking_aggregate_payment.model_payment_mode +msgid "Payment Mode" +msgstr "Betaalwijze" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:48 +#, python-format +msgid "Please only select a single payment order" +msgstr "Er kan maar één betaalopdracht worden geselecteerd" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:147 +#, python-format +msgid "Move line %s has already been paid/reconciled" +msgstr "Boekingsregel %s is al afgeletterd" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:44 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:121 +#, python-format +msgid "Please select a payment order" +msgstr "Selecteer alstublieft een betaalopdracht" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:125 +#, python-format +msgid "This operation can only be performed on a single payment order" +msgstr "Deze bewerking kan alleen worden uitgevoerd op een enkele betaalopdracht" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:155 +#, python-format +msgid "Transit %s" +msgstr "Tussenboeking %s" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:191 +#, python-format +msgid "Transit reconciliation" +msgstr "Aflettering tussenboeking" + +#. module: account_banking_aggregate_payment +#: view:banking.export.aggregate:0 +msgid "Export aggregate payment order" +msgstr "Verwerken een verzamelbetalingsopdracht" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:208 +#, python-format +msgid "Amount payable" +msgstr "Verschuldigd bedrag" + +#. module: account_banking_aggregate_payment +#: field:payment.mode,aggregate_partner_id:0 +msgid "Aggregate payment beneficiary" +msgstr "Begunstigde van de verzamelbetaling" + +#. module: account_banking_aggregate_payment +#: help:payment.mode,chained_mode_id:0 +msgid "The payment type of the chained payment order" +msgstr "De betaalwijze van de gekoppelde betaalopdracht" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:43 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:47 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:65 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:71 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:120 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:124 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:142 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:146 +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:229 +#, python-format +msgid "Error" +msgstr "Fout" + +#. module: account_banking_aggregate_payment +#: model:ir.model,name:account_banking_aggregate_payment.model_banking_export_aggregate +msgid "Execute aggregate payment" +msgstr "Verzamelbetaling boeken" + +#. module: account_banking_aggregate_payment +#: view:banking.export.aggregate:0 +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." +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." + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:172 +#, python-format +msgid "Reconciliation %s" +msgstr "Aflettering %s" + +#. module: account_banking_aggregate_payment +#: field:banking.export.aggregate,payment_order_id:0 +msgid "Payment order" +msgstr "Betaalopdracht" + +#. module: account_banking_aggregate_payment +#: field:payment.mode,chained_mode_id:0 +msgid "Chained payment mode" +msgstr "Gekoppelde betaalwijze" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:66 +#, python-format +msgid "Cannot reconcile between different accounts" +msgstr "Kan niet afletteren tussen verschillende grootboekrekeningen" + +#. module: account_banking_aggregate_payment +#: code:addons/account_banking_aggregate_payment/model/export_aggregate.py:72 +#, python-format +msgid "Line is already fully reconciled" +msgstr "De regel is al afgeletterd" + +#. module: account_banking_aggregate_payment +#: view:banking.export.aggregate:0 +msgid "Cancel" +msgstr "Annuleer" + === 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-08-04 17:37:29 +0000 @@ -0,0 +1,2 @@ +import payment_mode +import export_aggregate === 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-08-04 17:37:29 +0000 @@ -0,0 +1,252 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2013 Therp BV (<http://therp.nl>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from openerp.osv import orm, fields +from openerp.tools.translate import _ +from openerp import netsvc + + +class banking_export_aggregate(orm.TransientModel): + _name = 'banking.export.aggregate' + _description = 'Execute aggregate payment order' + _rec_name = 'payment_order_id' + + _columns = { + 'payment_order_id': fields.many2one( + 'payment.order', 'Payment order', + required=True), + } + + def create(self, cr, uid, vals, context=None): + if context is None: + context = {} + if not vals.get('payment_order_id'): + if not context.get('active_ids'): + raise orm.except_orm( + _('Error'), + _('Please select a payment order')) + if len(context['active_ids']) > 1: + raise orm.except_orm( + _('Error'), + _('Please only select a single payment order')) + vals['payment_order_id'] = context['active_ids'][0] + return super(banking_export_aggregate, self).create( + cr, uid, vals, context=context) + + def reconcile_lines(self, cr, uid, move_line_ids, context=None): + """ + Reconcile move lines lines, really. ERP core functionality. + """ + reconcile_obj = self.pool.get('account.move.reconcile') + account_move_line_obj = self.pool.get('account.move.line') + currency_obj = self.pool.get('res.currency') + lines = account_move_line_obj.browse(cr, uid, move_line_ids, context=context) + + for line in lines[1:]: + if line.account_id != lines[0].account_id: + raise orm.except_orm( + _('Error'), + _('Cannot reconcile between different accounts')) + + if any([line.reconcile_id and line.reconcile_id.line_id + for line in lines]): + raise orm.except_orm( + _('Error'), + _('Line is already fully reconciled')) + + currency = lines[0].company_id.currency_id + + partials = [] + line_ids = [] + for line in lines: + if line.id not in line_ids: + line_ids.append(line.id) + if line.reconcile_partial_id: + line_ids += line.reconcile_partial_id.line_partial_ids + if line.reconcile_partial_id.id not in partials: + partials.append(line.reconcile_partial_id.id) + + total = account_move_line_obj.get_balance(cr, uid, line_ids) + is_zero = currency_obj.is_zero(cr, uid, currency, total) + + vals = { + 'type': 'auto', + 'line_id': is_zero and [(6, 0, line_ids)] or [(6, 0, [])], + 'line_partial_ids': is_zero and [(6, 0, [])] or [(6, 0, line_ids)], + } + + if partials: + if len(partials) > 1: + reconcile_obj.unlink( + cr, uid, partials[1:], context=context) + reconcile_obj.write( + cr, uid, partials[0], + vals, context=context) + else: + reconcile_obj.create( + cr, uid, vals, context=context) + + for line_id in line_ids: + netsvc.LocalService("workflow").trg_trigger( + uid, 'account.move.line', line_id, cr) + return True + + def create_aggregate_order(self, cr, uid, ids, context=None): + wf_service = netsvc.LocalService('workflow') + + def wf_trigger_check(order, state): + wf_service.trg_validate(uid, 'payment.order', order.id, state, cr) + order.refresh() + if order.state != state: + raise orm.except_orm( + _('Error'), + _('Payment order workflow does not go into state ' + '"%s"') % state) + + account_move_line_obj = self.pool.get('account.move.line') + account_move_obj = self.pool.get('account.move') + payment_order_obj = self.pool.get('payment.order') + payment_order_line_obj = self.pool.get('payment.line') + payment_order_ids = context.get('active_ids', []) + if not payment_order_ids: + raise orm.except_orm( + _('Error'), + _('Please select a payment order')) + if len(payment_order_ids) > 1: + raise orm.except_orm( + _('Error'), + _('This operation can only be performed on a single ' + 'payment order')) + + today = fields.date.context_today(self, cr, uid, context=context) + order = payment_order_obj.browse( + cr, uid, payment_order_ids[0], context=context) + + wf_trigger_check(order, 'sent') + + move_id = account_move_obj.create(cr, uid, { + 'journal_id': order.mode.transfer_journal_id.id, + 'ref': _('Aggregate Payment Order %s') % order.reference, + }, context=context) + + line_ids = [] + for order_line in order.line_ids: + for line in order_line.transit_move_line_id.move_id.line_id: + if line.account_id.type == 'other': + account_id = line.account_id.id + if line.reconcile_id: + raise orm.except_orm( + _('Error'), + _('Transfer move line %s has already been ' + 'paid/reconciled') % + line.name + ) + line_ids.append(line.id) + + # TODO: take multicurrency into account? + + total = account_move_line_obj.get_balance( + cr, uid, line_ids) + + # Write the aggregate partner on the order's counter move line + account_move_line_obj.write( + cr, uid, line_ids, + {'partner_id': order.mode.aggregate_partner_id.id}, + context=context) + + # Create the counter move to the order's transit move line + # and reconcile + vals = { + 'name': _('Transfer reconciliation'), + 'move_id': move_id, + 'partner_id': order.mode.aggregate_partner_id.id, + 'account_id': account_id, + 'debit': total < 0 and -total or 0.0, + 'credit': total >= 0 and total or 0.0, + 'date': today, + } + + aggregate_move_line_id = account_move_line_obj.create( + cr, uid, vals, context=context) + + self.reconcile_lines( + cr, uid, line_ids + [aggregate_move_line_id], + context=context) + + destination_account_id = ( + order.mode.aggregate_partner_id.property_account_receivable.id + if order.payment_order_type == 'debit' + else order.mode.aggregate_partner_id.property_account_payable.id) + + # create the credit move line on the aggregate partner + vals.update({ + 'name': _('Amount payable'), + 'account_id': destination_account_id, + 'partner_id': order.mode.aggregate_partner_id.id, + 'debit': total >= 0 and total or 0.0, + 'credit': total < 0 and -total or 0.0, + }) + + payable_move_line = account_move_line_obj.browse( + cr, uid, + account_move_line_obj.create( + cr, uid, vals, context=context), + context=context) + + account_move_obj.post(cr, uid, [move_id], context=context) + + wf_trigger_check(order, 'done') + + payment_order_id = payment_order_obj.create( + cr, uid, { + 'company_id': order.company_id.id, + 'mode': order.mode.chained_mode_id.id, + }, context=context) + + lines2bank = account_move_line_obj.line2bank( + cr, uid, [payable_move_line.id], order.mode.id, context) + + payment_order_line_obj.create(cr, uid,{ + 'move_line_id': payable_move_line.id, + 'amount_currency': payable_move_line.amount_to_pay, + 'bank_id': lines2bank.get(payable_move_line.id), + 'order_id': payment_order_id, + 'partner_id': order.mode.aggregate_partner_id.id, + 'communication': order.reference.replace('/', ''), + 'communication2': False, + 'state': 'structured', + 'date': today, + 'currency': ( + order.company_id.currency_id.id), + }, context=context) + + return { + 'name': payment_order_obj._description, + 'view_type': 'form', + 'view_mode': 'form', + 'res_model': payment_order_obj._name, + 'domain': [], + 'context': context, + 'type': 'ir.actions.act_window', + 'target': 'current', + 'res_id': payment_order_id, + 'nodestroy': True, + } === 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-08-04 17:37:29 +0000 @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2013 Therp BV (<http://therp.nl>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from openerp.osv import orm, fields + + +class payment_mode(orm.Model): + _inherit = "payment.mode" + _columns = { + 'aggregate_partner_id': fields.many2one( + 'res.partner', 'Aggregate payment beneficiary', + help="The single partner on the chained payment order", + ), + 'chained_mode_id': fields.many2one( + 'payment.mode', 'Chained payment mode', + help="The payment type of the chained payment order"), + } === 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-08-04 17:37:29 +0000 @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="banking_export_aggregate_view" model="ir.ui.view"> + <field name="name">Export aggregate payment order</field> + <field name="model">banking.export.aggregate</field> + <field name="arch" type="xml"> + <form string="Export aggregate payment order"> + <label string="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."/> + <group col="2" colspan="1"> + <button icon="gtk-close" + special="cancel" + string="Cancel" + /> + <button icon="gtk-ok" + string="Create" + name="create_aggregate_order" + type="object" + /> + </group> + </form> + </field> + </record> + </data> +</openerp> === 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-08-04 17:37:29 +0000 @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + <record id="view_payment_mode_form" model="ir.ui.view"> + <field name="name">Adaptations for aggregate payment modes</field> + <field name="model">payment.mode</field> + <field name="inherit_id" + ref="account_banking_payment.view_payment_mode_form_inherit"/> + <field name="arch" type="xml"> + <field name="payment_term_ids" position="after"> + <group colspan="2" col="2" string="Aggregate payment" + attrs="{ + 'invisible': [ + ('type', '!=', + %(account_banking_aggregate_payment.type_aggregate)d + )]}"> + <field name="aggregate_partner_id" + attrs="{'required': [ + ('type', '=', + %(account_banking_aggregate_payment.type_aggregate)d + )]}" + /> + <field name="chained_mode_id" + attrs="{'required': [ + ('type', '=', + %(account_banking_aggregate_payment.type_aggregate)d + )]}" + /> + </group> + </field> + + <field name="transfer_account_id" position="attributes"> + <attribute name="attrs">{ + 'required': [ + ('type', '=', + %(account_banking_aggregate_payment.type_aggregate)d + )]}</attribute> + </field> + + <field name="transfer_journal_id" position="attributes"> + <attribute name="attrs">{ + 'required': [ + ('type', '=', + %(account_banking_aggregate_payment.type_aggregate)d + )]}</attribute> + </field> + + </field> + </record> + </data> +</openerp> === modified file 'account_banking_payment/model/account_payment.py' --- account_banking_payment/model/account_payment.py 2013-07-15 13:31:34 +0000 +++ account_banking_payment/model/account_payment.py 2013-08-04 17:37:29 +0000 @@ -280,8 +280,8 @@ account_move_line_obj = self.pool.get('account.move.line') payment_line_obj = self.pool.get('payment.line') labels = { - 'payment': _('Payment order'), - 'debit': _('Direct debit order'), + 'payment': _('Payment'), + 'debit': _('Direct debit'), } for order in self.browse(cr, uid, ids, context=context): for line in order.line_ids: @@ -299,9 +299,10 @@ move_id = account_move_obj.create(cr, uid, { 'journal_id': order.mode.transfer_journal_id.id, - 'name': '%s %s' % (labels[order.payment_order_type], - line.move_line_id.move_id.name), - 'reference': '%s%s' % (order.payment_order_type[:3].upper(), + 'name': '%s %s (%s)' % (labels[order.payment_order_type], + line.move_line_id.move_id.name, + order.reference), + 'ref': '%s/%s' % (order.payment_order_type[:3].upper(), line.move_line_id.move_id.name), }, context=context) @@ -309,11 +310,7 @@ # create the debit move line on the transfer account vals = { - 'name': _('%s for %s') % ( - labels[order.payment_order_type], - line.move_line_id.invoice and - line.move_line_id.invoice.number or - line.move_line_id.name), + 'name': _('Transfer'), 'move_id': move_id, 'partner_id': False, 'account_id': order.mode.transfer_account_id.id, @@ -329,6 +326,7 @@ # create the debit move line on the receivable account vals.update({ + 'name': _('Reconciliation'), 'partner_id': line.partner_id.id, 'account_id': line.move_line_id.account_id.id, 'credit': (order.payment_order_type == 'debit'
-- Mailing list: https://launchpad.net/~banking-addons-team Post to : [email protected] Unsubscribe : https://launchpad.net/~banking-addons-team More help : https://help.launchpad.net/ListHelp

