diff --git a/account_banking_aggregate_payment/data/payment_mode_type.xml b/account_banking_aggregate_payment/data/payment_mode_type.xml index 793aab521..564b9744c 100644 --- a/account_banking_aggregate_payment/data/payment_mode_type.xml +++ b/account_banking_aggregate_payment/data/payment_mode_type.xml @@ -3,35 +3,14 @@ - Aggregate payment order for all accounts - AGG_ALL + id="type_aggregate"> + Aggregate payment order + AGGR - - - Aggregate payment order for IBAN accounts - AGG_IBAN - - - - - - Aggregate payment order for domestic accounts - AGG_DMST - - - - diff --git a/account_banking_aggregate_payment/model/export_aggregate.py b/account_banking_aggregate_payment/model/export_aggregate.py index bc69c541b..45c1cd8ef 100644 --- a/account_banking_aggregate_payment/model/export_aggregate.py +++ b/account_banking_aggregate_payment/model/export_aggregate.py @@ -23,6 +23,7 @@ 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' _columns = { @@ -51,7 +52,7 @@ class banking_export_aggregate(orm.TransientModel): def reconcile_lines(self, cr, uid, move_line_ids, context=None): """ - Reconcile move lines lines, really. Talk about core functionality + 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') @@ -121,15 +122,12 @@ class banking_export_aggregate(orm.TransientModel): if len(payment_order_ids) > 1: raise orm.except_orm( _('Error'), - _('This operation can only be performed on a single payment order')) + _('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) - if not (order.mode.transfer_journal_id and - order.mode.transfer_account_id): - raise orm.except_orm( - _('Error'), - _('Transfer journal or account are not filled ' - 'in on the payment mode')) move_id = account_move_obj.create(cr, uid, { 'journal_id': order.mode.transfer_journal_id.id, @@ -151,7 +149,7 @@ class banking_export_aggregate(orm.TransientModel): line.move_line_id.name ) - # TODO: take multicurrency into account + # TODO: take multicurrency into account? # create the move line on the transfer account vals = { @@ -164,7 +162,7 @@ class banking_export_aggregate(orm.TransientModel): 'account_id': order.mode.transfer_account_id.id, 'credit': line.amount, 'debit': 0.0, - 'date': fields.date.context_today(self, cr, uid, context=context), + 'date': today, } counter_move_line_id = account_move_line_obj.create( cr, uid, vals, context=context) @@ -187,7 +185,7 @@ class banking_export_aggregate(orm.TransientModel): cr, uid, counter_move_line_ids) vals = { - 'name': 'Aggregate payment for %s' % ( + 'name': _('Aggregate payment for %s') % ( line.move_line_id.invoice and line.move_line_id.invoice.number or line.move_line_id.name), @@ -196,11 +194,13 @@ class banking_export_aggregate(orm.TransientModel): 'account_id': order.mode.transfer_account_id.id, 'debit': total < 0 and -total or 0.0, 'credit': total >= 0 and total or 0.0, - 'date': fields.date.context_today(self, cr, uid, context=context), + 'date': today, } aggregate_move_line_id = account_move_line_obj.create( cr, uid, vals, context=context) + account_move_obj.post(cr, uid, [move_id], context=context) + self.reconcile_lines( cr, uid, counter_move_line_ids + [aggregate_move_line_id], context=context) @@ -219,7 +219,6 @@ class banking_export_aggregate(orm.TransientModel): cr, uid, vals, context=context), context=context) - account_move_obj.post(cr, uid, [move_id], context=context) wf_service = netsvc.LocalService('workflow') wf_service.trg_validate(uid, 'payment.order', order.id, 'sent', cr) @@ -245,10 +244,10 @@ class banking_export_aggregate(orm.TransientModel): 'bank_id': lines2bank.get(payable_move_line.id), 'order_id': payment_order_id, 'partner_id': order.mode.aggregate_partner_id.id, - 'communication': payable_move_line.ref, + 'communication': (payable_move_line.ref or '').replace('/', ''), 'communication2': False, 'state': 'structured', - 'date': False, + 'date': today, 'currency': ( line.move_line_id.journal_id.currency.id or line.move_line_id.journal_id.company_id.currency_id.id), diff --git a/account_banking_aggregate_payment/model/payment_mode.py b/account_banking_aggregate_payment/model/payment_mode.py index dc4bf21e8..8ca89b604 100644 --- a/account_banking_aggregate_payment/model/payment_mode.py +++ b/account_banking_aggregate_payment/model/payment_mode.py @@ -26,9 +26,10 @@ class payment_mode(orm.Model): _inherit = "payment.mode" _columns = { 'aggregate_partner_id': fields.many2one( - 'res.partner', 'Aggregate partner id', + 'res.partner', 'Aggregate payment beneficiary', + help="The single partner on the chained payment order", ), 'chained_mode_id': fields.many2one( - 'payment.mode', 'Chained payment mode'), + 'payment.mode', 'Chained payment mode', + help="The payment type of the chained payment order"), } - diff --git a/account_banking_aggregate_payment/view/payment_mode.xml b/account_banking_aggregate_payment/view/payment_mode.xml index 8504027b3..dafa1f7ff 100644 --- a/account_banking_aggregate_payment/view/payment_mode.xml +++ b/account_banking_aggregate_payment/view/payment_mode.xml @@ -5,21 +5,47 @@ Adaptations for aggregate payment modes payment.mode + ref="account_direct_debit.view_payment_mode_form"/> form - - - - + + + + + + + { + 'required': [ + ('type', '=', + %(account_banking_aggregate_payment.type_aggregate)d + )]} + + + + { + 'required': [ + ('type', '=', + %(account_banking_aggregate_payment.type_aggregate)d + )]} + +