mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
add account_payment_transaction_id: compatibility between payment orders and transaction ids
This commit is contained in:
3
account_payment_transaction_id/__init__.py
Normal file
3
account_payment_transaction_id/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import account_payment
|
||||
40
account_payment_transaction_id/__openerp__.py
Normal file
40
account_payment_transaction_id/__openerp__.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Guewen Baconnier
|
||||
# Copyright 2014 Camptocamp SA
|
||||
#
|
||||
# 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 Payment - Transaction ID',
|
||||
'version': 'version',
|
||||
'author': 'Camptocamp',
|
||||
'maintainer': 'Camptocamp',
|
||||
'license': 'AGPL-3',
|
||||
'category': 'Hidden',
|
||||
'depends': ['base_transaction_id',
|
||||
'account_payment',
|
||||
],
|
||||
'description': """
|
||||
Compatibility module between Account Payment and Base Transaction ID
|
||||
""",
|
||||
'website': 'http://www.camptocamp.com',
|
||||
'data': [],
|
||||
'test': [],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
}
|
||||
62
account_payment_transaction_id/account_payment.py
Normal file
62
account_payment_transaction_id/account_payment.py
Normal file
@@ -0,0 +1,62 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Guewen Baconnier
|
||||
# Copyright 2014 Camptocamp SA
|
||||
#
|
||||
# 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_line(orm.Model):
|
||||
_inherit = 'payment.line'
|
||||
|
||||
def _update_transaction_id(self, cr, uid, ids, context=None):
|
||||
""" Update the bank statement line's transaction id
|
||||
|
||||
When the payment line is linked with a bank statement line,
|
||||
copy the transaction id of the related move line.
|
||||
|
||||
"""
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
if not line.move_line_id:
|
||||
continue
|
||||
if not line.bank_statement_line_id:
|
||||
continue
|
||||
stat_trans_id = line.bank_statement_line_id.transaction_id
|
||||
move_trans_id = line.move_line_id.transaction_ref
|
||||
if stat_trans_id != move_trans_id:
|
||||
line.bank_statement_line_id.write(
|
||||
{'transaction_id': move_trans_id}
|
||||
)
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
line_id = super(payment_line, self).create(cr, uid, vals,
|
||||
context=context)
|
||||
if vals.get('bank_statement_line_id'):
|
||||
self._update_transaction_id(cr, uid, [line_id], context=context)
|
||||
return line_id
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
result = super(payment_line, self).write(cr, uid, ids, vals,
|
||||
context=context)
|
||||
if vals.get('bank_statement_line_id'):
|
||||
self._update_transaction_id(cr, uid, ids, context=context)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user