mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MRG] account_banking_payment_export
Refactoring of account_banking_payment to provide payment export infrastructure independently of bank statement reconciliation features.
This commit is contained in:
@@ -32,17 +32,14 @@
|
||||
'category': 'Banking addons',
|
||||
'depends': [
|
||||
'account_banking',
|
||||
'account_payment',
|
||||
'account_banking_payment_export',
|
||||
],
|
||||
'data': [
|
||||
'view/account_payment.xml',
|
||||
'view/banking_transaction_wizard.xml',
|
||||
'view/payment_mode.xml',
|
||||
'view/payment_mode_type.xml',
|
||||
'view/bank_payment_manual.xml',
|
||||
'data/payment_mode_type.xml',
|
||||
'workflow/account_payment.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'description': '''
|
||||
This addon adds payment infrastructure to the Banking Addons.
|
||||
|
||||
@@ -5,5 +5,4 @@ import payment_mode_type
|
||||
import payment_order_create
|
||||
import banking_import_transaction
|
||||
import banking_transaction_wizard
|
||||
import bank_payment_manual
|
||||
import banking_import_line
|
||||
|
||||
@@ -115,49 +115,6 @@ class payment_order(orm.Model):
|
||||
'payment_order_type': 'payment',
|
||||
}
|
||||
|
||||
def launch_wizard(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Search for a wizard to launch according to the type.
|
||||
If type is manual. just confirm the order.
|
||||
Previously (pre-v6) in account_payment/wizard/wizard_pay.py
|
||||
"""
|
||||
if context == None:
|
||||
context = {}
|
||||
result = {}
|
||||
orders = self.browse(cr, uid, ids, context)
|
||||
order = orders[0]
|
||||
# check if a wizard is defined for the first order
|
||||
if order.mode.type and order.mode.type.ir_model_id:
|
||||
context['active_ids'] = ids
|
||||
wizard_model = order.mode.type.ir_model_id.model
|
||||
wizard_obj = self.pool.get(wizard_model)
|
||||
wizard_id = wizard_obj.create(cr, uid, {}, context)
|
||||
result = {
|
||||
'name': wizard_obj._description or _('Payment Order Export'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': wizard_model,
|
||||
'domain': [],
|
||||
'context': context,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'res_id': wizard_id,
|
||||
'nodestroy': True,
|
||||
}
|
||||
else:
|
||||
# should all be manual orders without type or wizard model
|
||||
for order in orders[1:]:
|
||||
if order.mode.type and order.mode.type.ir_model_id:
|
||||
raise orm.except_orm(
|
||||
_('Error'),
|
||||
_('You can only combine payment orders of the same type')
|
||||
)
|
||||
# process manual payments
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
for order_id in ids:
|
||||
wf_service.trg_validate(uid, 'payment.order', order_id, 'sent', cr)
|
||||
return result
|
||||
|
||||
def _write_payment_lines(self, cr, uid, ids, **kwargs):
|
||||
'''
|
||||
ORM method for setting attributes of corresponding payment.line objects.
|
||||
|
||||
@@ -27,28 +27,9 @@ from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class payment_mode(orm.Model):
|
||||
''' Restoring the payment type from version 5,
|
||||
used to select the export wizard (if any) '''
|
||||
_inherit = "payment.mode"
|
||||
|
||||
def suitable_bank_types(self, cr, uid, payment_mode_id=None, context=None):
|
||||
""" Reinstates functional code for suitable bank type filtering.
|
||||
Current code in account_payment is disfunctional.
|
||||
"""
|
||||
res = []
|
||||
payment_mode = self.browse(
|
||||
cr, uid, payment_mode_id, context)
|
||||
if (payment_mode and payment_mode.type and
|
||||
payment_mode.type.suitable_bank_types):
|
||||
res = [type.code for type in payment_mode.type.suitable_bank_types]
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'type': fields.many2one(
|
||||
'payment.mode.type', 'Payment type',
|
||||
required=True,
|
||||
help='Select the Payment Type for the Payment Mode.'
|
||||
),
|
||||
'transfer_account_id': fields.many2one(
|
||||
'account.account', 'Transfer account',
|
||||
domain=[('type', '=', 'other'),
|
||||
|
||||
@@ -27,30 +27,9 @@ from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class payment_mode_type(orm.Model):
|
||||
_name = 'payment.mode.type'
|
||||
_description = 'Payment Mode Type'
|
||||
_inherit = 'payment.mode.type'
|
||||
|
||||
_columns = {
|
||||
'name': fields.char(
|
||||
'Name', size=64, required=True,
|
||||
help='Payment Type'
|
||||
),
|
||||
'code': fields.char(
|
||||
'Code', size=64, required=True,
|
||||
help='Specify the Code for Payment Type'
|
||||
),
|
||||
# Setting suitable_bank_types to required pending
|
||||
# https://bugs.launchpad.net/openobject-addons/+bug/786845
|
||||
'suitable_bank_types': fields.many2many(
|
||||
'res.partner.bank.type',
|
||||
'bank_type_payment_type_rel',
|
||||
'pay_type_id','bank_type_id',
|
||||
'Suitable bank types', required=True),
|
||||
'ir_model_id': fields.many2one(
|
||||
'ir.model', 'Payment wizard',
|
||||
help=('Select the Payment Wizard for payments of this type. '
|
||||
'Leave empty for manual processing'),
|
||||
domain=[('osv_memory', '=', True)],
|
||||
),
|
||||
'payment_order_type': fields.selection(
|
||||
[('payment', 'Payment'),('debit', 'Direct debit')],
|
||||
'Payment order type', required=True,
|
||||
|
||||
@@ -23,9 +23,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from datetime import datetime
|
||||
from openerp.osv import orm, fields
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
'invisible':[('state','!=','draft')]
|
||||
}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//button[@string='Make Payments']"
|
||||
position="attributes">
|
||||
<attribute name="name">launch_wizard</attribute>
|
||||
</xpath>
|
||||
<!-- Communication only used for 'structured' communication -->
|
||||
<xpath expr="//field[@name='line_ids']/form//field[@name='communication']"
|
||||
position="attributes">
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_payment_manual_form" model="ir.ui.view">
|
||||
<field name="name">Form for manual payment wizard</field>
|
||||
<field name="model">payment.manual</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Manual payment">
|
||||
<label string="Payment order(s) have been set to 'sent'"/>
|
||||
<button special="cancel" icon="gtk-ok" string="OK"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -8,10 +8,9 @@
|
||||
<record id="view_payment_mode_form_inherit" model="ir.ui.view">
|
||||
<field name="name">payment.mode.form.inherit</field>
|
||||
<field name="model">payment.mode</field>
|
||||
<field name="inherit_id" ref="account_payment.view_payment_mode_form"/>
|
||||
<field name="inherit_id" ref="account_banking_payment_export.view_payment_mode_form_inherit"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="company_id" position="after">
|
||||
<field name="type"/>
|
||||
<field name="type" position="after">
|
||||
<group colspan="4" col="4">
|
||||
<group colspan="2">
|
||||
<separator colspan="2"
|
||||
|
||||
@@ -2,29 +2,14 @@
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_payment_mode_tree_inherit" model="ir.ui.view">
|
||||
<field name="name">payment.mode.tree.inherit</field>
|
||||
<field name="model">payment.mode</field>
|
||||
<field name="inherit_id" ref="account_payment.view_payment_mode_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="company_id" position="after">
|
||||
<field name="type"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- basic view for payment mode type -->
|
||||
<record model="ir.ui.view" id="view_payment_mode_type_form">
|
||||
<record model="ir.ui.view" id="view_payment_mode_type_form_inherit">
|
||||
<field name="name">view.payment.mode.type.form</field>
|
||||
<field name="model">payment.mode.type</field>
|
||||
<field name="inherit_id" ref="account_banking_payment_export.view_payment_mode_type_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Payment mode">
|
||||
<field name="name" />
|
||||
<field name="code" />
|
||||
<field name="suitable_bank_types"/>
|
||||
<field name="payment_order_type"/>
|
||||
<field name="ir_model_id"/>
|
||||
</form>
|
||||
<field name="suitable_bank_types" position="after">
|
||||
<field name="payment_order_type"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -29,6 +29,12 @@ write({'state':'rejected'})</field>
|
||||
<field name="act_to" ref="account_banking.act_sent"/>
|
||||
<field name="signal">sent</field>
|
||||
</record>
|
||||
<!-- the done signal continues to work but goes to sent -->
|
||||
<record id="account_banking.trans_open_done" model="workflow.transition">
|
||||
<field name="act_from" ref="account_payment.act_open"/>
|
||||
<field name="act_to" ref="account_banking.act_sent"/>
|
||||
<field name="signal">done</field>
|
||||
</record>
|
||||
<!-- From sent straight to sent_wait -->
|
||||
<record id="account_banking.trans_sent_sent_wait" model="workflow.transition">
|
||||
<field name="act_from" ref="account_banking.act_sent"/>
|
||||
|
||||
1
account_banking_payment_export/__init__.py
Normal file
1
account_banking_payment_export/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import model
|
||||
69
account_banking_payment_export/__openerp__.py
Normal file
69
account_banking_payment_export/__openerp__.py
Normal file
@@ -0,0 +1,69 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
|
||||
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
|
||||
#
|
||||
# All other contributions are (C) by their respective contributors
|
||||
#
|
||||
# All Rights Reserved
|
||||
#
|
||||
# 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 - Payments Export Infrastructure',
|
||||
'version': '0.1.164',
|
||||
'license': 'AGPL-3',
|
||||
'author': 'Banking addons community',
|
||||
'website': 'https://launchpad.net/banking-addons',
|
||||
'category': 'Banking addons',
|
||||
'depends': [
|
||||
'account_payment',
|
||||
'base_iban', # for manual_bank_tranfer
|
||||
],
|
||||
'conflicts': [
|
||||
# lp:account-payment/account_payment_extension also adds
|
||||
# a type field to payment.mode, with a very similar purpose.
|
||||
# We can't add a dependency on account_payment_extension here
|
||||
# because account_payment_extension adds many other features
|
||||
# that probably conflict with other parts of lp:banking-addons.
|
||||
# Proposal to resolve: make account_payment_extension depend
|
||||
# on the present account_banking_payment_export module.
|
||||
'account_payment_extension',
|
||||
],
|
||||
'data': [
|
||||
'view/account_payment.xml',
|
||||
'view/bank_payment_manual.xml',
|
||||
'view/payment_mode.xml',
|
||||
'view/payment_mode_type.xml',
|
||||
'data/payment_mode_type.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'description': '''
|
||||
Infrastructure to export payment orders.
|
||||
|
||||
This technical module provides the base infrastructure to export
|
||||
payment orders for electronic banking. It provides the following
|
||||
technical features:
|
||||
* a new payment.mode.type model
|
||||
* payment.mode now has a mandatory type
|
||||
* a better implementation of payment_mode.suitable_bank_types() based on payment.mode.type
|
||||
* the "make payment" button launches a wizard depending on the payment.mode.type
|
||||
* a manual payment mode type is provided as an example, with a default "do nothing" wizard
|
||||
''',
|
||||
'auto_install': True,
|
||||
'installable': True,
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- Add manual bank transfer as default payment option -->
|
||||
<record model="payment.mode.type" id="account_banking.manual_bank_tranfer">
|
||||
<record model="payment.mode.type" id="manual_bank_tranfer">
|
||||
<field name="name">Manual Bank Transfer</field>
|
||||
<field name="code">BANKMAN</field>
|
||||
<field name="suitable_bank_types"
|
||||
eval="[(6,0,[ref('base.bank_normal'),ref('base_iban.bank_iban'),])]" />
|
||||
<field name="ir_model_id"
|
||||
ref="account_banking_payment.model_payment_manual"/>
|
||||
ref="model_payment_manual"/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
5
account_banking_payment_export/model/__init__.py
Normal file
5
account_banking_payment_export/model/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from . import account_payment
|
||||
from . import bank_payment_manual
|
||||
from . import payment_mode
|
||||
from . import payment_mode_type
|
||||
from . import payment_order_create
|
||||
75
account_banking_payment_export/model/account_payment.py
Normal file
75
account_banking_payment_export/model/account_payment.py
Normal file
@@ -0,0 +1,75 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
|
||||
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
|
||||
#
|
||||
# All other contributions are (C) by their respective contributors
|
||||
#
|
||||
# All Rights Reserved
|
||||
#
|
||||
# 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
|
||||
from openerp.tools.translate import _
|
||||
from openerp import netsvc
|
||||
|
||||
|
||||
class payment_order(orm.Model):
|
||||
_inherit = 'payment.order'
|
||||
|
||||
def launch_wizard(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Search for a wizard to launch according to the type.
|
||||
If type is manual. just confirm the order.
|
||||
Previously (pre-v6) in account_payment/wizard/wizard_pay.py
|
||||
"""
|
||||
if context == None:
|
||||
context = {}
|
||||
result = {}
|
||||
orders = self.browse(cr, uid, ids, context)
|
||||
order = orders[0]
|
||||
# check if a wizard is defined for the first order
|
||||
if order.mode.type and order.mode.type.ir_model_id:
|
||||
context['active_ids'] = ids
|
||||
wizard_model = order.mode.type.ir_model_id.model
|
||||
wizard_obj = self.pool.get(wizard_model)
|
||||
wizard_id = wizard_obj.create(cr, uid, {}, context)
|
||||
result = {
|
||||
'name': wizard_obj._description or _('Payment Order Export'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': wizard_model,
|
||||
'domain': [],
|
||||
'context': context,
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'res_id': wizard_id,
|
||||
'nodestroy': True,
|
||||
}
|
||||
else:
|
||||
# should all be manual orders without type or wizard model
|
||||
for order in orders[1:]:
|
||||
if order.mode.type and order.mode.type.ir_model_id:
|
||||
raise orm.except_orm(
|
||||
_('Error'),
|
||||
_('You can only combine payment orders of the same type')
|
||||
)
|
||||
# process manual payments
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
for order_id in ids:
|
||||
wf_service.trg_validate(uid, 'payment.order', order_id, 'done', cr)
|
||||
return result
|
||||
@@ -24,7 +24,7 @@
|
||||
##############################################################################
|
||||
|
||||
'''
|
||||
This module contains a single "wizard" for including a 'sent' state for manual
|
||||
This module contains a single "wizard" for confirming manual
|
||||
bank transfers.
|
||||
'''
|
||||
|
||||
@@ -34,20 +34,26 @@ from openerp import netsvc
|
||||
|
||||
class payment_manual(orm.TransientModel):
|
||||
_name = 'payment.manual'
|
||||
_description = 'Set payment orders to \'sent\' manually'
|
||||
|
||||
def default_get(self, cr, uid, fields_list, context=None):
|
||||
if context and context.get('active_ids'):
|
||||
payment_order_obj = self.pool.get('payment.order')
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
for order_id in context['active_ids']:
|
||||
wf_service.trg_validate(
|
||||
uid, 'payment.order', order_id, 'sent', cr)
|
||||
return super(payment_manual, self).default_get(
|
||||
cr, uid, fields_list, context=None)
|
||||
_description = 'Send payment order(s) manually'
|
||||
|
||||
_columns = {
|
||||
# dummy field, to trigger a call to default_get
|
||||
'name': fields.char('Name', size=1),
|
||||
'payment_order_ids': fields.many2many('payment.order',
|
||||
'wiz_manual_payorders_rel', 'wizard_id', 'payment_order_id',
|
||||
'Payment orders', readonly=True),
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
payment_order_ids = context.get('active_ids', [])
|
||||
vals.update({
|
||||
'payment_order_ids': [[6, 0, payment_order_ids]],
|
||||
})
|
||||
return super(payment_manual, self).create(cr, uid,
|
||||
vals, context=context)
|
||||
|
||||
def button_ok(self, cr, uid, ids, context=None):
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
for wiz in self.browse(cr, uid, ids, context=context):
|
||||
for order_id in wiz.payment_order_ids:
|
||||
wf_service.trg_validate(
|
||||
uid, 'payment.order', order_id.id, 'done', cr)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
52
account_banking_payment_export/model/payment_mode.py
Normal file
52
account_banking_payment_export/model/payment_mode.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
|
||||
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
|
||||
#
|
||||
# All other contributions are (C) by their respective contributors
|
||||
#
|
||||
# All Rights Reserved
|
||||
#
|
||||
# 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):
|
||||
''' Restoring the payment type from version 5,
|
||||
used to select the export wizard (if any) '''
|
||||
_inherit = "payment.mode"
|
||||
|
||||
def suitable_bank_types(self, cr, uid, payment_mode_id=None, context=None):
|
||||
""" Reinstates functional code for suitable bank type filtering.
|
||||
Current code in account_payment is disfunctional.
|
||||
"""
|
||||
res = []
|
||||
payment_mode = self.browse(
|
||||
cr, uid, payment_mode_id, context)
|
||||
if (payment_mode and payment_mode.type and
|
||||
payment_mode.type.suitable_bank_types):
|
||||
res = [t.code for t in payment_mode.type.suitable_bank_types]
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'type': fields.many2one(
|
||||
'payment.mode.type', 'Payment type',
|
||||
required=True,
|
||||
help='Select the Payment Type for the Payment Mode.'
|
||||
),
|
||||
}
|
||||
61
account_banking_payment_export/model/payment_mode_type.py
Normal file
61
account_banking_payment_export/model/payment_mode_type.py
Normal file
@@ -0,0 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
|
||||
# (C) 2011 - 2013 Therp BV (<http://therp.nl>).
|
||||
#
|
||||
# All other contributions are (C) by their respective contributors
|
||||
#
|
||||
# All Rights Reserved
|
||||
#
|
||||
# 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_type(orm.Model):
|
||||
_name = 'payment.mode.type'
|
||||
_description = 'Payment Mode Type'
|
||||
_columns = {
|
||||
'name': fields.char(
|
||||
'Name', size=64, required=True,
|
||||
help='Payment Type'
|
||||
),
|
||||
'code': fields.char(
|
||||
'Code', size=64, required=True,
|
||||
help='Specify the Code for Payment Type'
|
||||
),
|
||||
'suitable_bank_types': fields.many2many(
|
||||
'res.partner.bank.type',
|
||||
'bank_type_payment_type_rel',
|
||||
'pay_type_id','bank_type_id',
|
||||
'Suitable bank types', required=True),
|
||||
'ir_model_id': fields.many2one(
|
||||
'ir.model', 'Payment wizard',
|
||||
help=('Select the Payment Wizard for payments of this type. '
|
||||
'Leave empty for manual processing'),
|
||||
domain=[('osv_memory', '=', True)],
|
||||
),
|
||||
}
|
||||
|
||||
def _auto_init(self, cr, context=None):
|
||||
r = super(payment_mode_type, self)._auto_init(cr, context=context)
|
||||
# migrate xmlid from manual_bank_transfer to avoid dependency on account_banking
|
||||
cr.execute("""UPDATE ir_model_data SET module='account_banking_payment_export'
|
||||
WHERE module='account_banking' AND
|
||||
name='manual_bank_tranfer' AND
|
||||
model='payment.mode.type'""")
|
||||
return r
|
||||
58
account_banking_payment_export/model/payment_order_create.py
Normal file
58
account_banking_payment_export/model/payment_order_create.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (C) 2013 ACSONE SA/NV (<http://acsone.eu>);.
|
||||
#
|
||||
# All other contributions are (C) by their respective contributors
|
||||
#
|
||||
# All Rights Reserved
|
||||
#
|
||||
# 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
|
||||
|
||||
|
||||
class payment_order_create(orm.TransientModel):
|
||||
_inherit = 'payment.order.create'
|
||||
|
||||
def create_payment(self, cr, uid, ids, context=None):
|
||||
'''This method adapts the core create_payment()
|
||||
to pass the payment mode to line2bank() through the context,
|
||||
so it is in turn propagated to suitable_bank_types().
|
||||
|
||||
This is necessary because the core does not propagate the payment mode to line2bank: t = None in
|
||||
http://bazaar.launchpad.net/~openerp/openobject-addons/7.0/view/head:/account_payment/wizard/account_payment_order.py#L72
|
||||
|
||||
Hack idea courtesy Stefan Rijnhart.
|
||||
'''
|
||||
if context is None:
|
||||
context = {}
|
||||
order_obj = self.pool.get('payment.order')
|
||||
payment = order_obj.browse(cr, uid, context['active_id'], context=context)
|
||||
context['_fix_payment_mode_id'] = payment.mode.id
|
||||
return super(payment_order_create, self).create_payment(cr, uid, ids, context=context)
|
||||
|
||||
|
||||
class account_move_line(orm.Model):
|
||||
_inherit = 'account.move.line'
|
||||
|
||||
def line2bank(self, cr, uid, ids, payment_mode_id=None, context=None):
|
||||
'''Obtain payment_type from context, see create_payment above'''
|
||||
if context is None:
|
||||
context = {}
|
||||
payment_mode_id = payment_mode_id or context.get('_fix_payment_mode_id')
|
||||
return super(account_move_line, self).line2bank(cr, uid, ids, payment_mode_id, context=context)
|
||||
|
||||
22
account_banking_payment_export/view/account_payment.xml
Normal file
22
account_banking_payment_export/view/account_payment.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- restore wizard functionality when making payments
|
||||
-->
|
||||
|
||||
<record id="view_banking_payment_order_form_1" model="ir.ui.view">
|
||||
<field name="name">account.payment.order.form.banking-1</field>
|
||||
<field name="inherit_id" ref="account_payment.view_payment_order_form" />
|
||||
<field name="model">payment.order</field>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//button[@string='Make Payments']"
|
||||
position="attributes">
|
||||
<attribute name="name">launch_wizard</attribute>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
18
account_banking_payment_export/view/bank_payment_manual.xml
Normal file
18
account_banking_payment_export/view/bank_payment_manual.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_payment_manual_form" model="ir.ui.view">
|
||||
<field name="name">Form for manual payment wizard</field>
|
||||
<field name="model">payment.manual</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Manual payment" version="7.0">
|
||||
<label string="Please execute payment order manually, and click OK when succesfully sent."/>
|
||||
<footer>
|
||||
<button name="button_ok" type="object" string="OK" class="oe_highlight"/>
|
||||
<button special="cancel" string="Cancel" class="oe_link"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
20
account_banking_payment_export/view/payment_mode.xml
Normal file
20
account_banking_payment_export/view/payment_mode.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!--
|
||||
Add the payment mode type and transfer settings
|
||||
-->
|
||||
<record id="view_payment_mode_form_inherit" model="ir.ui.view">
|
||||
<field name="name">payment.mode.form.inherit</field>
|
||||
<field name="model">payment.mode</field>
|
||||
<field name="inherit_id" ref="account_payment.view_payment_mode_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="company_id" position="after">
|
||||
<field name="type"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
31
account_banking_payment_export/view/payment_mode_type.xml
Normal file
31
account_banking_payment_export/view/payment_mode_type.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_payment_mode_tree_inherit" model="ir.ui.view">
|
||||
<field name="name">payment.mode.tree.inherit</field>
|
||||
<field name="model">payment.mode</field>
|
||||
<field name="inherit_id" ref="account_payment.view_payment_mode_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="company_id" position="after">
|
||||
<field name="type"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- basic view for payment mode type -->
|
||||
<record model="ir.ui.view" id="view_payment_mode_type_form">
|
||||
<field name="name">view.payment.mode.type.form</field>
|
||||
<field name="model">payment.mode.type</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Payment mode">
|
||||
<field name="name" />
|
||||
<field name="code" />
|
||||
<field name="suitable_bank_types"/>
|
||||
<field name="ir_model_id"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -26,7 +26,7 @@
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'category': 'Banking addons',
|
||||
'depends': ['account_banking_payment'],
|
||||
'depends': ['account_banking_payment_export'],
|
||||
'data': [
|
||||
'account_banking_sepa_view.xml',
|
||||
'wizard/export_sepa_view.xml',
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
##############################################################################
|
||||
|
||||
from openerp.osv import orm, fields
|
||||
import time
|
||||
from openerp.tools.translate import _
|
||||
from openerp.addons.decimal_precision import decimal_precision as dp
|
||||
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
|
||||
<menuitem id="menu_account_banking_sepa"
|
||||
parent="account_banking.menu_finance_banking_actions"
|
||||
parent="account_payment.menu_main_payment"
|
||||
action="action_account_banking_sepa"
|
||||
sequence="15"
|
||||
/>
|
||||
|
||||
@@ -101,8 +101,6 @@ class banking_export_sepa_wizard(orm.TransientModel):
|
||||
'''
|
||||
Creates the SEPA Credit Transfer file. That's the important code !
|
||||
'''
|
||||
payment_order_obj = self.pool.get('payment.order')
|
||||
|
||||
sepa_export = self.browse(cr, uid, ids[0], context=context)
|
||||
|
||||
my_company_name = sepa_export.payment_order_ids[0].mode.bank_id.partner_id.name
|
||||
@@ -330,12 +328,15 @@ class banking_export_sepa_wizard(orm.TransientModel):
|
||||
|
||||
def save_sepa(self, cr, uid, ids, context=None):
|
||||
'''
|
||||
Save the SEPA PAIN: mark all payments in the file as 'sent'.
|
||||
Save the SEPA PAIN: send the done signal to all payment orders in the file.
|
||||
With the default workflow, they will transition to 'done', while with the
|
||||
advanced workflow in account_banking_payment they will transition to 'sent'
|
||||
waiting reconciliation.
|
||||
'''
|
||||
sepa_export = self.browse(cr, uid, ids[0], context=context)
|
||||
sepa_file = self.pool.get('banking.export.sepa').write(cr, uid,
|
||||
self.pool.get('banking.export.sepa').write(cr, uid,
|
||||
sepa_export.file_id.id, {'state': 'sent'}, context=context)
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
for order in sepa_export.payment_order_ids:
|
||||
wf_service.trg_validate(uid, 'payment.order', order.id, 'sent', cr)
|
||||
wf_service.trg_validate(uid, 'payment.order', order.id, 'done', cr)
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
Reference in New Issue
Block a user