banking-addons-team team mailing list archive
-
banking-addons-team team
-
Mailing list archive
-
Message #00187
lp:~therp-nl/banking-addons/6.1-lp1066826-matching_wizard_on_manual_statements into lp:banking-addons
Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/banking-addons/6.1-lp1066826-matching_wizard_on_manual_statements into lp:banking-addons.
Requested reviews:
Banking Addons Team (banking-addons-team)
Related bugs:
Bug #1066826 in Banking Addons: "Matching wizard does not work for manually encoded transactions"
https://bugs.launchpad.net/banking-addons/+bug/1066826
For more details, see:
https://code.launchpad.net/~therp-nl/banking-addons/6.1-lp1066826-matching_wizard_on_manual_statements/+merge/137397
--
https://code.launchpad.net/~therp-nl/banking-addons/6.1-lp1066826-matching_wizard_on_manual_statements/+merge/137397
Your team Banking Addons Team is requested to review the proposed merge of lp:~therp-nl/banking-addons/6.1-lp1066826-matching_wizard_on_manual_statements into lp:banking-addons.
=== modified file 'account_banking/banking_import_transaction.py'
--- account_banking/banking_import_transaction.py 2012-05-07 11:38:26 +0000
+++ account_banking/banking_import_transaction.py 2012-12-01 18:21:20 +0000
@@ -606,7 +606,7 @@
payment_line_obj.write(
cr, uid, transaction.payment_line_id.id, {
'export_state': 'done',
- 'date_done': transaction.effective_date,
+ 'date_done': transaction.statement_line_id.date,
}
)
self._confirm_move(cr, uid, transaction_id, context=context)
@@ -961,9 +961,14 @@
]
def create(self, cr, uid, vals, context=None):
+ """
+ Search for duplicates of the newly created transaction
+ and mark them as such unless a context key
+ 'transaction_no_duplicate_search' is defined and true.
+ """
res = super(banking_import_transaction, self).create(
cr, uid, vals, context)
- if res:
+ if res and not context.get('transaction_no_duplicate_search'):
me = self.browse(cr, uid, res, context)
search_vals = [(key, '=', me[key])
for key in self.signal_duplicate_keys]
@@ -1556,8 +1561,16 @@
if transaction.move_line_id:
move_line_amount = transaction.move_line_id.amount_residual_currency
- to_curr_id = transaction.statement_id.journal_id.currency and transaction.statement_id.journal_id.currency.id or transaction.statement_line_id.statement_id.company_id.currency_id.id
- from_curr_id = transaction.move_line_id.currency_id and transaction.move_line_id.currency_id.id or transaction.statement_id.company_id.currency_id.id
+ to_curr_id = (
+ transaction.statement_line_id.statement_id.journal_id.currency
+ and transaction.statement_line_id.statement_id.journal_id.currency.id
+ or transaction.statement_line_id.statement_id.company_id.currency_id.id
+ )
+ from_curr_id = (
+ transaction.move_line_id.currency_id
+ and transaction.move_line_id.currency_id.id
+ or transaction.statement_line_id.statement_id.company_id.currency_id.id
+ )
if from_curr_id != to_curr_id:
amount_currency = stline_pool._convert_currency(cr, uid, from_curr_id, to_curr_id, move_line_amount, round=True,
date=time.strftime('%Y-%m-%d'), context=context)
@@ -1871,6 +1884,40 @@
return super(account_bank_statement_line, self).unlink(
cr, uid, ids, context=context)
+ def create_instant_transaction(
+ self, cr, uid, ids, context=None):
+ """
+ Check for existance of import transaction on the
+ bank statement lines. Create instant items if appropriate.
+
+ This way, the matching wizard works on manually
+ encoded statements.
+
+ The transaction is only filled with the most basic
+ information. The use of the transaction at this point
+ is rather to store matching data rather than to
+ provide data about the transaction which have all been
+ transferred to the bank statement line.
+ """
+ import_transaction_pool = self.pool.get('banking.import.transaction')
+ if ids and isinstance(ids, (int, long)):
+ ids = [ids]
+ localcontext = context.copy()
+ localcontext['transaction_no_duplicate_search'] = True
+ for line in self.browse(
+ cr, uid, ids, context=context):
+ if line.state != 'confirmed' and not line.import_transaction_id:
+ res = import_transaction_pool.create(
+ cr, uid, {
+ 'company_id': line.statement_id.company_id.id,
+ 'statement_line_id': line.id,
+ },
+ context=localcontext)
+ self.write(
+ cr, uid, line.id, {
+ 'import_transaction_id': res},
+ context=context)
+
account_bank_statement_line()
class account_bank_statement(osv.osv):
=== modified file 'account_banking/wizard/banking_transaction_wizard.py'
--- account_banking/wizard/banking_transaction_wizard.py 2012-05-02 09:29:06 +0000
+++ account_banking/wizard/banking_transaction_wizard.py 2012-12-01 18:21:20 +0000
@@ -35,6 +35,18 @@
_name = 'banking.transaction.wizard'
_description = 'Match transaction'
+ def create(self, cr, uid, vals, context=None):
+ """
+ Make sure that the statement line has an import transaction
+ """
+ res = super(banking_transaction_wizard, self).create(
+ cr, uid, vals, context=context)
+ if res and vals.get('statement_line_id'):
+ line_pool = self.pool.get('account.bank.statement.line')
+ line_pool.create_instant_transaction(
+ cr, uid, vals['statement_line_id'], context=context)
+ return res
+
def create_act_window(self, cr, uid, ids, nodestroy=True, context=None):
"""
Return a popup window for this model
=== added directory 'account_direct_debit_storno_payment_term'
=== added file 'account_direct_debit_storno_payment_term/__init__.py'
--- account_direct_debit_storno_payment_term/__init__.py 1970-01-01 00:00:00 +0000
+++ account_direct_debit_storno_payment_term/__init__.py 2012-12-01 18:21:20 +0000
@@ -0,0 +1,1 @@
+import model
=== added file 'account_direct_debit_storno_payment_term/__openerp__.py'
--- account_direct_debit_storno_payment_term/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_direct_debit_storno_payment_term/__openerp__.py 2012-12-01 18:21:20 +0000
@@ -0,0 +1,50 @@
+##############################################################################
+#
+# Copyright (C) 2012 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+ 'name': 'Direct Debit Storno Payment Terms',
+ 'version': '6.1.1.141',
+ 'license': 'GPL-3',
+ 'author': 'Therp BV',
+ 'website': 'https://launchpad.net/banking-addons',
+ 'category': 'Banking addons',
+ 'depends': ['account_direct_debit'],
+ 'data': [
+ 'view/storno_payment_term_mapping.xml',
+ 'security/ir.model.access.csv',
+ ],
+ 'description': '''
+Applies a configurable mapping of payment terms for
+non-fatal error conditions signaled by the bank import.
+
+This allows you to mark failed direct debit attempts at the
+invoice level and to create separate debit runs for them.
+
+To configure the mapping of payment terms, go to Accounting ->
+Configuration -> Miscellaneous -> Banking -> Storno payment term mappings
+ ''',
+ 'active': False,
+ 'installable': True,
+}
=== added directory 'account_direct_debit_storno_payment_term/i18n'
=== added file 'account_direct_debit_storno_payment_term/i18n/nl.po'
--- account_direct_debit_storno_payment_term/i18n/nl.po 1970-01-01 00:00:00 +0000
+++ account_direct_debit_storno_payment_term/i18n/nl.po 2012-12-01 18:21:20 +0000
@@ -0,0 +1,48 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * account_direct_debit_storno_payment_term
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-11-02 12:51+0000\n"
+"PO-Revision-Date: 2012-11-02 12:51+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_direct_debit_storno_payment_term
+#: model:ir.actions.act_window,name:account_direct_debit_storno_payment_term.action_mapping_tree
+#: model:ir.ui.menu,name:account_direct_debit_storno_payment_term.menu_mappings
+msgid "Storno payment term mappings"
+msgstr "Wijziging betalingsconditie bij storno"
+
+#. module: account_direct_debit_storno_payment_term
+#: field:storno.payment.term.mapping,mapping_to_id:0
+msgid "Target payment term"
+msgstr "Nieuwe betalingsconditie"
+
+#. module: account_direct_debit_storno_payment_term
+#: sql_constraint:payment.line:0
+msgid "The payment line name must be unique!"
+msgstr "De betaalregelnaam moet uniek zijn!"
+
+#. module: account_direct_debit_storno_payment_term
+#: model:ir.model,name:account_direct_debit_storno_payment_term.model_storno_payment_term_mapping
+msgid "storno.payment.term.mapping"
+msgstr "storno.payment.term.mapping"
+
+#. module: account_direct_debit_storno_payment_term
+#: model:ir.model,name:account_direct_debit_storno_payment_term.model_payment_line
+msgid "Payment Line"
+msgstr "Betaalregel"
+
+#. module: account_direct_debit_storno_payment_term
+#: field:storno.payment.term.mapping,mapping_from_id:0
+msgid "Source payment term"
+msgstr "Oorspronkelijke betalingsconditie"
+
=== added directory 'account_direct_debit_storno_payment_term/model'
=== added file 'account_direct_debit_storno_payment_term/model/__init__.py'
--- account_direct_debit_storno_payment_term/model/__init__.py 1970-01-01 00:00:00 +0000
+++ account_direct_debit_storno_payment_term/model/__init__.py 2012-12-01 18:21:20 +0000
@@ -0,0 +1,1 @@
+import storno_payment_term_mapping
=== added file 'account_direct_debit_storno_payment_term/model/storno_payment_term_mapping.py'
--- account_direct_debit_storno_payment_term/model/storno_payment_term_mapping.py 1970-01-01 00:00:00 +0000
+++ account_direct_debit_storno_payment_term/model/storno_payment_term_mapping.py 2012-12-01 18:21:20 +0000
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (C) 2012 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+
+class storno_payment_term_mapping(osv.osv):
+ _name = 'storno.payment.term.mapping'
+ _rec_name = 'mapping_from_id'
+ _columns = {
+ 'mapping_from_id': fields.many2one(
+ 'account.payment.term', 'Source payment term'),
+ 'mapping_to_id': fields.many2one(
+ 'account.payment.term', 'Target payment term'),
+ }
+
+class payment_line(osv.osv):
+ _inherit = 'payment.line'
+
+ def debit_storno(self, cr, uid, payment_line_id, amount,
+ currency, storno_retry=True, context=None):
+ """
+ Map the payment term on an invoice the payment of which
+ has been stalled temporarily
+ """
+ reconcile_id = super(payment_line, self).debit_storno(
+ cr, uid, payment_line_id, amount, currency,
+ storno_retry=True, context=context)
+ if reconcile_id and storno_retry:
+ line = self.browse(cr, uid, payment_line_id, context=context)
+ if line.move_line_id.invoice and line.move_line_id.invoice.payment_term:
+ invoice_pool = self.pool.get('account.invoice')
+ term_mapping_pool = self.pool.get('storno.payment.term.mapping')
+ map_ids = term_mapping_pool.search(
+ cr, uid,
+ [('mapping_from_id', '=', line.move_line_id.invoice.payment_term.id)],
+ context=context)
+ if map_ids:
+ payment_term_id = term_mapping_pool.read(
+ cr, uid, map_ids[0], ['mapping_to_id'], context=context)['mapping_to_id'][0]
+ invoice_pool.write(
+ cr, uid, line.move_line_id.invoice.id,
+ {'payment_term': payment_term_id}, context=context)
+ return reconcile_id
+
+
=== added directory 'account_direct_debit_storno_payment_term/security'
=== added file 'account_direct_debit_storno_payment_term/security/ir.model.access.csv'
--- account_direct_debit_storno_payment_term/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ account_direct_debit_storno_payment_term/security/ir.model.access.csv 2012-12-01 18:21:20 +0000
@@ -0,0 +1,3 @@
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+"access_payment_term_mapping_manage","Payment term mappings - manage","model_storno_payment_term_mapping","account.group_account_manager",1,1,1,1
+"access_payment_term_mapping_read","Payment term mappings - read","model_storno_payment_term_mapping","account.group_account_user",1,0,0,0
=== added directory 'account_direct_debit_storno_payment_term/view'
=== added file 'account_direct_debit_storno_payment_term/view/storno_payment_term_mapping.xml'
--- account_direct_debit_storno_payment_term/view/storno_payment_term_mapping.xml 1970-01-01 00:00:00 +0000
+++ account_direct_debit_storno_payment_term/view/storno_payment_term_mapping.xml 2012-12-01 18:21:20 +0000
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <record id="mapping_tree" model="ir.ui.view">
+ <field name="name">Storno payment term mapping tree</field>
+ <field name="model">storno.payment.term.mapping</field>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <tree editable="top">
+ <field name="mapping_from_id"/>
+ <field name="mapping_to_id"/>
+ </tree>
+ </field>
+ </record>
+ <record id="action_mapping_tree"
+ model="ir.actions.act_window">
+ <field name="name">Storno payment term mappings</field>
+ <field name="res_model">storno.payment.term.mapping</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree</field>
+ </record>
+ <menuitem id="menu_mappings"
+ name="Storno payment term mappings"
+ action="action_mapping_tree"
+ parent="account.menu_configuration_misc"
+ />
+ </data>
+</openerp>