diff --git a/bank_transaction_period_fix/README.rst b/bank_transaction_period_fix/README.rst new file mode 100644 index 00000000..5db2e0c4 --- /dev/null +++ b/bank_transaction_period_fix/README.rst @@ -0,0 +1,4 @@ +Make sure that when reconciliation moves are generated for a bank +transaction, that the period for the moves is determined from the transaction +(bank statement line), and not from the bank statement period. + diff --git a/bank_transaction_period_fix/__init__.py b/bank_transaction_period_fix/__init__.py new file mode 100644 index 00000000..7c47ee42 --- /dev/null +++ b/bank_transaction_period_fix/__init__.py @@ -0,0 +1,30 @@ +# -*- encoding: utf-8 -*- +"""Import python modules.""" +############################################################################## +# +# Copyright (C) 2015 Therp BV - http://therp.nl. +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract EduSense BV +# +# 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 . +# +############################################################################## +from . import model + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bank_transaction_period_fix/__openerp__.py b/bank_transaction_period_fix/__openerp__.py new file mode 100644 index 00000000..f122eb48 --- /dev/null +++ b/bank_transaction_period_fix/__openerp__.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2015 Therp BV - http://therp.nl. +# 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 . +# +############################################################################## +{ + 'name': 'Account banking fix to use transaction date to determine period', + 'version': '1.0', + 'author': 'Therp BV', + 'category': 'Banking addons', + 'complexity': 'easy', + 'depends': [ + 'account', + ], + 'website': 'https://github.com/OCA/bank-statement-import', + 'data': [], + 'test': [], + 'installable': True, + 'images': [], + 'auto_install': False, + 'license': 'AGPL-3', +} diff --git a/bank_transaction_period_fix/model/__init__.py b/bank_transaction_period_fix/model/__init__.py new file mode 100644 index 00000000..708e6440 --- /dev/null +++ b/bank_transaction_period_fix/model/__init__.py @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- +"""Import python modules extending orm models.""" +############################################################################## +# +# Copyright (C) 2015 Therp BV - http://therp.nl. +# All Rights Reserved +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract EduSense BV +# +# 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 . +# +############################################################################## +from . import account_bank_statement_line +from . import account_move_line + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bank_transaction_period_fix/model/account_bank_statement_line.py b/bank_transaction_period_fix/model/account_bank_statement_line.py new file mode 100644 index 00000000..d96f6d67 --- /dev/null +++ b/bank_transaction_period_fix/model/account_bank_statement_line.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +"""Extend account.bank.statement.line to use transaction date in moves.""" +############################################################################## +# +# Copyright (C) 2015 Therp BV - http://therp.nl. +# 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 . +# +############################################################################## +from openerp.osv import orm + + +class AccountBankStatementLine(orm.Model): + """Extend account.bank.statement.line to use transaction date in moves.""" + _inherit = 'account.bank.statement.line' + + def process_reconciliation( + self, cr, uid, id, mv_line_dicts, context=None): + """Put marker in context to use period from date in move line.""" + ctx = context.copy() or {} + ctx['override_period_from_date'] = True + return super(AccountBankStatementLine, self).process_reconciliation( + cr, uid, id, mv_line_dicts, context=ctx) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bank_transaction_period_fix/model/account_move_line.py b/bank_transaction_period_fix/model/account_move_line.py new file mode 100644 index 00000000..e6d615d4 --- /dev/null +++ b/bank_transaction_period_fix/model/account_move_line.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +"""Extend account.move.line to use date for period, when requested.""" +############################################################################## +# +# Copyright (C) 2015 Therp BV - http://therp.nl. +# 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 . +# +############################################################################## +from openerp.osv import orm + + +class AccountMoveLine(orm.Model): + """Extend account.move.line to use date for period, when requested.""" + _inherit = 'account.move.line' + + def create(self, cr, uid, vals, context=None, check=True): + """If requested, override period from date.""" + ctx = context.copy() or {} + if (('override_period_from_date' in ctx or + 'period_id' not in vals) and 'date' in vals): + period_model = self.pool['account.period'] + period_ids = period_search + ## BE CAREFULL, ALSO CHECK COMPANY + vals['period_id'] = period_ids[0] + return super(AccountMoveLine, self).create( + cr, uid, vals, context=context, check=check) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: