From dc895512ba71cfa3374bc8b7b6646d45fe73e985 Mon Sep 17 00:00:00 2001 From: Roel Adriaans Date: Sun, 13 Jul 2014 14:57:05 +0200 Subject: [PATCH 01/84] [IMP] Add statement line reference to search Add the reference to the search for matching statements. When importing CAMT (Dutch banking files) the description of the invoice is filled in the reference field. The name field only has the index (eg 001), not the full text. --- account_statement_completion_label/statement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_statement_completion_label/statement.py b/account_statement_completion_label/statement.py index 0d50ae56..4ae36143 100644 --- a/account_statement_completion_label/statement.py +++ b/account_statement_completion_label/statement.py @@ -92,7 +92,7 @@ class AccountStatementCompletionRule(orm.Model): ON st_l.statement_id = s.id WHERE - st_l.name ~* l.label + (st_l.name ~* l.label OR st_l.ref ~* l.label) AND l.profile_id = s.profile_id AND From 88c5159f52d6d6948f02f917a272616475d48438 Mon Sep 17 00:00:00 2001 From: florian-dacosta Date: Wed, 23 Jul 2014 17:55:39 +0200 Subject: [PATCH 02/84] [FIX] conversion_dict is now created in the generic parser --- account_statement_base_import/parser/file_parser.py | 11 ++--------- .../parser/generic_file_parser.py | 9 ++++++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/account_statement_base_import/parser/file_parser.py b/account_statement_base_import/parser/file_parser.py index 125605f2..ad810169 100644 --- a/account_statement_base_import/parser/file_parser.py +++ b/account_statement_base_import/parser/file_parser.py @@ -42,7 +42,7 @@ class FileParser(BankStatementImportParser): """ :param char: parse_name: The name of the parser :param char: ftype: extension of the file (could be csv, xls or xlsx) - :param dict: extra_fields: extra fields to add to the conversion dict. In the format + :param dict: extra_fields: extra fields to put into the conversion dict. In the format {fieldname: fieldtype} :param list: header : specify header fields if the csv file has no header """ @@ -53,14 +53,7 @@ class FileParser(BankStatementImportParser): else: raise except_osv(_('User Error'), _('Invalid file type %s. Please use csv, xls or xlsx') % ftype) - self.conversion_dict = { - 'ref': unicode, - 'label': unicode, - 'date': datetime.datetime, - 'amount': float_or_zero, - } - if extra_fields: - self.conversion_dict.update(extra_fields) + self.conversion_dict = extra_fields self.keys_to_validate = self.conversion_dict.keys() self.fieldnames = header self._datemode = 0 # used only for xls documents, diff --git a/account_statement_base_import/parser/generic_file_parser.py b/account_statement_base_import/parser/generic_file_parser.py index 81e51c8c..e60bedf9 100644 --- a/account_statement_base_import/parser/generic_file_parser.py +++ b/account_statement_base_import/parser/generic_file_parser.py @@ -24,6 +24,7 @@ import csv import tempfile import datetime from file_parser import FileParser ++from openerp.addons.account_statement_base_import.parser.file_parser import float_or_zero try: import xlrd except: @@ -38,7 +39,13 @@ class GenericFileParser(FileParser): """ def __init__(self, parse_name, ftype='csv', **kwargs): - super(GenericFileParser, self).__init__(parse_name, ftype=ftype, **kwargs) + conversion_dict = { + 'ref': unicode, + 'label': unicode, + 'date': datetime.datetime, + 'amount': float_or_zero, + } + super(GenericFileParser, self).__init__(parse_name, ftype=ftype, extra_fields=conversion_dict, **kwargs) @classmethod def parser_for(cls, parser_name): From 600fb4dd86b134ab55cd3d8e69df08f27be45445 Mon Sep 17 00:00:00 2001 From: florian-dacosta Date: Wed, 23 Jul 2014 20:03:03 +0200 Subject: [PATCH 03/84] replace unicode by ustr --- .../parser/generic_file_parser.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/account_statement_base_import/parser/generic_file_parser.py b/account_statement_base_import/parser/generic_file_parser.py index e60bedf9..04149d1b 100644 --- a/account_statement_base_import/parser/generic_file_parser.py +++ b/account_statement_base_import/parser/generic_file_parser.py @@ -24,7 +24,8 @@ import csv import tempfile import datetime from file_parser import FileParser -+from openerp.addons.account_statement_base_import.parser.file_parser import float_or_zero +from openerp.addons.account_statement_base_import.parser.file_parser import float_or_zero +from openerp.loglevels import ustr try: import xlrd except: @@ -40,8 +41,8 @@ class GenericFileParser(FileParser): def __init__(self, parse_name, ftype='csv', **kwargs): conversion_dict = { - 'ref': unicode, - 'label': unicode, + 'ref': ustr, + 'label': ustr, 'date': datetime.datetime, 'amount': float_or_zero, } From 92c523709d077befebd961196a583bcd8c24c94c Mon Sep 17 00:00:00 2001 From: florian-dacosta Date: Thu, 24 Jul 2014 10:56:31 +0200 Subject: [PATCH 04/84] import ustr from tools --- account_statement_base_import/parser/generic_file_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_statement_base_import/parser/generic_file_parser.py b/account_statement_base_import/parser/generic_file_parser.py index 04149d1b..c1da333b 100644 --- a/account_statement_base_import/parser/generic_file_parser.py +++ b/account_statement_base_import/parser/generic_file_parser.py @@ -25,7 +25,7 @@ import tempfile import datetime from file_parser import FileParser from openerp.addons.account_statement_base_import.parser.file_parser import float_or_zero -from openerp.loglevels import ustr +from openerp.tools import ustr try: import xlrd except: From b25332284f0300236f4430bf33fd252935da9fe0 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (aka lmi)" Date: Mon, 7 Jul 2014 12:46:20 +0200 Subject: [PATCH 05/84] [IMP] Improve the matching on acc_number by removing the formatting characters when querying the res_partner_bank table --- .../__init__.py | 3 +- .../res_partner_bank.py | 49 +++++++++++++ .../statement.py | 4 +- .../tests/test_bankaccount_completion.py | 68 +++++++++++-------- 4 files changed, 94 insertions(+), 30 deletions(-) create mode 100644 account_statement_bankaccount_completion/res_partner_bank.py diff --git a/account_statement_bankaccount_completion/__init__.py b/account_statement_bankaccount_completion/__init__.py index 133223b9..cac9a795 100644 --- a/account_statement_bankaccount_completion/__init__.py +++ b/account_statement_bankaccount_completion/__init__.py @@ -18,4 +18,5 @@ # along with this program. If not, see . # # -import statement +from . import statement +from . import res_partner_bank diff --git a/account_statement_bankaccount_completion/res_partner_bank.py b/account_statement_bankaccount_completion/res_partner_bank.py new file mode 100644 index 00000000..4af45adb --- /dev/null +++ b/account_statement_bankaccount_completion/res_partner_bank.py @@ -0,0 +1,49 @@ +# +# Authors: Laurent Mignon +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) +# 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.orm import Model +from openerp.addons.base_iban import base_iban + + +class res_partner_bank(Model): + _inherit = 'res.partner.bank' + + def search_by_acc_number(self, cr, uid, acc_number, context=None): + ''' + Try to find the Account Number using a 'like' operator to avoid problems with the input mask + used to store the value. + ''' + # first try with an exact match + ids = self.search(cr, + uid, + [('acc_number', '=', acc_number)], + context=context) + if ids: + return ids + + cr.execute(""" + SELECT + id + FROM + res_partner_bank + WHERE + regexp_replace(acc_number,'([^[:alnum:]])', '','g') ilike regexp_replace(%s,'([^[:alnum:]])', '','g') """, + (acc_number,)) + #apply security constraints by using the orm + return self.search(cr, uid, [('id', 'in', [r[0] for r in cr.fetchall()])]) diff --git a/account_statement_bankaccount_completion/statement.py b/account_statement_bankaccount_completion/statement.py index 48b81942..6f6cdb74 100644 --- a/account_statement_bankaccount_completion/statement.py +++ b/account_statement_bankaccount_completion/statement.py @@ -56,9 +56,9 @@ class AccountStatementCompletionRule(Model): st_obj = self.pool.get('account.bank.statement.line') res = {} res_bank_obj = self.pool.get('res.partner.bank') - ids = res_bank_obj.search(cr, + ids = res_bank_obj.search_by_acc_number(cr, uid, - [('acc_number', '=', partner_acc_number)], + partner_acc_number, context=context) if len(ids) > 1: raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more than ' diff --git a/account_statement_bankaccount_completion/tests/test_bankaccount_completion.py b/account_statement_bankaccount_completion/tests/test_bankaccount_completion.py index 5f1f9142..e9fb7331 100644 --- a/account_statement_bankaccount_completion/tests/test_bankaccount_completion.py +++ b/account_statement_bankaccount_completion/tests/test_bankaccount_completion.py @@ -22,29 +22,28 @@ from openerp.tests import common import time -ACC_NUMBER = "BE38733040385372" +ACC_NUMBER = " BE38 7330 4038 5372 " class bankaccount_completion(common.TransactionCase): - def prepare(self): + def setUp(self): + super(bankaccount_completion, self).setUp() self.company_a = self.browse_ref('base.main_company') self.profile_obj = self.registry("account.statement.profile") self.account_bank_statement_obj = self.registry("account.bank.statement") self.account_bank_statement_line_obj = self.registry("account.bank.statement.line") self.completion_rule_id = self.ref('account_statement_bankaccount_completion.bank_statement_completion_rule_10') - self.journal_id = self.registry("ir.model.data").get_object_reference(self.cr, self. uid, "account", "bank_journal")[1] + self.journal_id = self.ref("account.bank_journal") self.partner_id = self.ref('base.main_partner') + self.account_id = self.ref("account.a_recv") + # Create the profile - self.account_id = self.registry("ir.model.data").get_object_reference(self.cr, self.uid, "account", "a_recv")[1] - self.journal_id = self.registry("ir.model.data").get_object_reference(self.cr, self. uid, "account", "bank_journal")[1] self.profile_id = self.profile_obj.create(self.cr, self.uid, { "name": "TEST", "commission_account_id": self.account_id, "journal_id": self.journal_id, "rule_ids": [(6, 0, [self.completion_rule_id])]}) - # Create the completion rule - # Create a bank statement self.statement_id = self.account_bank_statement_obj.create(self.cr, self.uid, { "balance_end_real": 0.0, @@ -55,18 +54,9 @@ class bankaccount_completion(common.TransactionCase): }) - # Create bank a statement line - self.statement_line_id = self.account_bank_statement_line_obj.create(self.cr, self.uid, { - 'amount': 1000.0, - 'name': 'EXT001', - 'ref': 'My ref', - 'statement_id': self.statement_id, - 'partner_acc_number': ACC_NUMBER - }) - # Add a bank account number to the partner - res_bank_obj = self.registry('res.partner.bank') - res_bank_obj.create(self.cr, self.uid, { + self.res_partner_bank_obj = self.registry('res.partner.bank') + self.res_partner_bank_id = self.res_partner_bank_obj.create(self.cr, self.uid, { "state": "bank", "company_id": self.company_a.id, "partner_id": self.partner_id, @@ -77,15 +67,39 @@ class bankaccount_completion(common.TransactionCase): def test_00(self): """Test complete partner_id from bank account number - Test the automatic completion of the partner_id based on the account number associated to the statement line """ - self.prepare() - statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, self.statement_line_id) - # before import, the - self.assertFalse(statement_line.partner_id, "Partner_id must be blank before completion") - statement_obj = self.account_bank_statement_obj.browse(self.cr, self.uid, self.statement_id) - statement_obj.button_auto_completion() - statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, self.statement_line_id) - self.assertEquals(self.partner_id, statement_line.partner_id['id'], "Missing expected partner id after completion") + for bank_acc_number in [ACC_NUMBER, ACC_NUMBER.replace(" ", ""), ACC_NUMBER.replace(" ", "-")]: + # check the completion for well formatted and not well formatted account number + self.res_partner_bank_obj.write(self.cr, self.uid, self.res_partner_bank_id, { + "acc_number": bank_acc_number, + }) + for acc_number in [ACC_NUMBER, ACC_NUMBER.replace(" ", ""), ACC_NUMBER.replace(" ", "-"), " BE38-7330 4038-5372 "]: + statement_line_id = self.account_bank_statement_line_obj.create(self.cr, self.uid, { + 'amount': 1000.0, + 'name': 'EXT001', + 'ref': 'My ref', + 'statement_id': self.statement_id, + 'partner_acc_number': acc_number + }) + statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, statement_line_id) + self.assertFalse(statement_line.partner_id, "Partner_id must be blank before completion") + statement_obj = self.account_bank_statement_obj.browse(self.cr, self.uid, self.statement_id) + statement_obj.button_auto_completion() + statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, statement_line_id) + self.assertEquals(self.partner_id, statement_line.partner_id['id'], "Missing expected partner id after completion") + + statement_line_id = self.account_bank_statement_line_obj.create(self.cr, self.uid, { + 'amount': 1000.0, + 'name': 'EXT001', + 'ref': 'My ref', + 'statement_id': self.statement_id, + 'partner_acc_number': 'BE38a7330.4038-5372.' + }) + statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, statement_line_id) + self.assertFalse(statement_line.partner_id, "Partner_id must be blank before completion") + statement_obj = self.account_bank_statement_obj.browse(self.cr, self.uid, self.statement_id) + statement_obj.button_auto_completion() + statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, statement_line_id) + self.assertFalse(statement_line.partner_id.id) From 55e53a6d5dd6b1a945711fefb2a1c34341884f05 Mon Sep 17 00:00:00 2001 From: Laurent Mignon Date: Fri, 1 Aug 2014 09:22:03 +0200 Subject: [PATCH 06/84] [PEP8] max-line-length=80 --- .../res_partner_bank.py | 23 ++-- .../statement.py | 40 ++++-- .../tests/test_bankaccount_completion.py | 125 +++++++++++------- .../tests/test_base_completion.py | 8 +- .../tests/test_regex_account_completion.py | 10 +- 5 files changed, 125 insertions(+), 81 deletions(-) diff --git a/account_statement_bankaccount_completion/res_partner_bank.py b/account_statement_bankaccount_completion/res_partner_bank.py index 4af45adb..ea826f96 100644 --- a/account_statement_bankaccount_completion/res_partner_bank.py +++ b/account_statement_bankaccount_completion/res_partner_bank.py @@ -18,7 +18,6 @@ # # from openerp.osv.orm import Model -from openerp.addons.base_iban import base_iban class res_partner_bank(Model): @@ -26,14 +25,14 @@ class res_partner_bank(Model): def search_by_acc_number(self, cr, uid, acc_number, context=None): ''' - Try to find the Account Number using a 'like' operator to avoid problems with the input mask - used to store the value. + Try to find the Account Number using a 'like' operator to avoid + problems with the input mask used to store the value. ''' # first try with an exact match ids = self.search(cr, - uid, - [('acc_number', '=', acc_number)], - context=context) + uid, + [('acc_number', '=', acc_number)], + context=context) if ids: return ids @@ -43,7 +42,11 @@ class res_partner_bank(Model): FROM res_partner_bank WHERE - regexp_replace(acc_number,'([^[:alnum:]])', '','g') ilike regexp_replace(%s,'([^[:alnum:]])', '','g') """, - (acc_number,)) - #apply security constraints by using the orm - return self.search(cr, uid, [('id', 'in', [r[0] for r in cr.fetchall()])]) + regexp_replace(acc_number,'([^[:alnum:]])', '','g') + ilike + regexp_replace(%s,'([^[:alnum:]])', '','g') + """, (acc_number,)) + # apply security constraints by using the orm + return self.search(cr, uid, + [('id', 'in', [r[0] for r in cr.fetchall()])], + context=context) diff --git a/account_statement_bankaccount_completion/statement.py b/account_statement_bankaccount_completion/statement.py index 6f6cdb74..07895a29 100644 --- a/account_statement_bankaccount_completion/statement.py +++ b/account_statement_bankaccount_completion/statement.py @@ -23,7 +23,8 @@ from openerp.tools.translate import _ from openerp.osv.orm import Model from openerp.osv import fields -from openerp.addons.account_statement_base_completion.statement import ErrorTooManyPartner +from openerp.addons.account_statement_base_completion.statement \ + import ErrorTooManyPartner class AccountStatementCompletionRule(Model): @@ -57,22 +58,34 @@ class AccountStatementCompletionRule(Model): res = {} res_bank_obj = self.pool.get('res.partner.bank') ids = res_bank_obj.search_by_acc_number(cr, - uid, - partner_acc_number, - context=context) + uid, + partner_acc_number, + context=context) if len(ids) > 1: - raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched by more than ' - 'one partner for account number "%s".') % (st_line['name'], st_line['ref'], partner_acc_number)) + raise ErrorTooManyPartner(_('Line named "%s" (Ref:%s) was matched ' + 'by more than one partner for account ' + 'number "%s".') % + (st_line['name'], + st_line['ref'], + partner_acc_number)) if len(ids) == 1: - partner = res_bank_obj.browse(cr, uid, ids[0], context=context).partner_id + partner = res_bank_obj.browse(cr, + uid, + ids[0], + context=context).partner_id res['partner_id'] = partner.id + profile_id = st_line['profile_id'] + m_acc_id = st_line['master_account_id'] + partner_id = res.get('partner_id', False) + line_type = st_line['type'] + amout = st_line['amount'] if st_line['amount'] else 0.0 st_vals = st_obj.get_values_for_line(cr, uid, - profile_id=st_line['profile_id'], - master_account_id=st_line['master_account_id'], - partner_id=res.get('partner_id', False), - line_type=st_line['type'], - amount=st_line['amount'] if st_line['amount'] else 0.0, + profile_id=profile_id, + master_account_id=m_acc_id, + partner_id=partner_id, + line_type=line_type, + amount=amout, context=context) res.update(st_vals) return res @@ -82,7 +95,8 @@ class AccountStatementLine(Model): _inherit = "account.bank.statement.line" _columns = { - # 'additional_bank_fields' : fields.serialized('Additional infos from bank', help="Used by completion and import system."), + # 'additional_bank_fields' : fields.serialized('Additional infos from + # bank', help="Used by completion and import system."), 'partner_acc_number': fields.sparse( type='char', string='Account Number', diff --git a/account_statement_bankaccount_completion/tests/test_bankaccount_completion.py b/account_statement_bankaccount_completion/tests/test_bankaccount_completion.py index e9fb7331..9ed5c06b 100644 --- a/account_statement_bankaccount_completion/tests/test_bankaccount_completion.py +++ b/account_statement_bankaccount_completion/tests/test_bankaccount_completion.py @@ -31,9 +31,12 @@ class bankaccount_completion(common.TransactionCase): super(bankaccount_completion, self).setUp() self.company_a = self.browse_ref('base.main_company') self.profile_obj = self.registry("account.statement.profile") - self.account_bank_statement_obj = self.registry("account.bank.statement") - self.account_bank_statement_line_obj = self.registry("account.bank.statement.line") - self.completion_rule_id = self.ref('account_statement_bankaccount_completion.bank_statement_completion_rule_10') + self.acc_bk_stmt = self.registry("account.bank.statement") + self.acc_bk_stmt_line_obj = \ + self.registry("account.bank.statement.line") + self.completion_rule_id = \ + self.ref('account_statement_bankaccount_completion.' + 'bank_statement_completion_rule_10') self.journal_id = self.ref("account.bank_journal") self.partner_id = self.ref('base.main_partner') self.account_id = self.ref("account.a_recv") @@ -45,61 +48,85 @@ class bankaccount_completion(common.TransactionCase): "journal_id": self.journal_id, "rule_ids": [(6, 0, [self.completion_rule_id])]}) # Create a bank statement - self.statement_id = self.account_bank_statement_obj.create(self.cr, self.uid, { - "balance_end_real": 0.0, - "balance_start": 0.0, - "date": time.strftime('%Y-%m-%d'), - "journal_id": self.journal_id, - "profile_id": self.profile_id - - }) + vals = {"balance_end_real": 0.0, + "balance_start": 0.0, + "date": time.strftime('%Y-%m-%d'), + "journal_id": self.journal_id, + "profile_id": self.profile_id, + } + self.statement_id = self.acc_bk_stmt.create(self.cr, + self.uid, + vals) # Add a bank account number to the partner self.res_partner_bank_obj = self.registry('res.partner.bank') - self.res_partner_bank_id = self.res_partner_bank_obj.create(self.cr, self.uid, { - "state": "bank", - "company_id": self.company_a.id, - "partner_id": self.partner_id, - "acc_number": ACC_NUMBER, - "footer": True, - "bank_name": "Reserve" - }) + vals = {"state": "bank", + "company_id": self.company_a.id, + "partner_id": self.partner_id, + "acc_number": ACC_NUMBER, + "footer": True, + "bank_name": "Reserve", + } + self.res_partner_bank_id = self.res_partner_bank_obj.create(self.cr, + self.uid, + vals) def test_00(self): """Test complete partner_id from bank account number - Test the automatic completion of the partner_id based on the account number associated to the - statement line + Test the automatic completion of the partner_id based on the accoun + t number associated to the statement line """ - for bank_acc_number in [ACC_NUMBER, ACC_NUMBER.replace(" ", ""), ACC_NUMBER.replace(" ", "-")]: - # check the completion for well formatted and not well formatted account number - self.res_partner_bank_obj.write(self.cr, self.uid, self.res_partner_bank_id, { - "acc_number": bank_acc_number, - }) - for acc_number in [ACC_NUMBER, ACC_NUMBER.replace(" ", ""), ACC_NUMBER.replace(" ", "-"), " BE38-7330 4038-5372 "]: - statement_line_id = self.account_bank_statement_line_obj.create(self.cr, self.uid, { - 'amount': 1000.0, - 'name': 'EXT001', - 'ref': 'My ref', - 'statement_id': self.statement_id, - 'partner_acc_number': acc_number - }) - statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, statement_line_id) - self.assertFalse(statement_line.partner_id, "Partner_id must be blank before completion") - statement_obj = self.account_bank_statement_obj.browse(self.cr, self.uid, self.statement_id) + for bank_acc_number in [ACC_NUMBER, ACC_NUMBER.replace(" ", ""), + ACC_NUMBER.replace(" ", "-")]: + # check the completion for well formatted and not well + # formatted account number + self.res_partner_bank_obj.write(self.cr, + self.uid, + self.res_partner_bank_id, + {"acc_number": bank_acc_number} + ) + for acc_number in [ACC_NUMBER, ACC_NUMBER.replace(" ", ""), + ACC_NUMBER.replace(" ", "-"), + " BE38-7330 4038-5372 "]: + vals = {'amount': 1000.0, + 'name': 'EXT001', + 'ref': 'My ref', + 'statement_id': self.statement_id, + 'partner_acc_number': acc_number + } + line_id = self.acc_bk_stmt_line_obj.create(self.cr, + self.uid, + vals) + line = self.acc_bk_stmt_line_obj.browse(self.cr, + self.uid, + line_id) + self.assertFalse(line.partner_id, + 'Partner_id must be blank before completion') + statement_obj = self.acc_bk_stmt.browse(self.cr, + self.uid, + self.statement_id) statement_obj.button_auto_completion() - statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, statement_line_id) - self.assertEquals(self.partner_id, statement_line.partner_id['id'], "Missing expected partner id after completion") - - statement_line_id = self.account_bank_statement_line_obj.create(self.cr, self.uid, { - 'amount': 1000.0, + line = self.acc_bk_stmt_line_obj.browse(self.cr, + self.uid, + line_id) + self.assertEquals(self.partner_id, line.partner_id['id'], + 'Missing expected partner id after ' + 'completion') + vals = {'amount': 1000.0, 'name': 'EXT001', 'ref': 'My ref', 'statement_id': self.statement_id, - 'partner_acc_number': 'BE38a7330.4038-5372.' - }) - statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, statement_line_id) - self.assertFalse(statement_line.partner_id, "Partner_id must be blank before completion") - statement_obj = self.account_bank_statement_obj.browse(self.cr, self.uid, self.statement_id) + 'partner_acc_number': 'BE38a7330.4038-5372.', + } + line_id = self.acc_bk_stmt_line_obj.create(self.cr, + self.uid, + vals) + line = self.acc_bk_stmt_line_obj.browse(self.cr, self.uid, line_id) + self.assertFalse(line.partner_id, + 'Partner_id must be blank before completion') + statement_obj = self.acc_bk_stmt.browse(self.cr, + self.uid, + self.statement_id) statement_obj.button_auto_completion() - statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, statement_line_id) - self.assertFalse(statement_line.partner_id.id) + line = self.acc_bk_stmt_line_obj.browse(self.cr, self.uid, line_id) + self.assertFalse(line.partner_id.id) diff --git a/account_statement_base_completion/tests/test_base_completion.py b/account_statement_base_completion/tests/test_base_completion.py index 6e2d8d3e..19319567 100644 --- a/account_statement_base_completion/tests/test_base_completion.py +++ b/account_statement_base_completion/tests/test_base_completion.py @@ -49,7 +49,7 @@ class base_completion(common.TransactionCase): self.profile_obj = self.registry("account.statement.profile") self.partner_obj = self.registry("res.partner") self.account_bank_statement_obj = self.registry("account.bank.statement") - self.account_bank_statement_line_obj = self.registry("account.bank.statement.line") + self.acc_bk_stmt_line_obj = self.registry("account.bank.statement.line") self.journal_id = self.ref("account.bank_journal") self.partner_id = self.ref('base.main_partner') self.account_id = self.ref("account.a_recv") @@ -78,17 +78,17 @@ class base_completion(common.TransactionCase): for case in NAMES_COMPLETION_CASES: self.partner_obj.write(self.cr, self.uid, self.partner_id, {'name': case.partner_name}) - statement_line_id = self.account_bank_statement_line_obj.create(self.cr, self.uid, { + statement_line_id = self.acc_bk_stmt_line_obj.create(self.cr, self.uid, { 'amount': 1000.0, 'name': case.line_label, 'ref': 'My ref', 'statement_id': self.statement_id, }) - statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, statement_line_id) + statement_line = self.acc_bk_stmt_line_obj.browse(self.cr, self.uid, statement_line_id) self.assertFalse(statement_line.partner_id, "Partner_id must be blank before completion") statement_obj = self.account_bank_statement_obj.browse(self.cr, self.uid, self.statement_id) statement_obj.button_auto_completion() - statement_line = self.account_bank_statement_line_obj.browse(self.cr, self.uid, statement_line_id) + statement_line = self.acc_bk_stmt_line_obj.browse(self.cr, self.uid, statement_line_id) if case.should_match: self.assertEquals(self.partner_id, statement_line.partner_id['id'], "Missing expected partner id after completion (partner_name: %s, line_name: %s)" % (case.partner_name, case.line_label)) diff --git a/account_statement_regex_account_completion/tests/test_regex_account_completion.py b/account_statement_regex_account_completion/tests/test_regex_account_completion.py index 64958844..cfe66848 100644 --- a/account_statement_regex_account_completion/tests/test_regex_account_completion.py +++ b/account_statement_regex_account_completion/tests/test_regex_account_completion.py @@ -37,7 +37,7 @@ class test_regex_account_completion(common.TransactionCase): def prepare(self): self.account_bank_statement_obj = self.registry("account.bank.statement") - self.account_bank_statement_line_obj = self.registry("account.bank.statement.line") + self.acc_bk_stmt_line_obj = self.registry("account.bank.statement.line") self.account_id = self.ref('account.a_expense') # create the completion rule rule_vals = {'function_to_call': 'set_account', @@ -63,7 +63,7 @@ class test_regex_account_completion(common.TransactionCase): }) # Create two bank statement lines - self.statement_line1_id = self.account_bank_statement_line_obj.create(self.cr, self.uid, { + self.statement_line1_id = self.acc_bk_stmt_line_obj.create(self.cr, self.uid, { 'amount': 1000.0, 'name': 'My statement', 'ref': 'My ref', @@ -71,7 +71,7 @@ class test_regex_account_completion(common.TransactionCase): 'partner_acc_number': ACC_NUMBER }) - self.statement_line2_id = self.account_bank_statement_line_obj.create(self.cr, self.uid, { + self.statement_line2_id = self.acc_bk_stmt_line_obj.create(self.cr, self.uid, { 'amount': 2000.0, 'name': 'My second statement', 'ref': 'My second ref', @@ -85,7 +85,7 @@ class test_regex_account_completion(common.TransactionCase): self.prepare() statement_obj = self.account_bank_statement_obj.browse(self.cr, self.uid, self.statement_id) statement_obj.button_auto_completion() - statement_line1 = self.account_bank_statement_line_obj.browse(self.cr, self.uid, self.statement_line1_id) + statement_line1 = self.acc_bk_stmt_line_obj.browse(self.cr, self.uid, self.statement_line1_id) self.assertEquals(self.account_id, statement_line1.account_id.id, "The account should be the account of the completion") - statement_line2 = self.account_bank_statement_line_obj.browse(self.cr, self.uid, self.statement_line2_id) + statement_line2 = self.acc_bk_stmt_line_obj.browse(self.cr, self.uid, self.statement_line2_id) self.assertNotEqual(self.account_id, statement_line2.account_id.id, "The account should be not the account of the completion") From 7cafa70ab6b78ce9741124ee7c3453fa044c446d Mon Sep 17 00:00:00 2001 From: Laurent Mignon Date: Fri, 1 Aug 2014 10:04:23 +0200 Subject: [PATCH 07/84] [FIX] rename 'acc_bk_stmt_line_obj' to 'st_line_obj' --- .../tests/test_bankaccount_completion.py | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/account_statement_bankaccount_completion/tests/test_bankaccount_completion.py b/account_statement_bankaccount_completion/tests/test_bankaccount_completion.py index 9ed5c06b..bef61969 100644 --- a/account_statement_bankaccount_completion/tests/test_bankaccount_completion.py +++ b/account_statement_bankaccount_completion/tests/test_bankaccount_completion.py @@ -32,8 +32,7 @@ class bankaccount_completion(common.TransactionCase): self.company_a = self.browse_ref('base.main_company') self.profile_obj = self.registry("account.statement.profile") self.acc_bk_stmt = self.registry("account.bank.statement") - self.acc_bk_stmt_line_obj = \ - self.registry("account.bank.statement.line") + self.st_line_obj = self.registry("account.bank.statement.line") self.completion_rule_id = \ self.ref('account_statement_bankaccount_completion.' 'bank_statement_completion_rule_10') @@ -73,8 +72,8 @@ class bankaccount_completion(common.TransactionCase): def test_00(self): """Test complete partner_id from bank account number - Test the automatic completion of the partner_id based on the accoun - t number associated to the statement line + Test the automatic completion of the partner_id based on the account + number associated to the statement line """ for bank_acc_number in [ACC_NUMBER, ACC_NUMBER.replace(" ", ""), ACC_NUMBER.replace(" ", "-")]: @@ -94,21 +93,15 @@ class bankaccount_completion(common.TransactionCase): 'statement_id': self.statement_id, 'partner_acc_number': acc_number } - line_id = self.acc_bk_stmt_line_obj.create(self.cr, - self.uid, - vals) - line = self.acc_bk_stmt_line_obj.browse(self.cr, - self.uid, - line_id) + line_id = self.st_line_obj.create(self.cr, self.uid, vals) + line = self.st_line_obj.browse(self.cr, self.uid, line_id) self.assertFalse(line.partner_id, 'Partner_id must be blank before completion') statement_obj = self.acc_bk_stmt.browse(self.cr, self.uid, self.statement_id) statement_obj.button_auto_completion() - line = self.acc_bk_stmt_line_obj.browse(self.cr, - self.uid, - line_id) + line = self.st_line_obj.browse(self.cr, self.uid, line_id) self.assertEquals(self.partner_id, line.partner_id['id'], 'Missing expected partner id after ' 'completion') @@ -118,15 +111,13 @@ class bankaccount_completion(common.TransactionCase): 'statement_id': self.statement_id, 'partner_acc_number': 'BE38a7330.4038-5372.', } - line_id = self.acc_bk_stmt_line_obj.create(self.cr, - self.uid, - vals) - line = self.acc_bk_stmt_line_obj.browse(self.cr, self.uid, line_id) + line_id = self.st_line_obj.create(self.cr, self.uid, vals) + line = self.st_line_obj.browse(self.cr, self.uid, line_id) self.assertFalse(line.partner_id, 'Partner_id must be blank before completion') statement_obj = self.acc_bk_stmt.browse(self.cr, self.uid, self.statement_id) statement_obj.button_auto_completion() - line = self.acc_bk_stmt_line_obj.browse(self.cr, self.uid, line_id) + line = self.st_line_obj.browse(self.cr, self.uid, line_id) self.assertFalse(line.partner_id.id) From f34f3fbbd64132bae8e7a0690fcb0c2ffc677c2e Mon Sep 17 00:00:00 2001 From: Laurent Mignon Date: Mon, 4 Aug 2014 15:32:34 +0200 Subject: [PATCH 08/84] [FIX] improve code quality --- .../statement.py | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/account_statement_bankaccount_completion/statement.py b/account_statement_bankaccount_completion/statement.py index 07895a29..3c40204f 100644 --- a/account_statement_bankaccount_completion/statement.py +++ b/account_statement_bankaccount_completion/statement.py @@ -54,9 +54,9 @@ class AccountStatementCompletionRule(Model): partner_acc_number = st_line['partner_acc_number'] if not partner_acc_number: return {} - st_obj = self.pool.get('account.bank.statement.line') + st_obj = self.pool['account.bank.statement.line'] res = {} - res_bank_obj = self.pool.get('res.partner.bank') + res_bank_obj = self.pool['res.partner.bank'] ids = res_bank_obj.search_by_acc_number(cr, uid, partner_acc_number, @@ -74,19 +74,13 @@ class AccountStatementCompletionRule(Model): ids[0], context=context).partner_id res['partner_id'] = partner.id - profile_id = st_line['profile_id'] - m_acc_id = st_line['master_account_id'] - partner_id = res.get('partner_id', False) - line_type = st_line['type'] - amout = st_line['amount'] if st_line['amount'] else 0.0 - st_vals = st_obj.get_values_for_line(cr, - uid, - profile_id=profile_id, - master_account_id=m_acc_id, - partner_id=partner_id, - line_type=line_type, - amount=amout, - context=context) + st_vals = st_obj.get_values_for_line( + cr, uid, profile_id=st_line['profile_id'], + master_account_id=st_line['master_account_id'], + partner_id=res.get('partner_id', False), + line_type=st_line['type'], + amount=st_line['amount'] if st_line['amount'] else 0.0, + context=context) res.update(st_vals) return res @@ -95,8 +89,6 @@ class AccountStatementLine(Model): _inherit = "account.bank.statement.line" _columns = { - # 'additional_bank_fields' : fields.serialized('Additional infos from - # bank', help="Used by completion and import system."), 'partner_acc_number': fields.sparse( type='char', string='Account Number', From 410c8c47b32def08ce420587d0b801a433c9caec Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (aka lmi)" Date: Wed, 6 Aug 2014 16:17:36 +0200 Subject: [PATCH 09/84] [FIX] conflicts incorrectly resolved when merging upstream/7.0 --- .../tests/test_base_completion.py | 98 ++++++++++++------- .../tests/test_regex_account_completion.py | 59 ++++++----- 2 files changed, 95 insertions(+), 62 deletions(-) diff --git a/account_statement_base_completion/tests/test_base_completion.py b/account_statement_base_completion/tests/test_base_completion.py index 19319567..40dbf6ef 100644 --- a/account_statement_base_completion/tests/test_base_completion.py +++ b/account_statement_base_completion/tests/test_base_completion.py @@ -23,22 +23,28 @@ from openerp.tests import common import time from collections import namedtuple -name_completion_case = namedtuple("name_completion_case", ["partner_name", "line_label", "should_match"]) +name_completion_case = namedtuple( + "name_completion_case", ["partner_name", "line_label", "should_match"]) NAMES_COMPLETION_CASES = [ - name_completion_case("Acsone", "Line for Acsone SA", True), - name_completion_case("Acsone", "Line for Acsone", True), - name_completion_case("Acsone", "Acsone for line", True), - name_completion_case("acsone", "Acsone for line", True), - name_completion_case("Acsone SA", "Line for Acsone SA test", True), - name_completion_case("Ac..ne", "Acsone for line", False), - name_completion_case("é@|r{}", "Acsone é@|r{} for line", True), - name_completion_case("Acsone", "A..one for line", False), - name_completion_case("A.one SA", "A.one SA for line", True), - name_completion_case("Acsone SA", "Line for Acsone ([^a-zA-Z0-9 -]) SA test", False), - name_completion_case("Acsone ([^a-zA-Z0-9 -]) SA", "Line for Acsone ([^a-zA-Z0-9 -]) SA test", True), - name_completion_case(r"Acsone (.^$*+?()[{\| -]\) SA", r"Line for Acsone (.^$*+?()[{\| -]\) SA test", True), - name_completion_case("Acšone SA", "Line for Acšone SA test", True), - ] + name_completion_case("Acsone", "Line for Acsone SA", True), + name_completion_case("Acsone", "Line for Acsone", True), + name_completion_case("Acsone", "Acsone for line", True), + name_completion_case("acsone", "Acsone for line", True), + name_completion_case("Acsone SA", "Line for Acsone SA test", True), + name_completion_case("Ac..ne", "Acsone for line", False), + name_completion_case("é@|r{}", "Acsone é@|r{} for line", True), + name_completion_case("Acsone", "A..one for line", False), + name_completion_case("A.one SA", "A.one SA for line", True), + name_completion_case( + "Acsone SA", "Line for Acsone ([^a-zA-Z0-9 -]) SA test", False), + name_completion_case( + "Acsone ([^a-zA-Z0-9 -]) SA", "Line for Acsone ([^a-zA-Z0-9 -]) SA " + "test", True), + name_completion_case( + r"Acsone (.^$*+?()[{\| -]\) SA", r"Line for Acsone (.^$*+?()[{\| -]\) " + r"SA test", True), + name_completion_case("Acšone SA", "Line for Acšone SA test", True), +] class base_completion(common.TransactionCase): @@ -48,8 +54,10 @@ class base_completion(common.TransactionCase): self.company_a = self.browse_ref('base.main_company') self.profile_obj = self.registry("account.statement.profile") self.partner_obj = self.registry("res.partner") - self.account_bank_statement_obj = self.registry("account.bank.statement") - self.acc_bk_stmt_line_obj = self.registry("account.bank.statement.line") + self.account_bank_statement_obj = self.registry( + "account.bank.statement") + self.account_bank_statement_line_obj = self.registry( + "account.bank.statement.line") self.journal_id = self.ref("account.bank_journal") self.partner_id = self.ref('base.main_partner') self.account_id = self.ref("account.a_recv") @@ -57,10 +65,12 @@ class base_completion(common.TransactionCase): def test_name_completion(self): """Test complete partner_id from statement line label - Test the automatic completion of the partner_id based if the name of the partner appears in - the statement line label + Test the automatic completion of the partner_id based if the name of the + partner appears in the statement line label """ - self.completion_rule_id = self.ref('account_statement_base_completion.bank_statement_completion_rule_3') + self.completion_rule_id = self.ref( + 'account_statement_base_completion.' + 'bank_statement_completion_rule_3') # Create the profile self.profile_id = self.profile_obj.create(self.cr, self.uid, { "name": "TEST", @@ -68,30 +78,44 @@ class base_completion(common.TransactionCase): "journal_id": self.journal_id, "rule_ids": [(6, 0, [self.completion_rule_id])]}) # Create a bank statement - self.statement_id = self.account_bank_statement_obj.create(self.cr, self.uid, { - "balance_end_real": 0.0, - "balance_start": 0.0, - "date": time.strftime('%Y-%m-%d'), - "journal_id": self.journal_id, - "profile_id": self.profile_id - }) + self.statement_id = self.account_bank_statement_obj.create( + self.cr, self.uid, { + "balance_end_real": 0.0, + "balance_start": 0.0, + "date": time.strftime('%Y-%m-%d'), + "journal_id": self.journal_id, + "profile_id": self.profile_id + }) for case in NAMES_COMPLETION_CASES: - self.partner_obj.write(self.cr, self.uid, self.partner_id, {'name': case.partner_name}) - statement_line_id = self.acc_bk_stmt_line_obj.create(self.cr, self.uid, { + self.partner_obj.write( + self.cr, self.uid, self.partner_id, {'name': case.partner_name}) + statement_line_id = self.account_bank_statement_line_obj.create( + self.cr, self.uid, { 'amount': 1000.0, 'name': case.line_label, 'ref': 'My ref', 'statement_id': self.statement_id, }) - statement_line = self.acc_bk_stmt_line_obj.browse(self.cr, self.uid, statement_line_id) - self.assertFalse(statement_line.partner_id, "Partner_id must be blank before completion") - statement_obj = self.account_bank_statement_obj.browse(self.cr, self.uid, self.statement_id) + statement_line = self.account_bank_statement_line_obj.browse( + self.cr, self.uid, statement_line_id) + self.assertFalse( + statement_line.partner_id, + "Partner_id must be blank before completion") + statement_obj = self.account_bank_statement_obj.browse( + self.cr, self.uid, self.statement_id) statement_obj.button_auto_completion() - statement_line = self.acc_bk_stmt_line_obj.browse(self.cr, self.uid, statement_line_id) + statement_line = self.account_bank_statement_line_obj.browse( + self.cr, self.uid, statement_line_id) if case.should_match: - self.assertEquals(self.partner_id, statement_line.partner_id['id'], - "Missing expected partner id after completion (partner_name: %s, line_name: %s)" % (case.partner_name, case.line_label)) + self.assertEquals( + self.partner_id, statement_line.partner_id['id'], + "Missing expected partner id after completion " + "(partner_name: %s, line_name: %s)" % + (case.partner_name, case.line_label)) else: - self.assertNotEquals(self.partner_id, statement_line.partner_id['id'], - "Partner id should be empty after completion(partner_name: %s, line_name: %s)" % (case.partner_name, case.line_label)) + self.assertNotEquals( + self.partner_id, statement_line.partner_id['id'], + "Partner id should be empty after completion(partner_name: " + "%s, line_name: %s)" % (case.partner_name, case.line_label)) + diff --git a/account_statement_regex_account_completion/tests/test_regex_account_completion.py b/account_statement_regex_account_completion/tests/test_regex_account_completion.py index cfe66848..ea3af52c 100644 --- a/account_statement_regex_account_completion/tests/test_regex_account_completion.py +++ b/account_statement_regex_account_completion/tests/test_regex_account_completion.py @@ -36,34 +36,38 @@ ACC_NUMBER = "BE38733040385372" class test_regex_account_completion(common.TransactionCase): def prepare(self): - self.account_bank_statement_obj = self.registry("account.bank.statement") - self.acc_bk_stmt_line_obj = self.registry("account.bank.statement.line") + self.st_obj = self.registry( + "account.bank.statement") + self.st_line_obj = self.registry( + "account.bank.statement.line") self.account_id = self.ref('account.a_expense') # create the completion rule rule_vals = {'function_to_call': 'set_account', 'regex': '^My statement', 'account_id': self.account_id} - completion_rule_id = self.registry("account.statement.completion.rule").create(self.cr, self.uid, rule_vals) - + completion_rule_id = self.registry( + "account.statement.completion.rule").create( + self.cr, self.uid, rule_vals) # Create the profile journal_id = self.ref("account.bank_journal") - profile_id = self.registry("account.statement.profile").create(self.cr, self.uid, { - "name": "TEST", - "commission_account_id": self.ref("account.a_recv"), - "journal_id": journal_id, - "rule_ids": [(6, 0, [completion_rule_id])]}) - + profile_id = self.registry("account.statement.profile").create( + self.cr, self.uid, { + "name": "TEST", + "commission_account_id": self.ref("account.a_recv"), + "journal_id": journal_id, + "rule_ids": [(6, 0, [completion_rule_id])] + }) # Create a bank statement - self.statement_id = self.account_bank_statement_obj.create(self.cr, self.uid, { - "balance_end_real": 0.0, - "balance_start": 0.0, - "date": time.strftime('%Y-%m-%d'), - "journal_id": journal_id, - "profile_id": profile_id - }) - + self.statement_id = self.st_obj.create( + self.cr, self.uid, { + "balance_end_real": 0.0, + "balance_start": 0.0, + "date": time.strftime('%Y-%m-%d'), + "journal_id": journal_id, + "profile_id": profile_id + }) # Create two bank statement lines - self.statement_line1_id = self.acc_bk_stmt_line_obj.create(self.cr, self.uid, { + self.statement_line1_id = self.st_line_obj.create(self.cr, self.uid, { 'amount': 1000.0, 'name': 'My statement', 'ref': 'My ref', @@ -71,7 +75,7 @@ class test_regex_account_completion(common.TransactionCase): 'partner_acc_number': ACC_NUMBER }) - self.statement_line2_id = self.acc_bk_stmt_line_obj.create(self.cr, self.uid, { + self.statement_line2_id = self.st_line_obj.create(self.cr, self.uid, { 'amount': 2000.0, 'name': 'My second statement', 'ref': 'My second ref', @@ -83,9 +87,14 @@ class test_regex_account_completion(common.TransactionCase): """Test the automatic completion on account """ self.prepare() - statement_obj = self.account_bank_statement_obj.browse(self.cr, self.uid, self.statement_id) + statement_obj = self.st_obj.browse(self.cr, self.uid, self.statement_id) statement_obj.button_auto_completion() - statement_line1 = self.acc_bk_stmt_line_obj.browse(self.cr, self.uid, self.statement_line1_id) - self.assertEquals(self.account_id, statement_line1.account_id.id, "The account should be the account of the completion") - statement_line2 = self.acc_bk_stmt_line_obj.browse(self.cr, self.uid, self.statement_line2_id) - self.assertNotEqual(self.account_id, statement_line2.account_id.id, "The account should be not the account of the completion") + statement_line1 = self.st_line_obj.browse( + self.cr, self.uid, self.statement_line1_id) + self.assertEquals(self.account_id, statement_line1.account_id.id, + "The account should be the account of the completion") + statement_line2 = self.st_line_obj.browse( + self.cr, self.uid, self.statement_line2_id) + self.assertNotEqual(self.account_id, statement_line2.account_id.id, + "The account should be not the account of the " + "completion") From aed71450efb48f9e3eb503011db1ed8892bff555 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (aka lmi)" Date: Wed, 6 Aug 2014 16:20:11 +0200 Subject: [PATCH 10/84] [FIX] conflicts incorrectly resolved when merging upstream/7.0 --- account_statement_base_completion/tests/test_base_completion.py | 1 - 1 file changed, 1 deletion(-) diff --git a/account_statement_base_completion/tests/test_base_completion.py b/account_statement_base_completion/tests/test_base_completion.py index 40dbf6ef..acbabbb0 100644 --- a/account_statement_base_completion/tests/test_base_completion.py +++ b/account_statement_base_completion/tests/test_base_completion.py @@ -118,4 +118,3 @@ class base_completion(common.TransactionCase): self.partner_id, statement_line.partner_id['id'], "Partner id should be empty after completion(partner_name: " "%s, line_name: %s)" % (case.partner_name, case.line_label)) - From 146331f10c9e8c03af664a0bfbd3f810e95287a1 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Mon, 11 Aug 2014 12:47:27 +0200 Subject: [PATCH 11/84] [FIX] correct partner used in statement import for refunds --- account_statement_transactionid_completion/statement.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/account_statement_transactionid_completion/statement.py b/account_statement_transactionid_completion/statement.py index 8fcb13d2..fbe65e8d 100644 --- a/account_statement_transactionid_completion/statement.py +++ b/account_statement_transactionid_completion/statement.py @@ -110,7 +110,13 @@ class AccountStatementCompletionRule(Model): elif len(invoice_id) == 1: invoice = invoice_obj.browse(cr, uid, invoice_id[0], context=context) - res['partner_id'] = invoice.partner_id.id + # FIXME use only commercial_partner_id of invoice in 7.1 + # this is for backward compatibility in 7.0 before + # the refactoring of res.partner + if hasattr(invoice, 'commercial_partner_id'): + res['partner_id'] = invoice.commercial_partner_id.id + else: + res['partner_id'] = invoice.partner_id.id # we want the move to have the same ref than the found # invoice's move, thus it will be easier to link them for the # accountants From dda528671c1652f9a197a736da26fd33a3713f64 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Mon, 11 Aug 2014 14:23:17 +0200 Subject: [PATCH 12/84] new comment on last change --- account_statement_transactionid_completion/statement.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/account_statement_transactionid_completion/statement.py b/account_statement_transactionid_completion/statement.py index fbe65e8d..109b53cf 100644 --- a/account_statement_transactionid_completion/statement.py +++ b/account_statement_transactionid_completion/statement.py @@ -110,9 +110,12 @@ class AccountStatementCompletionRule(Model): elif len(invoice_id) == 1: invoice = invoice_obj.browse(cr, uid, invoice_id[0], context=context) - # FIXME use only commercial_partner_id of invoice in 7.1 - # this is for backward compatibility in 7.0 before - # the refactoring of res.partner + # if account_report_company is installed, the field to be + # used as partner is the commercial partner; otherwise, + # the basic partner must be used. + # + # This is used to keep consistent behavior from the module + # account_statement_base_completion. if hasattr(invoice, 'commercial_partner_id'): res['partner_id'] = invoice.commercial_partner_id.id else: From 4871fc66f7a79f3f950545d4082dfcda046e128f Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Mon, 11 Aug 2014 14:37:48 +0200 Subject: [PATCH 13/84] [FIX] add dependency on account_report_company + remove unnecessary conditions --- account_statement_base_completion/__openerp__.py | 3 ++- account_statement_base_completion/statement.py | 8 +------- .../statement.py | 11 +---------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/account_statement_base_completion/__openerp__.py b/account_statement_base_completion/__openerp__.py index 36988cac..ffb46563 100644 --- a/account_statement_base_completion/__openerp__.py +++ b/account_statement_base_completion/__openerp__.py @@ -26,7 +26,8 @@ 'maintainer': 'Camptocamp', 'category': 'Finance', 'complexity': 'normal', - 'depends': ['account_statement_ext'], + 'depends': ['account_statement_ext', + 'account_report_company'], 'description': """ The goal of this module is to improve the basic bank statement, help dealing with huge volume of reconciliation by providing basic rules to identify the diff --git a/account_statement_base_completion/statement.py b/account_statement_base_completion/statement.py index ba1771f5..aa7849bf 100644 --- a/account_statement_base_completion/statement.py +++ b/account_statement_base_completion/statement.py @@ -189,13 +189,7 @@ class AccountStatementCompletionRule(orm.Model): res = {} inv = self._find_invoice(cr, uid, line, inv_type, context=context) if inv: - # FIXME use only commercial_partner_id of invoice in 7.1 - # this is for backward compatibility in 7.0 before - # the refactoring of res.partner - if hasattr(inv, 'commercial_partner_id'): - partner_id = inv.commercial_partner_id.id - else: - partner_id = inv.partner_id.id + partner_id = inv.commercial_partner_id.id res = {'partner_id': partner_id, 'account_id': inv.account_id.id, 'type': inv_type} diff --git a/account_statement_transactionid_completion/statement.py b/account_statement_transactionid_completion/statement.py index 109b53cf..cc39f9ae 100644 --- a/account_statement_transactionid_completion/statement.py +++ b/account_statement_transactionid_completion/statement.py @@ -110,16 +110,7 @@ class AccountStatementCompletionRule(Model): elif len(invoice_id) == 1: invoice = invoice_obj.browse(cr, uid, invoice_id[0], context=context) - # if account_report_company is installed, the field to be - # used as partner is the commercial partner; otherwise, - # the basic partner must be used. - # - # This is used to keep consistent behavior from the module - # account_statement_base_completion. - if hasattr(invoice, 'commercial_partner_id'): - res['partner_id'] = invoice.commercial_partner_id.id - else: - res['partner_id'] = invoice.partner_id.id + res['partner_id'] = invoice.commercial_partner_id.id # we want the move to have the same ref than the found # invoice's move, thus it will be easier to link them for the # accountants From 42fdf1d77f2c99b22d9cedb143ef0e6fd2e908ab Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 20 Aug 2014 17:20:22 +0200 Subject: [PATCH 14/84] [FIX] account_statement_ext: Catch also old exceptions (osv.except_osv) --- account_statement_ext/statement.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/account_statement_ext/statement.py b/account_statement_ext/statement.py index 68d2eb72..3c8012d8 100644 --- a/account_statement_ext/statement.py +++ b/account_statement_ext/statement.py @@ -19,7 +19,7 @@ # ############################################################################## import openerp.addons.account.account_bank_statement as stat_mod -from openerp.osv import fields, orm +from openerp.osv import fields, orm, osv from openerp.tools.translate import _ @@ -420,7 +420,7 @@ class AccountBankStatement(orm.Model): self.create_move_from_st_line( cr, uid, st_line.id, company_currency_id, st_line_number, context) - except orm.except_orm, exc: + except (orm.except_orm, osv.except_osv), exc: msg = "Line ID %s with ref %s had following error: %s" % ( st_line.id, st_line.ref, exc.value) errors_stack.append(msg) @@ -606,7 +606,7 @@ class AccountBankStatementLine(orm.Model): local_context['account_period_prefer_normal'] = True try: periods = period_obj.find(cr, uid, dt=date, context=local_context) - except orm.except_orm: + except (orm.except_orm, osv.except_osv): # if no period defined, we are certainly at installation time return False return periods and periods[0] or False From 76d4b6720ba9c9b0abc9bb0923e971167daac0b5 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 21 Aug 2014 02:10:01 +0200 Subject: [PATCH 15/84] Exception variable in 2.7 syntax --- account_statement_ext/statement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_statement_ext/statement.py b/account_statement_ext/statement.py index 3c8012d8..3c0b537d 100644 --- a/account_statement_ext/statement.py +++ b/account_statement_ext/statement.py @@ -420,7 +420,7 @@ class AccountBankStatement(orm.Model): self.create_move_from_st_line( cr, uid, st_line.id, company_currency_id, st_line_number, context) - except (orm.except_orm, osv.except_osv), exc: + except (orm.except_orm, osv.except_osv) as exc: msg = "Line ID %s with ref %s had following error: %s" % ( st_line.id, st_line.ref, exc.value) errors_stack.append(msg) From c4a1f50e50ac0bdbd858db640d0d76b02ffc3944 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 18 Jul 2014 15:59:19 +0200 Subject: [PATCH 16/84] Reconcile optimization: avoid to do a partial reconcile if it was already reconciled with the same lines Before this optimization, the same partial reconciliation were created at each run of the automatic reconcile. --- account_easy_reconcile/base_reconciliation.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/account_easy_reconcile/base_reconciliation.py b/account_easy_reconcile/base_reconciliation.py index 6145720a..7920a242 100644 --- a/account_easy_reconcile/base_reconciliation.py +++ b/account_easy_reconcile/base_reconciliation.py @@ -71,6 +71,7 @@ class EasyReconcileBase(orm.AbstractModel): 'name', 'partner_id', 'account_id', + 'reconcile_partial_id', 'move_id') return ["account_move_line.%s" % col for col in aml_cols] @@ -195,6 +196,19 @@ class EasyReconcileBase(orm.AbstractModel): context=rec_ctx) return True, True elif allow_partial: + # Check if the group of move lines was already partially + # reconciled and if all the lines were the same, in such + # case, just skip the group and consider it as partially + # reconciled (no change). + existing_partial_id = lines[0]['reconcile_partial_id'] + if existing_partial_id: + partial_line_ids = set(ml_obj.search( + cr, uid, + [('reconcile_partial_id', '=', existing_partial_id)], + context=context)) + if set(line_ids) == partial_line_ids: + return True, False + ml_obj.reconcile_partial( cr, uid, line_ids, From b5e62298ae7d4b6f6ebbb9a0f4ba01d3ffa7f5b6 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Mon, 21 Jul 2014 12:08:34 +0200 Subject: [PATCH 17/84] [FIX] added check for size before list access + corrected base columns for transaction ref --- .../base_advanced_reconciliation.py | 18 +++++------------- account_easy_reconcile/base_reconciliation.py | 17 +++++++++-------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/account_advanced_reconcile_transaction_ref/base_advanced_reconciliation.py b/account_advanced_reconcile_transaction_ref/base_advanced_reconciliation.py index c5feb2ac..e3f9e37a 100644 --- a/account_advanced_reconcile_transaction_ref/base_advanced_reconciliation.py +++ b/account_advanced_reconcile_transaction_ref/base_advanced_reconciliation.py @@ -30,16 +30,8 @@ class EasyReconcileAdvanced(orm.AbstractModel): """ Mandatory columns for move lines queries An extra column aliased as ``key`` should be defined in each query.""" - aml_cols = ( - 'id', - 'debit', - 'credit', - 'date', - 'period_id', - 'ref', - 'name', - 'partner_id', - 'account_id', - 'move_id', - 'transaction_ref') - return ["account_move_line.%s" % col for col in aml_cols] + aml_cols = super(easy_reconcile_advanced, self).\ + _base_columns(rec) + aml_cols += ['account_move_line.transaction_ref'] + return aml_cols + diff --git a/account_easy_reconcile/base_reconciliation.py b/account_easy_reconcile/base_reconciliation.py index 7920a242..9aeb6d44 100644 --- a/account_easy_reconcile/base_reconciliation.py +++ b/account_easy_reconcile/base_reconciliation.py @@ -200,14 +200,15 @@ class EasyReconcileBase(orm.AbstractModel): # reconciled and if all the lines were the same, in such # case, just skip the group and consider it as partially # reconciled (no change). - existing_partial_id = lines[0]['reconcile_partial_id'] - if existing_partial_id: - partial_line_ids = set(ml_obj.search( - cr, uid, - [('reconcile_partial_id', '=', existing_partial_id)], - context=context)) - if set(line_ids) == partial_line_ids: - return True, False + if lines: + existing_partial_id = lines[0]['reconcile_partial_id'] + if existing_partial_id: + partial_line_ids = set(ml_obj.search( + cr, uid, + [('reconcile_partial_id', '=', existing_partial_id)], + context=context)) + if set(line_ids) == partial_line_ids: + return True, False ml_obj.reconcile_partial( cr, uid, From 7f76d5a6d3b760bb6d33a0caef46ad8705116c2a Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 22 Aug 2014 16:19:24 +0200 Subject: [PATCH 18/84] Slightly improved styling --- .../base_advanced_reconciliation.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/account_advanced_reconcile_transaction_ref/base_advanced_reconciliation.py b/account_advanced_reconcile_transaction_ref/base_advanced_reconciliation.py index e3f9e37a..240df83d 100644 --- a/account_advanced_reconcile_transaction_ref/base_advanced_reconciliation.py +++ b/account_advanced_reconcile_transaction_ref/base_advanced_reconciliation.py @@ -30,8 +30,6 @@ class EasyReconcileAdvanced(orm.AbstractModel): """ Mandatory columns for move lines queries An extra column aliased as ``key`` should be defined in each query.""" - aml_cols = super(easy_reconcile_advanced, self).\ - _base_columns(rec) - aml_cols += ['account_move_line.transaction_ref'] + aml_cols = super(EasyReconcileAdvanced, self)._base_columns(rec) + aml_cols.append('account_move_line.transaction_ref') return aml_cols - From da08af927afbcaa58442c5bfb9b5916d07d007b9 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 18 Jul 2014 11:05:29 +0200 Subject: [PATCH 19/84] The history does not store the reconciled entries Because the new reconciliations are committed in a different transaction than the one used to create the history. Move the new cursor initialization to the outer method 'run_reconcile()' so everything is enclosed in the same transaction. --- account_advanced_reconcile/__init__.py | 1 - account_advanced_reconcile/__openerp__.py | 2 +- .../base_advanced_reconciliation.py | 32 +------- account_easy_reconcile/__init__.py | 1 + account_easy_reconcile/__openerp__.py | 4 +- account_easy_reconcile/easy_reconcile.py | 78 ++++++++++++------- .../res_config.py | 0 .../res_config_view.xml | 0 8 files changed, 58 insertions(+), 60 deletions(-) rename {account_advanced_reconcile => account_easy_reconcile}/res_config.py (100%) rename {account_advanced_reconcile => account_easy_reconcile}/res_config_view.xml (100%) diff --git a/account_advanced_reconcile/__init__.py b/account_advanced_reconcile/__init__.py index af0e2c47..5ee0093a 100644 --- a/account_advanced_reconcile/__init__.py +++ b/account_advanced_reconcile/__init__.py @@ -23,4 +23,3 @@ import easy_reconcile import base_advanced_reconciliation import advanced_reconciliation -import res_config # noqa diff --git a/account_advanced_reconcile/__openerp__.py b/account_advanced_reconcile/__openerp__.py index 5c45353c..6d448319 100644 --- a/account_advanced_reconcile/__openerp__.py +++ b/account_advanced_reconcile/__openerp__.py @@ -75,7 +75,7 @@ many offices. """, 'website': 'http://www.camptocamp.com', 'data': ['easy_reconcile_view.xml', - 'res_config_view.xml'], + ], 'test': [], 'images': [], 'installable': True, diff --git a/account_advanced_reconcile/base_advanced_reconciliation.py b/account_advanced_reconcile/base_advanced_reconciliation.py index e6f8ced9..50a8b3d6 100644 --- a/account_advanced_reconcile/base_advanced_reconciliation.py +++ b/account_advanced_reconcile/base_advanced_reconciliation.py @@ -23,11 +23,6 @@ import logging from itertools import product from openerp.osv import orm -from openerp import pooler -from openerp.tools.translate import _ - - -_logger = logging.getLogger(__name__) class easy_reconcile_advanced(orm.AbstractModel): @@ -222,29 +217,10 @@ class easy_reconcile_advanced(orm.AbstractModel): cr, uid, rec, move_line, op, matchers, context=context)] def _action_rec(self, cr, uid, rec, context=None): - # we use a new cursor to be able to commit the reconciliation - # often. We have to create it here and not later to avoid problems - # where the new cursor sees the lines as reconciles but the old one - # does not. - if context is None: - context = {} - ctx = context.copy() - ctx['commit_every'] = ( - rec.journal_id.company_id.reconciliation_commit_every - ) - if ctx['commit_every']: - new_cr = pooler.get_db(cr.dbname).cursor() - else: - new_cr = cr - try: - credit_lines = self._query_credit(new_cr, uid, rec, context=ctx) - debit_lines = self._query_debit(new_cr, uid, rec, context=ctx) - result = self._rec_auto_lines_advanced( - new_cr, uid, rec, credit_lines, debit_lines, context=ctx) - finally: - if ctx['commit_every']: - new_cr.commit() - new_cr.close() + credit_lines = self._query_credit(cr, uid, rec, context=context) + debit_lines = self._query_debit(cr, uid, rec, context=context) + result = self._rec_auto_lines_advanced( + cr, uid, rec, credit_lines, debit_lines, context=context) return result def _skip_line(self, cr, uid, rec, move_line, context=None): diff --git a/account_easy_reconcile/__init__.py b/account_easy_reconcile/__init__.py index b648751f..2b9e5980 100755 --- a/account_easy_reconcile/__init__.py +++ b/account_easy_reconcile/__init__.py @@ -23,3 +23,4 @@ import easy_reconcile import base_reconciliation import simple_reconciliation import easy_reconcile_history +import res_config # noqa diff --git a/account_easy_reconcile/__openerp__.py b/account_easy_reconcile/__openerp__.py index a53662c5..198fcf30 100755 --- a/account_easy_reconcile/__openerp__.py +++ b/account_easy_reconcile/__openerp__.py @@ -58,7 +58,9 @@ allows multiple lines and partial. "data": ["easy_reconcile.xml", "easy_reconcile_history_view.xml", "security/ir_rule.xml", - "security/ir.model.access.csv"], + "security/ir.model.access.csv", + "res_config_view.xml", + ], 'license': 'AGPL-3', "auto_install": False, "installable": True, diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index 99ed960f..b7570e55 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -21,6 +21,7 @@ from openerp.osv import fields, orm from openerp.tools.translate import _ +from openerp import pooler class EasyReconcileOptions(orm.AbstractModel): @@ -208,7 +209,7 @@ class AccountEasyReconcile(orm.Model): 'filter': rec_method.filter} def run_reconcile(self, cr, uid, ids, context=None): - def find_reconcile_ids(fieldname, move_line_ids): + def find_reconcile_ids(cr, fieldname, move_line_ids): if not move_line_ids: return [] sql = ("SELECT DISTINCT " + fieldname + @@ -219,37 +220,56 @@ class AccountEasyReconcile(orm.Model): res = cr.fetchall() return [row[0] for row in res] + # we use a new cursor to be able to commit the reconciliation + # often. We have to create it here and not later to avoid problems + # where the new cursor sees the lines as reconciles but the old one + # does not. + if context is None: + context = {} + for rec in self.browse(cr, uid, ids, context=context): - all_ml_rec_ids = [] - all_ml_partial_ids = [] + ctx = context.copy() + ctx['commit_every'] = ( + rec.account.company_id.reconciliation_commit_every + ) + if ctx['commit_every']: + new_cr = pooler.get_db(cr.dbname).cursor() + else: + new_cr = cr + try: + all_ml_rec_ids = [] + all_ml_partial_ids = [] - for method in rec.reconcile_method: - rec_model = self.pool.get(method.name) - auto_rec_id = rec_model.create( - cr, uid, - self._prepare_run_transient( - cr, uid, method, context=context), + for method in rec.reconcile_method: + rec_model = self.pool.get(method.name) + auto_rec_id = rec_model.create( + new_cr, uid, + self._prepare_run_transient( + new_cr, uid, method, context=context), + context=context) + + ml_rec_ids, ml_partial_ids = rec_model.automatic_reconcile( + new_cr, uid, auto_rec_id, context=ctx) + + all_ml_rec_ids += ml_rec_ids + all_ml_partial_ids += ml_partial_ids + + reconcile_ids = find_reconcile_ids( + new_cr, 'reconcile_id', all_ml_rec_ids) + partial_ids = find_reconcile_ids( + new_cr, 'reconcile_partial_id', all_ml_partial_ids) + + self.pool.get('easy.reconcile.history').create( + new_cr, uid, + {'easy_reconcile_id': rec.id, + 'date': fields.datetime.now(), + 'reconcile_ids': [(4, rid) for rid in reconcile_ids], + 'reconcile_partial_ids': [(4, rid) for rid in partial_ids]}, context=context) - - ml_rec_ids, ml_partial_ids = rec_model.automatic_reconcile( - cr, uid, auto_rec_id, context=context) - - all_ml_rec_ids += ml_rec_ids - all_ml_partial_ids += ml_partial_ids - - reconcile_ids = find_reconcile_ids( - 'reconcile_id', all_ml_rec_ids) - partial_ids = find_reconcile_ids( - 'reconcile_partial_id', all_ml_partial_ids) - - self.pool.get('easy.reconcile.history').create( - cr, - uid, - {'easy_reconcile_id': rec.id, - 'date': fields.datetime.now(), - 'reconcile_ids': [(4, rid) for rid in reconcile_ids], - 'reconcile_partial_ids': [(4, rid) for rid in partial_ids]}, - context=context) + finally: + if ctx['commit_every']: + new_cr.commit() + new_cr.close() return True def _no_history(self, cr, uid, rec, context=None): diff --git a/account_advanced_reconcile/res_config.py b/account_easy_reconcile/res_config.py similarity index 100% rename from account_advanced_reconcile/res_config.py rename to account_easy_reconcile/res_config.py diff --git a/account_advanced_reconcile/res_config_view.xml b/account_easy_reconcile/res_config_view.xml similarity index 100% rename from account_advanced_reconcile/res_config_view.xml rename to account_easy_reconcile/res_config_view.xml From e2c05c68512d6efcfcb8050fd98a668284a8ed3f Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Thu, 31 Jul 2014 13:14:34 +0200 Subject: [PATCH 20/84] remove useless noqa --- account_easy_reconcile/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_easy_reconcile/__init__.py b/account_easy_reconcile/__init__.py index 2b9e5980..87ea0fc3 100755 --- a/account_easy_reconcile/__init__.py +++ b/account_easy_reconcile/__init__.py @@ -23,4 +23,4 @@ import easy_reconcile import base_reconciliation import simple_reconciliation import easy_reconcile_history -import res_config # noqa +import res_config From 9c543fc06f7174808bdf78a1ee8514d0c17274b3 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 22 Aug 2014 16:41:06 +0200 Subject: [PATCH 21/84] Missing declaration of _logger and _ --- account_advanced_reconcile/base_advanced_reconciliation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/account_advanced_reconcile/base_advanced_reconciliation.py b/account_advanced_reconcile/base_advanced_reconciliation.py index 50a8b3d6..46d3fa6f 100644 --- a/account_advanced_reconcile/base_advanced_reconciliation.py +++ b/account_advanced_reconcile/base_advanced_reconciliation.py @@ -23,6 +23,9 @@ import logging from itertools import product from openerp.osv import orm +from openerp.tools.translate import _ + +_logger = logging.getLogger(__name__) class easy_reconcile_advanced(orm.AbstractModel): From f8322fda1e7733fe2910c6f3ebf745f305732b6a Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 22 Aug 2014 16:57:19 +0200 Subject: [PATCH 22/84] Long line --- account_easy_reconcile/easy_reconcile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index b7570e55..327b0bb5 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -264,7 +264,8 @@ class AccountEasyReconcile(orm.Model): {'easy_reconcile_id': rec.id, 'date': fields.datetime.now(), 'reconcile_ids': [(4, rid) for rid in reconcile_ids], - 'reconcile_partial_ids': [(4, rid) for rid in partial_ids]}, + 'reconcile_partial_ids': [(4, rid) for rid in partial_ids], + }, context=context) finally: if ctx['commit_every']: From 3ac15d6fb28c2cda15ab61d3eb2e967ff9289414 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 25 Aug 2014 10:23:44 +0200 Subject: [PATCH 23/84] pep8: E124 closing bracket does not match visual indentation --- account_easy_reconcile/easy_reconcile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index 327b0bb5..78f7977b 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -265,7 +265,7 @@ class AccountEasyReconcile(orm.Model): 'date': fields.datetime.now(), 'reconcile_ids': [(4, rid) for rid in reconcile_ids], 'reconcile_partial_ids': [(4, rid) for rid in partial_ids], - }, + }, context=context) finally: if ctx['commit_every']: From 5ad1ee5a04f49b6665f52ce6cb1e7b4278765fbb Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Tue, 26 Aug 2014 13:27:50 +0200 Subject: [PATCH 24/84] convert the repo to 79 columns --- account_advanced_reconcile/__openerp__.py | 4 +- .../base_advanced_reconciliation.py | 3 +- account_easy_reconcile/easy_reconcile.py | 14 +++---- account_invoice_reference/__openerp__.py | 4 +- .../__openerp__.py | 24 ++++++------ account_statement_base_completion/partner.py | 8 ++-- .../statement.py | 38 ++++++++++--------- .../tests/test_base_completion.py | 12 +++--- account_statement_base_import/__openerp__.py | 4 +- .../parser/file_parser.py | 6 +-- .../parser/generic_file_parser.py | 11 +++--- .../parser/parser.py | 10 ++--- account_statement_base_import/statement.py | 10 +++-- account_statement_commission/__openerp__.py | 6 +-- account_statement_commission/commission.py | 7 ++-- .../statement.py | 4 +- account_statement_ext/__openerp__.py | 4 +- account_statement_ext/statement.py | 25 ++++++------ .../point_of_sale.py | 3 +- account_statement_one_move/statement.py | 3 +- .../tests/test_regex_account_completion.py | 6 ++- .../statement.py | 6 ++- .../__openerp__.py | 10 ++--- .../parser/transactionid_file_parser.py | 6 +-- statement_voucher_killer/voucher.py | 4 +- 25 files changed, 125 insertions(+), 107 deletions(-) diff --git a/account_advanced_reconcile/__openerp__.py b/account_advanced_reconcile/__openerp__.py index 6d448319..d0be8d59 100644 --- a/account_advanced_reconcile/__openerp__.py +++ b/account_advanced_reconcile/__openerp__.py @@ -64,8 +64,8 @@ The base class to find the reconciliations is built to be as efficient as possible. So basically, if you have an invoice with 3 payments (one per month), the first -month, it will partial reconcile the debit move line with the first payment, the -second month, it will partial reconcile the debit move line with 2 first +month, it will partial reconcile the debit move line with the first payment, +the second month, it will partial reconcile the debit move line with 2 first payments, the third month, it will make the full reconciliation. This module is perfectly adapted for E-Commerce business where a big volume of diff --git a/account_advanced_reconcile/base_advanced_reconciliation.py b/account_advanced_reconcile/base_advanced_reconciliation.py index 46d3fa6f..a9fe439c 100644 --- a/account_advanced_reconcile/base_advanced_reconciliation.py +++ b/account_advanced_reconcile/base_advanced_reconciliation.py @@ -186,7 +186,8 @@ class easy_reconcile_advanced(orm.AbstractModel): If all the matchers match for a move line and an opposite move line, they are candidate for a reconciliation. """ - opp_matchers = self._opposite_matchers(cr, uid, rec, opposite_move_line, + opp_matchers = self._opposite_matchers(cr, uid, rec, + opposite_move_line, context=context) for matcher in matchers: try: diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index 78f7977b..1520dda5 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -259,14 +259,12 @@ class AccountEasyReconcile(orm.Model): partial_ids = find_reconcile_ids( new_cr, 'reconcile_partial_id', all_ml_partial_ids) - self.pool.get('easy.reconcile.history').create( - new_cr, uid, - {'easy_reconcile_id': rec.id, - 'date': fields.datetime.now(), - 'reconcile_ids': [(4, rid) for rid in reconcile_ids], - 'reconcile_partial_ids': [(4, rid) for rid in partial_ids], - }, - context=context) + self.pool.get('easy.reconcile.history').create(new_cr, uid, { + 'easy_reconcile_id': rec.id, + 'date': fields.datetime.now(), + 'reconcile_ids': [(4, rid) for rid in reconcile_ids], + 'reconcile_partial_ids': [(4, rid) for rid in partial_ids], + }, context=context) finally: if ctx['commit_every']: new_cr.commit() diff --git a/account_invoice_reference/__openerp__.py b/account_invoice_reference/__openerp__.py index fc12a9ca..2ad8758d 100644 --- a/account_invoice_reference/__openerp__.py +++ b/account_invoice_reference/__openerp__.py @@ -39,8 +39,8 @@ origin, free reference) and above all, to understand which field will be copied in the reference field of the move and move lines. The approach here is to state simple rules with one concern: consistency. -The reference of the move lines must be the number of the document at their very -origin (number of a sales order, of an external document like a supplier +The reference of the move lines must be the number of the document at their +very origin (number of a sales order, of an external document like a supplier invoice, ...). The goal is for the accountant to be able to trace to the source document from a ledger). The description of a line should always be... well, a description. Not a number diff --git a/account_statement_base_completion/__openerp__.py b/account_statement_base_completion/__openerp__.py index 36988cac..229b992e 100644 --- a/account_statement_base_completion/__openerp__.py +++ b/account_statement_base_completion/__openerp__.py @@ -31,8 +31,8 @@ The goal of this module is to improve the basic bank statement, help dealing with huge volume of reconciliation by providing basic rules to identify the partner of a bank statement line. - Each bank statement profile can have its own rules to be applied according to a - sequence order. + Each bank statement profile can have its own rules to be applied according to + a sequence order. Some basic rules are provided in this module: @@ -41,15 +41,15 @@ 2) Match from statement line label (based on partner name) 3) Match from statement line reference (based on Invoice number) - You can easily override this module and add your own rules in your own one. The - basic rules only fill in the partner, but you can use them to fill in any - value of the line (in the future, we will add a rule to automatically match and - reconcile the line). + You can easily override this module and add your own rules in your own one. + The basic rules only fill in the partner, but you can use them to fill in + any value of the line (in the future, we will add a rule to automatically + match and reconcile the line). It adds as well a label on the bank statement line (on which the pre-define - rules can match) and a char field on the partner called 'Bank Statement Label'. - Using the pre-define rules, you will be able to match various labels for a - partner. + rules can match) and a char field on the partner called 'Bank Statement + Label'. Using the pre-define rules, you will be able to match various + labels for a partner. The reference of the line is always used by the reconciliation process. We're supposed to copy there (or write manually) the matching string. This can be: @@ -60,9 +60,9 @@ reconciliation process. - TODO: The rules that look for invoices to find out the partner should take back - the payable / receivable account from there directly instead of retrieving it - from partner properties ! + TODO: The rules that look for invoices to find out the partner should take + back the payable / receivable account from there directly instead of + retrieving it from partner properties! """, 'website': 'http://www.camptocamp.com', 'data': [ diff --git a/account_statement_base_completion/partner.py b/account_statement_base_completion/partner.py index 2670d8aa..3f371c78 100644 --- a/account_statement_base_completion/partner.py +++ b/account_statement_base_completion/partner.py @@ -32,8 +32,8 @@ class ResPartner(orm.Model): 'bank_statement_label': fields.char( 'Bank Statement Label', size=100, help="Enter the various label found on your bank statement " - "separated by a ; If one of this label is include in the bank " - "statement line, the partner will be automatically filled (as " - "long as you use this method/rules in your statement " - "profile)."), + "separated by a ; If one of this label is include in the " + "bank statement line, the partner will be automatically " + "filled (as long as you use this method/rules in your " + "statement profile)."), } diff --git a/account_statement_base_completion/statement.py b/account_statement_base_completion/statement.py index ba1771f5..1131f150 100644 --- a/account_statement_base_completion/statement.py +++ b/account_statement_base_completion/statement.py @@ -124,7 +124,9 @@ class AccountStatementCompletionRule(orm.Model): _order = "sequence asc" def _get_functions(self, cr, uid, context=None): - """List of available methods for rules. Override this to add you own.""" + """List of available methods for rules. + + Override this to add you own.""" return [ ('get_from_ref_and_invoice', 'From line reference (based on customer invoice number)'), @@ -225,8 +227,8 @@ class AccountStatementCompletionRule(orm.Model): # Should be private but data are initialised with no update XML def get_from_ref_and_invoice(self, cr, uid, line, context=None): """Match the partner based on the invoice number and the reference of - the statement line. Then, call the generic get_values_for_line method to - complete other values. If more than one partner matched, raise the + the statement line. Then, call the generic get_values_for_line method + to complete other values. If more than one partner matched, raise the ErrorTooManyPartner error. :param dict line: read of the concerned account.bank.statement.line @@ -242,11 +244,11 @@ class AccountStatementCompletionRule(orm.Model): # Should be private but data are initialised with no update XML def get_from_label_and_partner_field(self, cr, uid, st_line, context=None): """ - Match the partner based on the label field of the statement line - and the text defined in the 'bank_statement_label' field of the partner. - Remember that we can have values separated with ; Then, call the generic - get_values_for_line method to complete other values. - If more than one partner matched, raise the ErrorTooManyPartner error. + Match the partner based on the label field of the statement line and + the text defined in the 'bank_statement_label' field of the partner. + Remember that we can have values separated with ; Then, call the + generic get_values_for_line method to complete other values. If more + than one partner matched, raise the ErrorTooManyPartner error. :param dict st_line: read of the concerned account.bank.statement.line :return: @@ -303,10 +305,10 @@ class AccountStatementCompletionRule(orm.Model): return res def get_from_label_and_partner_name(self, cr, uid, st_line, context=None): - """Match the partner based on the label field of the statement line - and the name of the partner. Then, call the generic get_values_for_line - method to complete other values. If more than one partner matched, raise - the ErrorTooManyPartner error. + """Match the partner based on the label field of the statement line and + the name of the partner. Then, call the generic get_values_for_line + method to complete other values. If more than one partner matched, + raise the ErrorTooManyPartner error. :param dict st_line: read of the concerned account.bank.statement.line :return: @@ -386,9 +388,9 @@ class AccountStatement(orm.Model): class AccountStatementLine(orm.Model): """ - Add sparse field on the statement line to allow to store all the - bank infos that are given by a bank/office. You can then add you own in your - module. The idea here is to store all bank/office infos in the + Add sparse field on the statement line to allow to store all the bank infos + that are given by a bank/office. You can then add you own in your module. + The idea here is to store all bank/office infos in the additionnal_bank_fields serialized field when importing the file. If many values, add a tab in the bank statement line to store your specific one. Have a look in account_statement_base_import module to see how we've done @@ -449,7 +451,8 @@ class AccountStatementLine(orm.Model): statement_line_obj = self.pool['account.bank.statement.line'] model_cols = statement_line_obj._columns avail = [ - k for k, col in model_cols.iteritems() if not hasattr(col, '_fnct')] + k for k, col in model_cols.iteritems() if not hasattr(col, '_fnct') + ] keys = [k for k in statement_store[0].keys() if k in avail] # add sparse fields.. if include_serializable: @@ -635,7 +638,8 @@ class AccountBankStatement(orm.Model): st += ''.join(traceback.format_tb(trbk, 30)) _logger.error(st) if res: - # stat_line_obj.write(cr, uid, [line.id], vals, context=ctx) + # stat_line_obj.write(cr, uid, [line.id], vals, + # context=ctx) try: stat_line_obj._update_line( cr, uid, res, context=context) diff --git a/account_statement_base_completion/tests/test_base_completion.py b/account_statement_base_completion/tests/test_base_completion.py index acbabbb0..9fd9adb5 100644 --- a/account_statement_base_completion/tests/test_base_completion.py +++ b/account_statement_base_completion/tests/test_base_completion.py @@ -65,8 +65,8 @@ class base_completion(common.TransactionCase): def test_name_completion(self): """Test complete partner_id from statement line label - Test the automatic completion of the partner_id based if the name of the - partner appears in the statement line label + Test the automatic completion of the partner_id based if the name of + the partner appears in the statement line label """ self.completion_rule_id = self.ref( 'account_statement_base_completion.' @@ -89,7 +89,8 @@ class base_completion(common.TransactionCase): for case in NAMES_COMPLETION_CASES: self.partner_obj.write( - self.cr, self.uid, self.partner_id, {'name': case.partner_name}) + self.cr, self.uid, self.partner_id, {'name': case.partner_name} + ) statement_line_id = self.account_bank_statement_line_obj.create( self.cr, self.uid, { 'amount': 1000.0, @@ -116,5 +117,6 @@ class base_completion(common.TransactionCase): else: self.assertNotEquals( self.partner_id, statement_line.partner_id['id'], - "Partner id should be empty after completion(partner_name: " - "%s, line_name: %s)" % (case.partner_name, case.line_label)) + "Partner id should be empty after completion " + "(partner_name: %s, line_name: %s)" + % (case.partner_name, case.line_label)) diff --git a/account_statement_base_import/__openerp__.py b/account_statement_base_import/__openerp__.py index 4826ae28..f7989ce3 100644 --- a/account_statement_base_import/__openerp__.py +++ b/account_statement_base_import/__openerp__.py @@ -57,8 +57,8 @@ The goal is here to populate the statement lines of a bank statement with the infos that the bank or office give you. Fell free to inherit from this module - to add your own format. Then, if you need to complete data from there, add your - own account_statement_*_completion module and implement the needed rules. + to add your own format. Then, if you need to complete data from there, add + your own account_statement_*_completion module and implement the needed rules. """, 'website': 'http://www.camptocamp.com', 'data': [ diff --git a/account_statement_base_import/parser/file_parser.py b/account_statement_base_import/parser/file_parser.py index e7d050a6..7eb107a6 100644 --- a/account_statement_base_import/parser/file_parser.py +++ b/account_statement_base_import/parser/file_parser.py @@ -181,9 +181,9 @@ class FileParser(BankStatementImportParser): except Exception as err: raise except_orm( _("Date format is not valid"), - _("Please modify the cell formatting to date format" - " for column: %s value: %s\n Please check the " - "line with ref: %s\n \n Detail: %s") % + _("Please modify the cell formatting to date " + "format for column: %s value: %s\n Please check " + "the line with ref: %s\n \n Detail: %s") % (rule, line.get(rule, _('Missing')), line.get('ref', line), repr(err))) else: diff --git a/account_statement_base_import/parser/generic_file_parser.py b/account_statement_base_import/parser/generic_file_parser.py index 710c5595..03f4dd13 100644 --- a/account_statement_base_import/parser/generic_file_parser.py +++ b/account_statement_base_import/parser/generic_file_parser.py @@ -24,8 +24,9 @@ from file_parser import FileParser class GenericFileParser(FileParser): """Standard parser that use a define format in csv or xls to import into a - bank statement. This is mostely an example of how to proceed to create a new - parser, but will also be useful as it allow to import a basic flat file. + bank statement. This is mostely an example of how to proceed to create a + new parser, but will also be useful as it allow to import a basic flat + file. """ def __init__(self, parse_name, ftype='csv', **kwargs): @@ -42,9 +43,9 @@ class GenericFileParser(FileParser): def get_st_line_vals(self, line, *args, **kwargs): """ This method must return a dict of vals that can be passed to create - method of statement line in order to record it. It is the responsibility - of every parser to give this dict of vals, so each one can implement his - own way of recording the lines. + method of statement line in order to record it. It is the + responsibility of every parser to give this dict of vals, so each one + can implement his own way of recording the lines. :param: line: a dict of vals that represent a line of result_row_list :return: dict of values to give to the create method of statement diff --git a/account_statement_base_import/parser/parser.py b/account_statement_base_import/parser/parser.py index 6a9be611..9618157d 100644 --- a/account_statement_base_import/parser/parser.py +++ b/account_statement_base_import/parser/parser.py @@ -48,8 +48,8 @@ class BankStatementImportParser(object): def __init__(self, profile, *args, **kwargs): # The name of the parser as it will be called self.parser_name = profile.import_type - # The result as a list of row. One row per line of data in the file, but - # not the commission one ! + # The result as a list of row. One row per line of data in the file, + # but not the commission one! self.result_row_list = None # The file buffer on which to work on self.filebuffer = None @@ -128,9 +128,9 @@ class BankStatementImportParser(object): def get_st_line_vals(self, line, *args, **kwargs): """Implement a method in your parser that must return a dict of vals - that can be passed to create method of statement line in order to record - it. It is the responsibility of every parser to give this dict of vals, - so each one can implement his own way of recording the lines. + that can be passed to create method of statement line in order to + record it. It is the responsibility of every parser to give this dict + of vals, so each one can implement his own way of recording the lines. :param: line: a dict of vals that represent a line of result_row_list :return: dict of values to give to the create method of statement line, diff --git a/account_statement_base_import/statement.py b/account_statement_base_import/statement.py index 2bacb45c..f8301e1b 100644 --- a/account_statement_base_import/statement.py +++ b/account_statement_base_import/statement.py @@ -80,7 +80,8 @@ class AccountStatementProfil(orm.Model): context): """Write the log in the logger - :param int/long statement_id: ID of the concerned account.bank.statement + :param int/long statement_id: ID of the concerned + account.bank.statement :param int/long num_lines: Number of line that have been parsed :return: True """ @@ -102,7 +103,8 @@ class AccountStatementProfil(orm.Model): :param dict of vals from parser for account.bank.statement.line (called by parser.get_st_line_vals) - :param int/long statement_id: ID of the concerned account.bank.statement + :param int/long statement_id: ID of the concerned + account.bank.statement :return: dict of vals that will be passed to create method of statement line. """ @@ -173,8 +175,8 @@ class AccountStatementProfil(orm.Model): ftype="csv", context=None): """Create a bank statement with the given profile and parser. It will fullfill the bank statement with the values of the file providen, but - will not complete data (like finding the partner, or the right account). - This will be done in a second step with the completion rules. + will not complete data (like finding the partner, or the right + account). This will be done in a second step with the completion rules. :param prof : The profile used to import the file :param parser: the parser diff --git a/account_statement_commission/__openerp__.py b/account_statement_commission/__openerp__.py index d4126340..9a4e0792 100644 --- a/account_statement_commission/__openerp__.py +++ b/account_statement_commission/__openerp__.py @@ -31,9 +31,9 @@ 'account_statement_base_import' ], 'description': """ -This module brings commission support to bank statement imports. It computes the -sum of a commission field on each transaction and creates a statement entry for -it. +This module brings commission support to bank statement imports. It computes +the sum of a commission field on each transaction and creates a statement +entry for it. """, 'website': 'http://www.camptocamp.com', 'data': [ diff --git a/account_statement_commission/commission.py b/account_statement_commission/commission.py index cba22bcf..7690b790 100644 --- a/account_statement_commission/commission.py +++ b/account_statement_commission/commission.py @@ -24,7 +24,8 @@ class AccountStatementProfil(orm.Model): commission_analytic_id = profile.commission_analytic_id.id comm_values = { 'name': 'IN ' + _('Commission line'), - 'date': parser.get_st_vals().get('date') or datetime.datetime.now(), + 'date': parser.get_st_vals().get('date') or + datetime.datetime.now(), 'amount': global_commission_amount, 'partner_id': partner_id, 'type': 'general', @@ -32,8 +33,8 @@ class AccountStatementProfil(orm.Model): 'account_id': commission_account_id, 'ref': 'commission', 'analytic_account_id': commission_analytic_id, - # !! We set the already_completed so auto-completion will not update - # those values! + # !! We set the already_completed so auto-completion will not + # update those values! 'already_completed': True, } st_obj = self.pool['account.bank.statement.line'] diff --git a/account_statement_completion_label/statement.py b/account_statement_completion_label/statement.py index aef6cb36..7f722821 100644 --- a/account_statement_completion_label/statement.py +++ b/account_statement_completion_label/statement.py @@ -125,8 +125,8 @@ class AccountStatementLabel(orm.Model): 'label': fields.char('Bank Statement Label', size=100), 'account_id': fields.many2one('account.account', 'Account', required=True, - help='Account corresponding to the label ' - 'for a given partner'), + help='Account corresponding to the ' + 'label for a given partner'), 'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', diff --git a/account_statement_ext/__openerp__.py b/account_statement_ext/__openerp__.py index 1cd090c6..d48aeb91 100644 --- a/account_statement_ext/__openerp__.py +++ b/account_statement_ext/__openerp__.py @@ -45,8 +45,8 @@ Features: 1) Improve the bank statement: allows to define profiles (for each Office or - Bank). The bank statement will then generate the entries based on some criteria - chosen in the selected profile. You can setup on the profile: + Bank). The bank statement will then generate the entries based on some + criteria chosen in the selected profile. You can setup on the profile: - the journal to use - use balance check or not diff --git a/account_statement_ext/statement.py b/account_statement_ext/statement.py index 3c0b537d..a3a45a2d 100644 --- a/account_statement_ext/statement.py +++ b/account_statement_ext/statement.py @@ -52,8 +52,8 @@ class AccountStatementProfile(orm.Model): 'name': fields.char('Name', required=True), 'sequence': fields.integer( 'Sequence', - help="Gives a sequence in lists, the first profile will be used as " - "default"), + help="Gives a sequence in lists, the first profile will be used " + "as default"), 'partner_id': fields.many2one( 'res.partner', 'Bank/Payment Office partner', @@ -144,7 +144,8 @@ class AccountBankStatement(orm.Model): profile_obj = self.pool['account.statement.profile'] user = user_obj.browse(cr, uid, uid, context=context) profile_ids = profile_obj.search( - cr, uid, [('company_id', '=', user.company_id.id)], context=context) + cr, uid, [('company_id', '=', user.company_id.id)], context=context + ) return profile_ids[0] if profile_ids else False def _get_statement_from_profile(self, cr, uid, profile_ids, context=None): @@ -304,7 +305,8 @@ class AccountBankStatement(orm.Model): line if different from the statement line account ID :param int/long analytic_id: ID of analytic account to put on the move line - :param int/long partner_id: ID of the partner to put on the move line + :param int/long partner_id: ID of the partner to put on the move + line :return: dict of value to create() the account.move.line """ if context is None: @@ -496,10 +498,10 @@ class AccountBankStatement(orm.Model): self, cr, uid, amount, account_receivable, account_payable, partner_id=False): """ - Give the amount, payable and receivable account (that can be found using - get_default_pay_receiv_accounts method) and receive the one to use. This - method should be use when there is no other way to know which one to - take. The rules are: + Give the amount, payable and receivable account (that can be found + using get_default_pay_receiv_accounts method) and receive the one to + use. This method should be use when there is no other way to know which + one to take. The rules are: - If the customer checkbox is checked on the found partner, type and account will be customer and receivable - If the supplier checkbox is checked on the found partner, type and @@ -617,7 +619,8 @@ class AccountBankStatementLine(orm.Model): _columns = { # Set them as required + 64 char instead of 32 'ref': fields.char('Reference', size=64, required=True), - 'period_id': fields.many2one('account.period', 'Period', required=True), + 'period_id': fields.many2one( + 'account.period', 'Period', required=True), } _defaults = { 'period_id': _get_period, @@ -732,8 +735,8 @@ class AccountBankStatementLine(orm.Model): 'voucher_id': False}} return {'value': {'type': line_type}} - def onchange_type(self, cr, uid, line_id, partner_id, line_type, profile_id, - context=None): + def onchange_type(self, cr, uid, line_id, partner_id, line_type, + profile_id, context=None): """Keep the same features as in standard and call super. If an account is returned, call the method to compute line values. """ diff --git a/account_statement_ext_point_of_sale/point_of_sale.py b/account_statement_ext_point_of_sale/point_of_sale.py index 6460b0a7..d929ab0e 100644 --- a/account_statement_ext_point_of_sale/point_of_sale.py +++ b/account_statement_ext_point_of_sale/point_of_sale.py @@ -82,7 +82,8 @@ if not hasattr(std_pos_session, '_prepare_bank_statement'): cr, uid, [('type', '=', 'cash')], context=context) if not cashids: cashids = journal_proxy.search( - cr, uid, [('journal_user', '=', True)], context=context) + cr, uid, [('journal_user', '=', True)], + context=context) jobj.write( cr, uid, [pos_config.id], {'journal_ids': [(6, 0, cashids)]}) pos_config = jobj.browse(cr, uid, config_id, context=context) diff --git a/account_statement_one_move/statement.py b/account_statement_one_move/statement.py index b4d47a93..40c4f900 100644 --- a/account_statement_one_move/statement.py +++ b/account_statement_one_move/statement.py @@ -65,7 +65,8 @@ class AccountBankStatement(orm.Model): }) return res - def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, + def create_move_from_st_line(self, cr, uid, st_line_id, + company_currency_id, st_line_number, context=None): if context is None: context = {} diff --git a/account_statement_regex_account_completion/tests/test_regex_account_completion.py b/account_statement_regex_account_completion/tests/test_regex_account_completion.py index ea3af52c..faac8a86 100644 --- a/account_statement_regex_account_completion/tests/test_regex_account_completion.py +++ b/account_statement_regex_account_completion/tests/test_regex_account_completion.py @@ -87,12 +87,14 @@ class test_regex_account_completion(common.TransactionCase): """Test the automatic completion on account """ self.prepare() - statement_obj = self.st_obj.browse(self.cr, self.uid, self.statement_id) + statement_obj = self.st_obj.browse( + self.cr, self.uid, self.statement_id) statement_obj.button_auto_completion() statement_line1 = self.st_line_obj.browse( self.cr, self.uid, self.statement_line1_id) self.assertEquals(self.account_id, statement_line1.account_id.id, - "The account should be the account of the completion") + "The account should be the account of the completion" + ) statement_line2 = self.st_line_obj.browse( self.cr, self.uid, self.statement_line2_id) self.assertNotEqual(self.account_id, statement_line2.account_id.id, diff --git a/account_statement_transactionid_completion/statement.py b/account_statement_transactionid_completion/statement.py index 8fcb13d2..44af03f5 100644 --- a/account_statement_transactionid_completion/statement.py +++ b/account_statement_transactionid_completion/statement.py @@ -151,7 +151,8 @@ class AccountBankStatement(Model): :param browse_record st_line: account.bank.statement.line record to create the move from. - :param int/long move_id: ID of the account.move to link the move line + :param int/long move_id: ID of the account.move to link the move + line :param float debit: debit amount of the move line :param float credit: credit amount of the move line :param int/long currency_id: ID of currency of the move line to @@ -162,7 +163,8 @@ class AccountBankStatement(Model): line if different from the statement line account ID :param int/long analytic_id: ID of analytic account to put on the move line - :param int/long partner_id: ID of the partner to put on the move line + :param int/long partner_id: ID of the partner to put on the move + line :return: dict of value to create() the account.move.line """ res = super(AccountBankStatement, self)._prepare_move_line_vals( diff --git a/account_statement_transactionid_import/__openerp__.py b/account_statement_transactionid_import/__openerp__.py index 626dbf09..29104fbb 100644 --- a/account_statement_transactionid_import/__openerp__.py +++ b/account_statement_transactionid_import/__openerp__.py @@ -35,9 +35,9 @@ the importation of different bank and offices that uses transactionID. This module allows you to import your bank transactions with a standard .csv - or .xls file (you'll find samples in the 'data' folder). It respects the chosen - profile (model provided by the account_statement_ext module) to generate the - entries. + or .xls file (you'll find samples in the 'data' folder). It respects the + chosen profile (model provided by the account_statement_ext module) to + generate the entries. This module can handle a commission taken by the payment office and has the following format: @@ -48,8 +48,8 @@ * amount: amount paid in the currency of the journal used in the importation profile * commission_amount: amount of the comission for each line - * label: the comunication given by the payment office, used as communication in - the generated entries. + * label: the comunication given by the payment office, used as communication + in the generated entries. """, 'website': 'http://www.camptocamp.com', 'installable': True, diff --git a/account_statement_transactionid_import/parser/transactionid_file_parser.py b/account_statement_transactionid_import/parser/transactionid_file_parser.py index 0bb2a2d7..873155e1 100644 --- a/account_statement_transactionid_import/parser/transactionid_file_parser.py +++ b/account_statement_transactionid_import/parser/transactionid_file_parser.py @@ -54,9 +54,9 @@ class TransactionIDFileParser(FileParser): def get_st_line_vals(self, line, *args, **kwargs): """This method must return a dict of vals that can be passed to create - method of statement line in order to record it. It is the responsibility - of every parser to give this dict of vals, so each one can implement his - own way of recording the lines. + method of statement line in order to record it. It is the + responsibility of every parser to give this dict of vals, so each one + can implement his own way of recording the lines. :param: line: a dict of vals that represent a line of result_row_list :return: dict of values to give to the create method of statement diff --git a/statement_voucher_killer/voucher.py b/statement_voucher_killer/voucher.py index ea88996f..b924b8a1 100644 --- a/statement_voucher_killer/voucher.py +++ b/statement_voucher_killer/voucher.py @@ -62,8 +62,8 @@ class AccountStatementFromInvoiceLines(orm.TransientModel): elif (line.invoice and line.invoice.currency_id.id != statement.currency.id): amount = currency_obj.compute( - cr, uid, line.invoice.currency_id.id, statement.currency.id, - amount, context=ctx) + cr, uid, line.invoice.currency_id.id, + statement.currency.id, amount, context=ctx) context.update({'move_line_ids': [line.id], 'invoice_id': line.invoice.id}) s_type = 'general' From 9a949d8ea188b1b2ce15547f7b91ea204a86b287 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Tue, 27 May 2014 15:54:03 +0200 Subject: [PATCH 25/84] [ADD] new reconciliation rule using bank statements --- .../__init__.py | 23 ++++ .../__openerp__.py | 44 +++++++ .../advanced_reconciliation.py | 60 ++++++++++ .../base_advanced_reconciliation.py | 46 ++++++++ .../easy_reconcile.py | 37 ++++++ .../easy_reconcile_view.xml | 19 ++++ ...count_advanced_reconcile_bank_statement.po | 107 ++++++++++++++++++ .../i18n/fr.po | 103 +++++++++++++++++ 8 files changed, 439 insertions(+) create mode 100644 account_advanced_reconcile_bank_statement/__init__.py create mode 100644 account_advanced_reconcile_bank_statement/__openerp__.py create mode 100644 account_advanced_reconcile_bank_statement/advanced_reconciliation.py create mode 100644 account_advanced_reconcile_bank_statement/base_advanced_reconciliation.py create mode 100644 account_advanced_reconcile_bank_statement/easy_reconcile.py create mode 100644 account_advanced_reconcile_bank_statement/easy_reconcile_view.xml create mode 100644 account_advanced_reconcile_bank_statement/i18n/account_advanced_reconcile_bank_statement.po create mode 100644 account_advanced_reconcile_bank_statement/i18n/fr.po diff --git a/account_advanced_reconcile_bank_statement/__init__.py b/account_advanced_reconcile_bank_statement/__init__.py new file mode 100644 index 00000000..e19ad65a --- /dev/null +++ b/account_advanced_reconcile_bank_statement/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Romain Deheele. Copyright 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 . +# +############################################################################## + +from . import easy_reconcile +from . import base_advanced_reconciliation +from . import advanced_reconciliation diff --git a/account_advanced_reconcile_bank_statement/__openerp__.py b/account_advanced_reconcile_bank_statement/__openerp__.py new file mode 100644 index 00000000..fc5ef68b --- /dev/null +++ b/account_advanced_reconcile_bank_statement/__openerp__.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Matthieu Dietrich. Copyright 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 . +# +############################################################################## + +{'name': 'Advanced Reconcile Bank Statement', + 'description': """ +Advanced reconciliation method for the module account_advanced_reconcile +======================================================================== +Reconcile rules with bank statement name. + +This will reconcile multiple credit move lines (bank statements) with +all the lines from a specific bank statement, debit or credit (to also +reconcile the commission with credit card imports). + +""", + 'version': '1.0.0', + 'author': 'Camptocamp', + 'category': 'Finance', + 'website': 'http://www.camptocamp.com', + 'depends': ['account_advanced_reconcile'], + 'data': ['easy_reconcile_view.xml'], + 'demo': [], + 'test': [], # To be ported or migrate to unit tests or scenarios + 'auto_install': False, + 'installable': True, + 'images': [] +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_advanced_reconcile_bank_statement/advanced_reconciliation.py b/account_advanced_reconcile_bank_statement/advanced_reconciliation.py new file mode 100644 index 00000000..f85369dc --- /dev/null +++ b/account_advanced_reconcile_bank_statement/advanced_reconciliation.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Matthieu Dietrich. Copyright 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 . +# +############################################################################## + +from openerp.osv import orm + + +class easy_reconcile_advanced_bank_statement(orm.TransientModel): + + _name = 'easy.reconcile.advanced.bank_statement' + _inherit = 'easy.reconcile.advanced' + + def _skip_line(self, cr, uid, rec, move_line, context=None): + """ + When True is returned on some conditions, the credit move line + will be skipped for reconciliation. Can be inherited to + skip on some conditions. ie: ref or partner_id is empty. + """ + return not (move_line.get('ref') and + move_line.get('partner_id')) + + def _matchers(self, cr, uid, rec, move_line, context=None): + return (('partner_id', move_line['partner_id']), + ('ref', move_line['ref'].lower().strip())) + + def _opposite_matchers(self, cr, uid, rec, move_line, context=None): + yield ('partner_id', move_line['partner_id']) + if move_line['statement_id']: + cr.execute("""SELECT name FROM account_bank_statement + WHERE id = %s""", (move_line['statement_id'],)) + statement_name = cr.fetchone()[0] + yield ('ref', statement_name.lower().strip()) + else: + yield ('ref', '') + + # Re-defined for this particular rule; since the commission line is a + # credit line inside of the target statement, it should also be considered + # as an opposite to be reconciled. + def _action_rec(self, cr, uid, rec, context=None): + credit_lines = self._query_credit(cr, uid, rec, context=context) + debit_lines = self._query_debit(cr, uid, rec, context=context) + return self._rec_auto_lines_advanced( + cr, uid, rec, credit_lines, credit_lines + debit_lines, + context=context) diff --git a/account_advanced_reconcile_bank_statement/base_advanced_reconciliation.py b/account_advanced_reconcile_bank_statement/base_advanced_reconciliation.py new file mode 100644 index 00000000..afcece18 --- /dev/null +++ b/account_advanced_reconcile_bank_statement/base_advanced_reconciliation.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Matthieu Dietrich +# 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 . +# +############################################################################## + +from itertools import product +from openerp.osv import orm + + +class easy_reconcile_advanced(orm.AbstractModel): + + _inherit = 'easy.reconcile.advanced' + + def _base_columns(self, rec): + """ Mandatory columns for move lines queries + An extra column aliased as ``key`` should be defined + in each query.""" + aml_cols = ( + 'id', + 'debit', + 'credit', + 'date', + 'period_id', + 'ref', + 'name', + 'partner_id', + 'account_id', + 'move_id', + 'statement_id') + return ["account_move_line.%s" % col for col in aml_cols] diff --git a/account_advanced_reconcile_bank_statement/easy_reconcile.py b/account_advanced_reconcile_bank_statement/easy_reconcile.py new file mode 100644 index 00000000..bf714bcd --- /dev/null +++ b/account_advanced_reconcile_bank_statement/easy_reconcile.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Romain Deheele +# Copyright 2013 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 . +# +############################################################################## + +from openerp.osv import orm + + +class account_easy_reconcile_method(orm.Model): + + _inherit = 'account.easy.reconcile.method' + + def _get_all_rec_method(self, cr, uid, context=None): + methods = super(account_easy_reconcile_method, self).\ + _get_all_rec_method(cr, uid, context=context) + methods += [ + ('easy.reconcile.advanced.bank_statement', + 'Advanced. Partner and Bank Statement'), + ] + return methods + diff --git a/account_advanced_reconcile_bank_statement/easy_reconcile_view.xml b/account_advanced_reconcile_bank_statement/easy_reconcile_view.xml new file mode 100644 index 00000000..72c0ad68 --- /dev/null +++ b/account_advanced_reconcile_bank_statement/easy_reconcile_view.xml @@ -0,0 +1,19 @@ + + + + + account.easy.reconcile.form + account.easy.reconcile + + + + + + + + + + + diff --git a/account_advanced_reconcile_bank_statement/i18n/account_advanced_reconcile_bank_statement.po b/account_advanced_reconcile_bank_statement/i18n/account_advanced_reconcile_bank_statement.po new file mode 100644 index 00000000..5ede7195 --- /dev/null +++ b/account_advanced_reconcile_bank_statement/i18n/account_advanced_reconcile_bank_statement.po @@ -0,0 +1,107 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_advanced_reconcile_bank_statement +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-05-27 08:36+0000\n" +"PO-Revision-Date: 2014-05-27 08:36+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_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,filter:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_filter +msgid "Filter" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,account_id:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_account_id +msgid "Account" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,partner_ids:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_partner_ids +msgid "Restrict on partners" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: code:_description:0 +#: model:ir.model,name:account_advanced_reconcile_bank_statement.model_easy_reconcile_advanced_bank_statement +#, python-format +msgid "easy.reconcile.advanced.bank_statement" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: view:account.easy.reconcile:0 +msgid "Match multiple debit vs multiple credit entries. Allow partial reconciliation. The lines should have the partner, the credit entry reference is matched vs the debit entry bank statement name." +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,journal_id:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_journal_id +msgid "Journal" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,account_profit_id:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_account_profit_id +msgid "Account Profit" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,analytic_account_id:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_analytic_account_id +msgid "Analytic Account" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: code:_description:0 +#: model:ir.model,name:account_advanced_reconcile_bank_statement.model_account_easy_reconcile_method +#, python-format +msgid "reconcile method for account_easy_reconcile" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,date_base_on:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_date_base_on +msgid "Date of reconciliation" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: help:easy.reconcile.advanced.bank_statement,analytic_account_id:0 +msgid "Analytic account for the write-off" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: view:account.easy.reconcile:0 +msgid "Advanced. Partner and Bank Statement" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: code:_description:0 +#: model:ir.model,name:account_advanced_reconcile_bank_statement.model_easy_reconcile_advanced +#, python-format +msgid "easy.reconcile.advanced" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,account_lost_id:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_account_lost_id +msgid "Account Lost" +msgstr "" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,write_off:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_write_off +msgid "Write off allowed" +msgstr "" + diff --git a/account_advanced_reconcile_bank_statement/i18n/fr.po b/account_advanced_reconcile_bank_statement/i18n/fr.po new file mode 100644 index 00000000..63124f07 --- /dev/null +++ b/account_advanced_reconcile_bank_statement/i18n/fr.po @@ -0,0 +1,103 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_advanced_reconcile_bank_statement +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-05-27 08:36+0000\n" +"PO-Revision-Date: 2014-05-27 08:36+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_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,filter:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_filter +msgid "Filter" +msgstr "Filtre" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,account_id:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_account_id +msgid "Account" +msgstr "Compte" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,partner_ids:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_partner_ids +msgid "Restrict on partners" +msgstr "Restriction sur les partenaires" + +#. module: account_advanced_reconcile_bank_statement +#: code:_description:0 +#: model:ir.model,name:account_advanced_reconcile_bank_statement.model_easy_reconcile_advanced_bank_statement +#, python-format +msgid "easy.reconcile.advanced.bank_statement" +msgstr "easy.reconcile.advanced.bank_statement" + +#. module: account_advanced_reconcile_bank_statement +#: view:account.easy.reconcile:0 +msgid "" +"Match multiple debit vs multiple credit entries. Allow partial " +"reconciliation. The lines should have the partner, the credit entry " +"reference is matched vs the debit entry bank statement name." +msgstr "" +"Le lettrage peut s'effectuer sur plusieurs écritures de débit et crédit. Le " +"lettrage partiel est autorisé. Les écritures doivent avoir le même " +"partenaire et la référence sur les écritures de crédit doit se retrouver +"dans le nom du relevé bancaire des écritures de débit." + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,journal_id:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_journal_id +msgid "Journal" +msgstr "Journal" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,account_profit_id:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_account_profit_id +msgid "Account Profit" +msgstr "Compte de produit" + +#. module: account_advanced_reconcile_bank_statement +#: code:_description:0 +#: model:ir.model,name:account_advanced_reconcile_bank_statement.model_account_easy_reconcile_method +#, python-format +msgid "reconcile method for account_easy_reconcile" +msgstr "Méthode de lettrage pour le module account_easy_reconcile" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,date_base_on:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_date_base_on +msgid "Date of reconciliation" +msgstr "Date de lettrage" + +#. module: account_advanced_reconcile_bank_statement +#: view:account.easy.reconcile:0 +msgid "Advanced. Partner and Bank Statement" +msgstr "Avancé. Partenaire et Relevé Bancaire" + +#. module: account_advanced_reconcile_bank_statement +#: code:_description:0 +#: model:ir.model,name:account_advanced_reconcile_bank_statement.model_easy_reconcile_advanced +#, python-format +msgid "easy.reconcile.advanced" +msgstr "easy.reconcile.advanced" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,account_lost_id:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_account_lost_id +msgid "Account Lost" +msgstr "Compte de charge" + +#. module: account_advanced_reconcile_bank_statement +#: field:easy.reconcile.advanced.bank_statement,write_off:0 +#: model:ir.model.fields,field_description:account_advanced_reconcile_bank_statement.field_easy_reconcile_advanced_bank_statement_write_off +msgid "Write off allowed" +msgstr "Ecart autorisé" + From b48a46a29925624591879cd52f83f7f373427921 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Tue, 27 May 2014 17:41:43 +0200 Subject: [PATCH 26/84] [FIX] updated copyrights --- account_advanced_reconcile_bank_statement/__init__.py | 3 ++- account_advanced_reconcile_bank_statement/__openerp__.py | 3 ++- .../advanced_reconciliation.py | 3 ++- account_advanced_reconcile_bank_statement/easy_reconcile.py | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/account_advanced_reconcile_bank_statement/__init__.py b/account_advanced_reconcile_bank_statement/__init__.py index e19ad65a..e70aef22 100644 --- a/account_advanced_reconcile_bank_statement/__init__.py +++ b/account_advanced_reconcile_bank_statement/__init__.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author: Romain Deheele. Copyright Camptocamp SA +# Author: Matthieu Dietrich +# 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 diff --git a/account_advanced_reconcile_bank_statement/__openerp__.py b/account_advanced_reconcile_bank_statement/__openerp__.py index fc5ef68b..cbdc4c52 100644 --- a/account_advanced_reconcile_bank_statement/__openerp__.py +++ b/account_advanced_reconcile_bank_statement/__openerp__.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author: Matthieu Dietrich. Copyright Camptocamp SA +# Author: Matthieu Dietrich +# 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 diff --git a/account_advanced_reconcile_bank_statement/advanced_reconciliation.py b/account_advanced_reconcile_bank_statement/advanced_reconciliation.py index f85369dc..65218454 100644 --- a/account_advanced_reconcile_bank_statement/advanced_reconciliation.py +++ b/account_advanced_reconcile_bank_statement/advanced_reconciliation.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author: Matthieu Dietrich. Copyright Camptocamp SA +# Author: Matthieu Dietrich +# 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 diff --git a/account_advanced_reconcile_bank_statement/easy_reconcile.py b/account_advanced_reconcile_bank_statement/easy_reconcile.py index bf714bcd..fc3deaba 100644 --- a/account_advanced_reconcile_bank_statement/easy_reconcile.py +++ b/account_advanced_reconcile_bank_statement/easy_reconcile.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author: Romain Deheele -# Copyright 2013 Camptocamp SA +# Author: Matthieu Dietrich +# 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 From c9779f3326086d3b8c22ba4624183fa9390db906 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Tue, 17 Jun 2014 18:10:35 +0200 Subject: [PATCH 27/84] [FIX] optimize new rule --- .../__init__.py | 4 +- .../advanced_reconciliation.py | 39 ++++++++++++---- .../base_advanced_reconciliation.py | 46 ------------------- 3 files changed, 31 insertions(+), 58 deletions(-) delete mode 100644 account_advanced_reconcile_bank_statement/base_advanced_reconciliation.py diff --git a/account_advanced_reconcile_bank_statement/__init__.py b/account_advanced_reconcile_bank_statement/__init__.py index e70aef22..748698d3 100644 --- a/account_advanced_reconcile_bank_statement/__init__.py +++ b/account_advanced_reconcile_bank_statement/__init__.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author: Matthieu Dietrich -# Copyright 2014 Camptocamp SA +# Author: Romain Deheele. Copyright 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 @@ -20,5 +19,4 @@ ############################################################################## from . import easy_reconcile -from . import base_advanced_reconciliation from . import advanced_reconciliation diff --git a/account_advanced_reconcile_bank_statement/advanced_reconciliation.py b/account_advanced_reconcile_bank_statement/advanced_reconciliation.py index 65218454..dd44bc6b 100644 --- a/account_advanced_reconcile_bank_statement/advanced_reconciliation.py +++ b/account_advanced_reconcile_bank_statement/advanced_reconciliation.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author: Matthieu Dietrich -# Copyright 2014 Camptocamp SA +# Author: Matthieu Dietrich. Copyright 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 @@ -27,6 +26,33 @@ class easy_reconcile_advanced_bank_statement(orm.TransientModel): _name = 'easy.reconcile.advanced.bank_statement' _inherit = 'easy.reconcile.advanced' + def _base_columns(self, rec): + """ Mandatory columns for move lines queries + An extra column aliased as ``key`` should be defined + in each query.""" + aml_cols = ( + 'id', + 'debit', + 'credit', + 'date', + 'period_id', + 'ref', + 'name', + 'partner_id', + 'account_id', + 'move_id', + 'statement_id') + result = ["account_move_line.%s" % col for col in aml_cols] + result += ["account_bank_statement.name as statement_name"] + return result + + def _from(self, rec, *args, **kwargs): + # Overriden to use a inner join + return """FROM account_move_line + INNER JOIN account_bank_statement + ON account_bank_statement.id = + account_move_line.statement_id""" + def _skip_line(self, cr, uid, rec, move_line, context=None): """ When True is returned on some conditions, the credit move line @@ -42,13 +68,8 @@ class easy_reconcile_advanced_bank_statement(orm.TransientModel): def _opposite_matchers(self, cr, uid, rec, move_line, context=None): yield ('partner_id', move_line['partner_id']) - if move_line['statement_id']: - cr.execute("""SELECT name FROM account_bank_statement - WHERE id = %s""", (move_line['statement_id'],)) - statement_name = cr.fetchone()[0] - yield ('ref', statement_name.lower().strip()) - else: - yield ('ref', '') + yield ('ref', + (move_line['statement_name'] or '').lower().strip()) # Re-defined for this particular rule; since the commission line is a # credit line inside of the target statement, it should also be considered diff --git a/account_advanced_reconcile_bank_statement/base_advanced_reconciliation.py b/account_advanced_reconcile_bank_statement/base_advanced_reconciliation.py deleted file mode 100644 index afcece18..00000000 --- a/account_advanced_reconcile_bank_statement/base_advanced_reconciliation.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author: Matthieu Dietrich -# 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 . -# -############################################################################## - -from itertools import product -from openerp.osv import orm - - -class easy_reconcile_advanced(orm.AbstractModel): - - _inherit = 'easy.reconcile.advanced' - - def _base_columns(self, rec): - """ Mandatory columns for move lines queries - An extra column aliased as ``key`` should be defined - in each query.""" - aml_cols = ( - 'id', - 'debit', - 'credit', - 'date', - 'period_id', - 'ref', - 'name', - 'partner_id', - 'account_id', - 'move_id', - 'statement_id') - return ["account_move_line.%s" % col for col in aml_cols] From a967226e3eb9da047701bd6de752e11a73a8e798 Mon Sep 17 00:00:00 2001 From: Nicolas Bessi Date: Tue, 8 Jul 2014 11:51:38 +0200 Subject: [PATCH 28/84] [MRG] [ADD] a cron to run reconciles. By default it runs one reconcile after the other to be more atomic and memory friendly. But you can set run_all agrument to have all reconcile run at once --- account_easy_reconcile/easy_reconcile.py | 24 ++++++++++++++ account_easy_reconcile/easy_reconcile.xml | 18 ++++++++++ .../easy_reconcile_history.py | 33 +++++++++---------- 3 files changed, 58 insertions(+), 17 deletions(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index 1520dda5..94d9c259 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -352,3 +352,27 @@ class AccountEasyReconcile(orm.Model): if not rec.last_history: self._no_history(cr, uid, rec, context=context) return rec.last_history.open_partial() + + def run_scheduler(self, cr, uid, run_all=None, context=None): + """ Launch the reconcile with the oldest run + This function is mostly here to be used with cron task + + :param run_all: if set it will ingore lookup and launch + all reconciliation + :returns: True in case of success or raises an exception + + """ + def _get_date(reconcile): + return datetime.strptime(reconcile.last_history.date, + DEFAULT_SERVER_DATETIME_FORMAT) + + ids = self.search(cr, uid, [], context=context) + assert ids, "No easy reconcile available" + if run_all: + self.run_reconcile(cr, uid, ids, context=context) + return True + reconciles = self.browse(cr, uid, ids, context=context) + reconciles.sort(key=_get_date) + older = reconciles[0] + self.run_reconcile(cr, uid, [older.id], context=context) + return True diff --git a/account_easy_reconcile/easy_reconcile.xml b/account_easy_reconcile/easy_reconcile.xml index 1fb27a10..d191fbb8 100644 --- a/account_easy_reconcile/easy_reconcile.xml +++ b/account_easy_reconcile/easy_reconcile.xml @@ -161,4 +161,22 @@ The lines should have the same amount (with the write-off) and the same referenc parent="account.periodical_processing_reconciliation"/> + + + + + Do Automatic Reconciliations + + + 3 + hours + -1 + + + + + + + + diff --git a/account_easy_reconcile/easy_reconcile_history.py b/account_easy_reconcile/easy_reconcile_history.py index 67581cb7..d73c0033 100644 --- a/account_easy_reconcile/easy_reconcile_history.py +++ b/account_easy_reconcile/easy_reconcile_history.py @@ -53,7 +53,7 @@ class EasyReconcileHistory(orm.Model): _columns = { 'easy_reconcile_id': fields.many2one( 'account.easy.reconcile', 'Reconcile Profile', readonly=True), - 'date': fields.datetime('Run date', readonly=True), + 'date': fields.datetime('Run date', readonly=True, required=True), 'reconcile_ids': fields.many2many( 'account.move.reconcile', 'account_move_reconcile_history_rel', @@ -62,28 +62,27 @@ class EasyReconcileHistory(orm.Model): 'account.move.reconcile', 'account_move_reconcile_history_partial_rel', string='Partial Reconciliations', readonly=True), - 'reconcile_line_ids': - fields.function( + 'reconcile_line_ids': fields.function( _reconcile_line_ids, string='Reconciled Items', type='many2many', relation='account.move.line', readonly=True, multi='lines'), - 'partial_line_ids': - fields.function( - _reconcile_line_ids, - string='Partially Reconciled Items', - type='many2many', - relation='account.move.line', - readonly=True, - multi='lines'), - 'company_id': fields.related('easy_reconcile_id', 'company_id', - relation='res.company', - type='many2one', - string='Company', - store=True, - readonly=True), + 'partial_line_ids': fields.function( + _reconcile_line_ids, + string='Partially Reconciled Items', + type='many2many', + relation='account.move.line', + readonly=True, + multi='lines'), + 'company_id': fields.related( + 'easy_reconcile_id', 'company_id', + relation='res.company', + type='many2one', + string='Company', + store=True, + readonly=True), } From 798fd098a19752f0ece218e5f6f292d213adf9b4 Mon Sep 17 00:00:00 2001 From: "Nicolas Bessi (nbessi)" Date: Tue, 8 Jul 2014 13:37:36 +0200 Subject: [PATCH 29/84] Add missing import Due to merge trouble --- account_easy_reconcile/easy_reconcile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index 94d9c259..164f0ac0 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -19,7 +19,9 @@ # ############################################################################## +from datetime import datetime from openerp.osv import fields, orm +from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT from openerp.tools.translate import _ from openerp import pooler @@ -272,7 +274,7 @@ class AccountEasyReconcile(orm.Model): return True def _no_history(self, cr, uid, rec, context=None): - """ Raise an `osv.except_osv` error, supposed to + """ Raise an `orm.except_orm` error, supposed to be called when there is no history on the reconciliation task. """ From 07d0fb418c671c839cbc8171346885bc0e0c9470 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 18 Jul 2014 15:53:10 +0200 Subject: [PATCH 30/84] Extend methods instead of overriding them entirely. Allows to stay compatible if the original methods change, for instance if new fields are added. --- .../advanced_reconciliation.py | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/account_advanced_reconcile_bank_statement/advanced_reconciliation.py b/account_advanced_reconcile_bank_statement/advanced_reconciliation.py index dd44bc6b..8b7fe8ab 100644 --- a/account_advanced_reconcile_bank_statement/advanced_reconciliation.py +++ b/account_advanced_reconcile_bank_statement/advanced_reconciliation.py @@ -30,28 +30,21 @@ class easy_reconcile_advanced_bank_statement(orm.TransientModel): """ Mandatory columns for move lines queries An extra column aliased as ``key`` should be defined in each query.""" - aml_cols = ( - 'id', - 'debit', - 'credit', - 'date', - 'period_id', - 'ref', - 'name', - 'partner_id', - 'account_id', - 'move_id', - 'statement_id') - result = ["account_move_line.%s" % col for col in aml_cols] - result += ["account_bank_statement.name as statement_name"] - return result + aml_cols = super(easy_reconcile_advanced_bank_statement, self).\ + _base_columns(rec) + aml_cols += ['account_move_line.statement_id', + 'account_bank_statement.name as statement_name', + ] + return aml_cols def _from(self, rec, *args, **kwargs): - # Overriden to use a inner join - return """FROM account_move_line - INNER JOIN account_bank_statement - ON account_bank_statement.id = - account_move_line.statement_id""" + result = super(easy_reconcile_advanced_bank_statement, self).\ + _from(rec, *args, **kwargs) + result = result + ( + " INNER JOIN account_bank_statement " + "ON account_bank_statement.id = account_move_line.statement_id " + ) + return result def _skip_line(self, cr, uid, rec, move_line, context=None): """ @@ -59,6 +52,10 @@ class easy_reconcile_advanced_bank_statement(orm.TransientModel): will be skipped for reconciliation. Can be inherited to skip on some conditions. ie: ref or partner_id is empty. """ + result = super(easy_reconcile_advanced_bank_statement, self).\ + _skip_line(cr, uid, rec, move_line, context=context) + if result: + return result return not (move_line.get('ref') and move_line.get('partner_id')) From 8110a47085391e1bd72b3616cce4d0dabd4b8cd4 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 22 Aug 2014 16:09:40 +0200 Subject: [PATCH 31/84] add debit lines for matching according to https://github.com/guewen/bank-statement-reconcile/commit/279a176e22bcca4db214dae665abafb02cfd672d --- .../advanced_reconciliation.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/account_advanced_reconcile_bank_statement/advanced_reconciliation.py b/account_advanced_reconcile_bank_statement/advanced_reconciliation.py index 8b7fe8ab..2eb77cbc 100644 --- a/account_advanced_reconcile_bank_statement/advanced_reconciliation.py +++ b/account_advanced_reconcile_bank_statement/advanced_reconciliation.py @@ -71,9 +71,11 @@ class easy_reconcile_advanced_bank_statement(orm.TransientModel): # Re-defined for this particular rule; since the commission line is a # credit line inside of the target statement, it should also be considered # as an opposite to be reconciled. + # And also, given some are refunds, debit lines can be "credit". def _action_rec(self, cr, uid, rec, context=None): credit_lines = self._query_credit(cr, uid, rec, context=context) debit_lines = self._query_debit(cr, uid, rec, context=context) - return self._rec_auto_lines_advanced( - cr, uid, rec, credit_lines, credit_lines + debit_lines, - context=context) + return self._rec_auto_lines_advanced(cr, uid, rec, + credit_lines + debit_lines, + credit_lines + debit_lines, + context=context) From 71f6c4807f6cea87c6224918ec5b817c5d2f0bff Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 22 Aug 2014 16:44:53 +0200 Subject: [PATCH 32/84] pep8 fixes --- account_advanced_reconcile_bank_statement/__openerp__.py | 5 ++--- account_advanced_reconcile_bank_statement/easy_reconcile.py | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/account_advanced_reconcile_bank_statement/__openerp__.py b/account_advanced_reconcile_bank_statement/__openerp__.py index cbdc4c52..24a9b7b0 100644 --- a/account_advanced_reconcile_bank_statement/__openerp__.py +++ b/account_advanced_reconcile_bank_statement/__openerp__.py @@ -37,9 +37,8 @@ reconcile the commission with credit card imports). 'depends': ['account_advanced_reconcile'], 'data': ['easy_reconcile_view.xml'], 'demo': [], - 'test': [], # To be ported or migrate to unit tests or scenarios + 'test': [], # To be ported or migrate to unit tests or scenarios 'auto_install': False, 'installable': True, 'images': [] -} -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + } diff --git a/account_advanced_reconcile_bank_statement/easy_reconcile.py b/account_advanced_reconcile_bank_statement/easy_reconcile.py index fc3deaba..53adbbb0 100644 --- a/account_advanced_reconcile_bank_statement/easy_reconcile.py +++ b/account_advanced_reconcile_bank_statement/easy_reconcile.py @@ -34,4 +34,3 @@ class account_easy_reconcile_method(orm.Model): 'Advanced. Partner and Bank Statement'), ] return methods - From 583b156df79d4026b3f942713f5f1abbda4ebe09 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 25 Aug 2014 09:11:28 +0200 Subject: [PATCH 33/84] Cron fails to run when there is no "last history". Fixes #39 --- account_easy_reconcile/easy_reconcile.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index 164f0ac0..8b12ee82 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -365,8 +365,11 @@ class AccountEasyReconcile(orm.Model): """ def _get_date(reconcile): - return datetime.strptime(reconcile.last_history.date, - DEFAULT_SERVER_DATETIME_FORMAT) + if reconcile.last_history.date: + return datetime.strptime(reconcile.last_history.date, + DEFAULT_SERVER_DATETIME_FORMAT) + else: + return datetime.min ids = self.search(cr, uid, [], context=context) assert ids, "No easy reconcile available" From b7d895a31b5fab4c941418d5ab5baf9f8a9935ec Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Tue, 26 Aug 2014 14:35:54 +0200 Subject: [PATCH 34/84] removed outdated comment --- account_advanced_reconcile_bank_statement/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_advanced_reconcile_bank_statement/__openerp__.py b/account_advanced_reconcile_bank_statement/__openerp__.py index 24a9b7b0..c90741fb 100644 --- a/account_advanced_reconcile_bank_statement/__openerp__.py +++ b/account_advanced_reconcile_bank_statement/__openerp__.py @@ -37,7 +37,7 @@ reconcile the commission with credit card imports). 'depends': ['account_advanced_reconcile'], 'data': ['easy_reconcile_view.xml'], 'demo': [], - 'test': [], # To be ported or migrate to unit tests or scenarios + 'test': [], 'auto_install': False, 'installable': True, 'images': [] From a75e1be202c5cf7ebf4d87b9cd4e4c344b50d6af Mon Sep 17 00:00:00 2001 From: Leonardo Pistone Date: Tue, 26 Aug 2014 14:45:35 +0200 Subject: [PATCH 35/84] fix author in header I asked Romain: he is not the author, the header was copy-pasted by mistake. --- account_advanced_reconcile_bank_statement/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/account_advanced_reconcile_bank_statement/__init__.py b/account_advanced_reconcile_bank_statement/__init__.py index 748698d3..0f9a7e4c 100644 --- a/account_advanced_reconcile_bank_statement/__init__.py +++ b/account_advanced_reconcile_bank_statement/__init__.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author: Romain Deheele. Copyright Camptocamp SA +# Author: Matthieu Dietrich +# 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 From 1d24f28d56dc9353e36712b95f58206e508f9b52 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Fri, 5 Sep 2014 15:34:22 +0200 Subject: [PATCH 36/84] [IMP] added unit test for partner fix in completion --- .../__openerp__.py | 99 +++++++++---------- .../test/completion_test.yml | 19 +++- .../test/refund.yml | 43 ++++++++ 3 files changed, 106 insertions(+), 55 deletions(-) create mode 100644 account_statement_base_completion/test/refund.yml diff --git a/account_statement_base_completion/__openerp__.py b/account_statement_base_completion/__openerp__.py index ffb46563..055318e3 100644 --- a/account_statement_base_completion/__openerp__.py +++ b/account_statement_base_completion/__openerp__.py @@ -19,68 +19,61 @@ # ############################################################################## -{ - 'name': "Bank statement base completion", - 'version': '1.0.3', - 'author': 'Camptocamp', - 'maintainer': 'Camptocamp', - 'category': 'Finance', - 'complexity': 'normal', - 'depends': ['account_statement_ext', - 'account_report_company'], - 'description': """ - The goal of this module is to improve the basic bank statement, help dealing - with huge volume of reconciliation by providing basic rules to identify the - partner of a bank statement line. - Each bank statement profile can have its own rules to be applied according to a - sequence order. +{'name': "Bank statement base completion", + 'version': '1.0.3', + 'author': 'Camptocamp', + 'maintainer': 'Camptocamp', + 'category': 'Finance', + 'complexity': 'normal', + 'depends': ['account_statement_ext', + 'account_report_company'], + 'description': """ + The goal of this module is to improve the basic bank statement, help dealing with huge volume of + reconciliation by providing basic rules to identify the partner of a bank statement line. + Each bank statement profile can have its own rules to be applied according to a sequence order. Some basic rules are provided in this module: - 1) Match from statement line label (based on partner field 'Bank Statement - Label') + 1) Match from statement line label (based on partner field 'Bank Statement Label') 2) Match from statement line label (based on partner name) 3) Match from statement line reference (based on Invoice number) - You can easily override this module and add your own rules in your own one. The - basic rules only fill in the partner, but you can use them to fill in any - value of the line (in the future, we will add a rule to automatically match and - reconcile the line). + You can easily override this module and add your own rules in your own one. The basic rules only + fill in the partner, but you can use them to fill in any value of the line (in the future, we will + add a rule to automatically match and reconcile the line). - It adds as well a label on the bank statement line (on which the pre-define - rules can match) and a char field on the partner called 'Bank Statement Label'. - Using the pre-define rules, you will be able to match various labels for a - partner. + It adds as well a label on the bank statement line (on which the pre-define rules can match) and + a char field on the partner called 'Bank Statement Label'. Using the pre-define rules, you will be + able to match various labels for a partner. - The reference of the line is always used by the reconciliation process. We're - supposed to copy there (or write manually) the matching string. This can be: - the order Number or an invoice number, or anything that will be found in the - invoice accounting entry part to make the match. + The reference of the line is always used by the reconciliation process. We're supposed to copy + there (or write manually) the matching string. This can be: the order Number or an invoice number, + or anything that will be found in the invoice accounting entry part to make the match. - You can use it with our account_advanced_reconcile module to automatize the - reconciliation process. + You can use it with our account_advanced_reconcile module to automatize the reconciliation process. - TODO: The rules that look for invoices to find out the partner should take back - the payable / receivable account from there directly instead of retrieving it - from partner properties ! - """, - 'website': 'http://www.camptocamp.com', - 'data': [ - 'statement_view.xml', - 'partner_view.xml', - 'data.xml', - 'security/ir.model.access.csv', - ], - 'demo': [], - 'test': [ - 'test/partner.yml', - 'test/invoice.yml', - 'test/supplier_invoice.yml', - 'test/completion_test.yml' - ], - 'installable': True, - 'images': [], - 'auto_install': False, - 'license': 'AGPL-3', + TODO: The rules that look for invoices to find out the partner should take back the payable / receivable + account from there directly instead of retrieving it from partner properties ! + + """, + 'website': 'http://www.camptocamp.com', + 'data': [ + 'statement_view.xml', + 'partner_view.xml', + 'data.xml', + 'security/ir.model.access.csv', + ], + 'demo': [], + 'test': [ + 'test/partner.yml', + 'test/invoice.yml', + 'test/supplier_invoice.yml', + 'test/refund.yml', + 'test/completion_test.yml' + ], + 'installable': True, + 'images': [], + 'auto_install': False, + 'license': 'AGPL-3', } diff --git a/account_statement_base_completion/test/completion_test.yml b/account_statement_base_completion/test/completion_test.yml index 5b87a959..5f5cdbad 100644 --- a/account_statement_base_completion/test/completion_test.yml +++ b/account_statement_base_completion/test/completion_test.yml @@ -38,6 +38,15 @@ ref: T2S12345 date: '2013-12-19' amount: -65.0 +- + I create a statement line for a CR +- + !record {model: account.bank.statement.line, id: statement_line_cr}: + name: Test autocompletion based on Customer Refund Number + statement_id: statement_test1 + ref: CR0001 + date: '2013-12-19' + amount: -210.0 - I create a statement line for the Partner Name - @@ -76,12 +85,18 @@ !assert {model: account.bank.statement.line, id: statement_line_si, string: Check completion by SI number}: - partner_id.id == _ref("base.res_partner_17") - - Line 3. I check that the partner name has been recognised. + Line 3. I expect the Customer refund number to be recognised. It should be + the commercial partner, and not the regular partner. +- + !assert {model: account.bank.statement.line, id: statement_line_cr, string: Check completion by CR number and commercial partner}: + - partner_id.id == _ref("base.res_partner_12") +- + Line 4. I check that the partner name has been recognised. - !assert {model: account.bank.statement.line, id: statement_line_partner_name, string: Check completion by partner name}: - partner_id.name == 'Vauxoo' - - Line 4. I check that the partner special label has been recognised. + Line 5. I check that the partner special label has been recognised. - !assert {model: account.bank.statement.line, id: statement_line_partner_label, string: Check completion by partner label}: - partner_id.id == _ref("base.res_partner_6") diff --git a/account_statement_base_completion/test/refund.yml b/account_statement_base_completion/test/refund.yml new file mode 100644 index 00000000..f8c07909 --- /dev/null +++ b/account_statement_base_completion/test/refund.yml @@ -0,0 +1,43 @@ +- + I create a "child" partner, to use in the invoice + (and have a different commercial_partner_id than itself) +- + !record {model: res.partner, id: res_partner_12_child}: + name: Child Partner + supplier: False + customer: True + is_company: False + parent_id: base.res_partner_12 +- + I create a customer refund to be found by the completion. +- + !record {model: account.invoice, id: refund_for_completion_1}: + account_id: account.a_pay + company_id: base.main_company + currency_id: base.EUR + internal_number: CR0001 + invoice_line: + - account_id: account.a_expense + name: '[PCSC234] PC Assemble SC234' + price_unit: 210.0 + quantity: 1.0 + product_id: product.product_product_3 + uos_id: product.product_uom_unit + journal_id: account.expenses_journal + partner_id: res_partner_12_child + type: 'out_refund' + reference_type: none +- + I confirm the refund +- + !workflow {model: account.invoice, action: invoice_open, ref: refund_for_completion_1} +- + I check that the refund state is "Open" +- + !assert {model: account.invoice, id: refund_for_completion_1}: + - state == 'open' +- + I check that it is given the number "CR0001" +- + !assert {model: account.invoice, id: refund_for_completion_1, string: Check CI number}: + - number == 'CR0001' From 80d84b8ebd4f87156f80104a4b00f8fed63af05e Mon Sep 17 00:00:00 2001 From: mdietrichc2c Date: Fri, 5 Sep 2014 16:01:32 +0200 Subject: [PATCH 37/84] [FIX] conflict with most recent version of OCA/7.0 --- .../__openerp__.py | 85 ++++++++++--------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/account_statement_base_completion/__openerp__.py b/account_statement_base_completion/__openerp__.py index 055318e3..158b9a55 100644 --- a/account_statement_base_completion/__openerp__.py +++ b/account_statement_base_completion/__openerp__.py @@ -19,18 +19,21 @@ # ############################################################################## -{'name': "Bank statement base completion", - 'version': '1.0.3', - 'author': 'Camptocamp', - 'maintainer': 'Camptocamp', - 'category': 'Finance', - 'complexity': 'normal', - 'depends': ['account_statement_ext', - 'account_report_company'], - 'description': """ - The goal of this module is to improve the basic bank statement, help dealing with huge volume of - reconciliation by providing basic rules to identify the partner of a bank statement line. - Each bank statement profile can have its own rules to be applied according to a sequence order. +{ + 'name': "Bank statement base completion", + 'version': '1.0.3', + 'author': 'Camptocamp', + 'maintainer': 'Camptocamp', + 'category': 'Finance', + 'complexity': 'normal', + 'depends': ['account_statement_ext', + 'account_report_company'], + 'description': """ + The goal of this module is to improve the basic bank statement, help dealing + with huge volume of reconciliation by providing basic rules to identify the + partner of a bank statement line. + Each bank statement profile can have its own rules to be applied according to + a sequence order. Some basic rules are provided in this module: @@ -38,13 +41,15 @@ 2) Match from statement line label (based on partner name) 3) Match from statement line reference (based on Invoice number) - You can easily override this module and add your own rules in your own one. The basic rules only - fill in the partner, but you can use them to fill in any value of the line (in the future, we will - add a rule to automatically match and reconcile the line). + You can easily override this module and add your own rules in your own one. + The basic rules only fill in the partner, but you can use them to fill in + any value of the line (in the future, we will add a rule to automatically + match and reconcile the line). - It adds as well a label on the bank statement line (on which the pre-define rules can match) and - a char field on the partner called 'Bank Statement Label'. Using the pre-define rules, you will be - able to match various labels for a partner. + It adds as well a label on the bank statement line (on which the pre-define + rules can match) and a char field on the partner called 'Bank Statement + Label'. Using the pre-define rules, you will be able to match various + labels for a partner. The reference of the line is always used by the reconciliation process. We're supposed to copy there (or write manually) the matching string. This can be: the order Number or an invoice number, @@ -53,27 +58,27 @@ You can use it with our account_advanced_reconcile module to automatize the reconciliation process. - TODO: The rules that look for invoices to find out the partner should take back the payable / receivable - account from there directly instead of retrieving it from partner properties ! - - """, - 'website': 'http://www.camptocamp.com', - 'data': [ - 'statement_view.xml', - 'partner_view.xml', - 'data.xml', - 'security/ir.model.access.csv', - ], - 'demo': [], - 'test': [ - 'test/partner.yml', - 'test/invoice.yml', - 'test/supplier_invoice.yml', + TODO: The rules that look for invoices to find out the partner should take + back the payable / receivable account from there directly instead of + retrieving it from partner properties! + """, + 'website': 'http://www.camptocamp.com', + 'data': [ + 'statement_view.xml', + 'partner_view.xml', + 'data.xml', + 'security/ir.model.access.csv', + ], + 'demo': [], + 'test': [ + 'test/partner.yml', + 'test/invoice.yml', + 'test/supplier_invoice.yml', 'test/refund.yml', - 'test/completion_test.yml' - ], - 'installable': True, - 'images': [], - 'auto_install': False, - 'license': 'AGPL-3', + 'test/completion_test.yml' + ], + 'installable': True, + 'images': [], + 'auto_install': False, + 'license': 'AGPL-3', } From a71ee406173c9bb84138717d3b28f57c88310e92 Mon Sep 17 00:00:00 2001 From: mdietrichc2c Date: Fri, 5 Sep 2014 16:20:06 +0200 Subject: [PATCH 38/84] [FIX] still some PEP8 issues --- account_statement_base_completion/__openerp__.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/account_statement_base_completion/__openerp__.py b/account_statement_base_completion/__openerp__.py index 158b9a55..9fc0fb0e 100644 --- a/account_statement_base_completion/__openerp__.py +++ b/account_statement_base_completion/__openerp__.py @@ -37,7 +37,8 @@ Some basic rules are provided in this module: - 1) Match from statement line label (based on partner field 'Bank Statement Label') + 1) Match from statement line label (based on partner field 'Bank Statement + Label') 2) Match from statement line label (based on partner name) 3) Match from statement line reference (based on Invoice number) @@ -51,11 +52,13 @@ Label'. Using the pre-define rules, you will be able to match various labels for a partner. - The reference of the line is always used by the reconciliation process. We're supposed to copy - there (or write manually) the matching string. This can be: the order Number or an invoice number, - or anything that will be found in the invoice accounting entry part to make the match. + The reference of the line is always used by the reconciliation process. We're + supposed to copy there (or write manually) the matching string. This can be: + the order Number or an invoice number, or anything that will be found in the + invoice accounting entry part to make the match. - You can use it with our account_advanced_reconcile module to automatize the reconciliation process. + You can use it with our account_advanced_reconcile module to automatize the + reconciliation process. TODO: The rules that look for invoices to find out the partner should take @@ -74,7 +77,7 @@ 'test/partner.yml', 'test/invoice.yml', 'test/supplier_invoice.yml', - 'test/refund.yml', + 'test/refund.yml', 'test/completion_test.yml' ], 'installable': True, From 9c9e0ee08f45bd290e2a52ea89ec272b5b0e959c Mon Sep 17 00:00:00 2001 From: mdietrichc2c Date: Fri, 5 Sep 2014 16:41:19 +0200 Subject: [PATCH 39/84] Update .coveragerc to omit test directory --- .coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/.coveragerc b/.coveragerc index f0fda4fa..d25f247d 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,6 +3,7 @@ include = */bank-statement-reconcile/* omit = + */test/* */tests/* *__init__.py From 5db3d914d18f1476a722fa077eebf3e5033a4c00 Mon Sep 17 00:00:00 2001 From: florian-dacosta Date: Wed, 17 Sep 2014 10:32:23 +0200 Subject: [PATCH 40/84] fix pep8 col --- .../parser/generic_file_parser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/account_statement_base_import/parser/generic_file_parser.py b/account_statement_base_import/parser/generic_file_parser.py index c1da333b..14be05c9 100644 --- a/account_statement_base_import/parser/generic_file_parser.py +++ b/account_statement_base_import/parser/generic_file_parser.py @@ -24,7 +24,9 @@ import csv import tempfile import datetime from file_parser import FileParser -from openerp.addons.account_statement_base_import.parser.file_parser import float_or_zero +from openerp.addons.account_statement_base_import.parser.file_parser import ( + float_or_zero +) from openerp.tools import ustr try: import xlrd @@ -46,7 +48,9 @@ class GenericFileParser(FileParser): 'date': datetime.datetime, 'amount': float_or_zero, } - super(GenericFileParser, self).__init__(parse_name, ftype=ftype, extra_fields=conversion_dict, **kwargs) + super(GenericFileParser, self).__init__(parse_name, ftype=ftype, + extra_fields=conversion_dict, + **kwargs) @classmethod def parser_for(cls, parser_name): From 5e8830fde86a8432e5dda4becbd638f4c3bc0276 Mon Sep 17 00:00:00 2001 From: florian-dacosta Date: Wed, 23 Jul 2014 17:55:39 +0200 Subject: [PATCH 41/84] [FIX] conversion_dict is now created in the generic parser --- .../parser/file_parser.py | 11 ++--------- .../parser/generic_file_parser.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/account_statement_base_import/parser/file_parser.py b/account_statement_base_import/parser/file_parser.py index 7eb107a6..ff8ee482 100644 --- a/account_statement_base_import/parser/file_parser.py +++ b/account_statement_base_import/parser/file_parser.py @@ -46,7 +46,7 @@ class FileParser(BankStatementImportParser): :param char: parse_name: The name of the parser :param char: ftype: extension of the file (could be csv, xls or xlsx) - :param dict: extra_fields: extra fields to add to the conversion + :param dict: extra_fields: extra fields to put into the conversion dict. In the format {fieldname: fieldtype} :param list: header : specify header fields if the csv file has no header @@ -58,14 +58,7 @@ class FileParser(BankStatementImportParser): raise except_orm( _('User Error'), _('Invalid file type %s. Please use csv, xls or xlsx') % ftype) - self.conversion_dict = { - 'ref': unicode, - 'label': unicode, - 'date': datetime.datetime, - 'amount': float_or_zero, - } - if extra_fields: - self.conversion_dict.update(extra_fields) + self.conversion_dict = extra_fields self.keys_to_validate = self.conversion_dict.keys() self.fieldnames = header self._datemode = 0 # used only for xls documents, diff --git a/account_statement_base_import/parser/generic_file_parser.py b/account_statement_base_import/parser/generic_file_parser.py index 03f4dd13..69bc8725 100644 --- a/account_statement_base_import/parser/generic_file_parser.py +++ b/account_statement_base_import/parser/generic_file_parser.py @@ -20,6 +20,11 @@ import datetime from file_parser import FileParser +from openerp.addons.account_statement_base_import.parser.file_parser import float_or_zero +try: + import xlrd +except: + raise Exception(_('Please install python lib xlrd')) class GenericFileParser(FileParser): @@ -30,8 +35,16 @@ class GenericFileParser(FileParser): """ def __init__(self, parse_name, ftype='csv', **kwargs): + conversion_dict = { + 'ref': unicode, + 'label': unicode, + 'date': datetime.datetime, + 'amount': float_or_zero, + } super(GenericFileParser, self).__init__( - parse_name, ftype=ftype, **kwargs) + parse_name, ftype=ftype, + extra_fields=conversion_dict, + **kwargs) @classmethod def parser_for(cls, parser_name): From 02ec16a6aa88d60a67260eccb17d06c4e0ed60f7 Mon Sep 17 00:00:00 2001 From: florian-dacosta Date: Wed, 23 Jul 2014 20:03:03 +0200 Subject: [PATCH 42/84] replace unicode by ustr --- account_statement_base_import/parser/generic_file_parser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/account_statement_base_import/parser/generic_file_parser.py b/account_statement_base_import/parser/generic_file_parser.py index 69bc8725..5c792510 100644 --- a/account_statement_base_import/parser/generic_file_parser.py +++ b/account_statement_base_import/parser/generic_file_parser.py @@ -21,6 +21,7 @@ import datetime from file_parser import FileParser from openerp.addons.account_statement_base_import.parser.file_parser import float_or_zero +from openerp.loglevels import ustr try: import xlrd except: @@ -36,8 +37,8 @@ class GenericFileParser(FileParser): def __init__(self, parse_name, ftype='csv', **kwargs): conversion_dict = { - 'ref': unicode, - 'label': unicode, + 'ref': ustr, + 'label': ustr, 'date': datetime.datetime, 'amount': float_or_zero, } From 923e11395eee57ed2870a81ff08da71f269110d2 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 25 Sep 2014 11:13:30 +0200 Subject: [PATCH 43/84] [FIX] Prevent remove partial reconcile, when you use easy reconcile --- account_easy_reconcile/base_reconciliation.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/account_easy_reconcile/base_reconciliation.py b/account_easy_reconcile/base_reconciliation.py index 9aeb6d44..b324d1ba 100644 --- a/account_easy_reconcile/base_reconciliation.py +++ b/account_easy_reconcile/base_reconciliation.py @@ -79,10 +79,13 @@ class EasyReconcileBase(orm.AbstractModel): return "SELECT %s" % ', '.join(self._base_columns(rec)) def _from(self, rec, *args, **kwargs): - return "FROM account_move_line" + return ("FROM account_move_line " + "LEFT OUTER JOIN account_move_reconcile ON (account_move_line.reconcile_partial_id = account_move_reconcile.id)" + ) def _where(self, rec, *args, **kwargs): where = ("WHERE account_move_line.account_id = %s " + "AND COALESCE(account_move_reconcile.type,'') <> 'manual' " "AND account_move_line.reconcile_id IS NULL ") # it would be great to use dict for params # but as we use _where_calc in _get_filter From ccb58c98780c0e9fe0e0bbc4164a9bedbeb108cf Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 25 Sep 2014 15:14:05 +0200 Subject: [PATCH 44/84] [FIX] pep8 --- account_easy_reconcile/base_reconciliation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/account_easy_reconcile/base_reconciliation.py b/account_easy_reconcile/base_reconciliation.py index b324d1ba..39d321ac 100644 --- a/account_easy_reconcile/base_reconciliation.py +++ b/account_easy_reconcile/base_reconciliation.py @@ -80,7 +80,9 @@ class EasyReconcileBase(orm.AbstractModel): def _from(self, rec, *args, **kwargs): return ("FROM account_move_line " - "LEFT OUTER JOIN account_move_reconcile ON (account_move_line.reconcile_partial_id = account_move_reconcile.id)" + "LEFT OUTER JOIN account_move_reconcile ON " + "(account_move_line.reconcile_partial_id " + "= account_move_reconcile.id)" ) def _where(self, rec, *args, **kwargs): From d4799cfbc37c2c7981d1029821669207f2a39d4e Mon Sep 17 00:00:00 2001 From: florian-dacosta Date: Thu, 25 Sep 2014 15:46:21 +0200 Subject: [PATCH 45/84] Fix pep8 issue --- account_statement_base_import/parser/generic_file_parser.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/account_statement_base_import/parser/generic_file_parser.py b/account_statement_base_import/parser/generic_file_parser.py index 39c1117f..9e5e1a96 100644 --- a/account_statement_base_import/parser/generic_file_parser.py +++ b/account_statement_base_import/parser/generic_file_parser.py @@ -24,10 +24,6 @@ from openerp.addons.account_statement_base_import.parser.file_parser import ( float_or_zero ) from openerp.tools import ustr -try: - import xlrd -except: - raise Exception(_('Please install python lib xlrd')) class GenericFileParser(FileParser): @@ -45,7 +41,7 @@ class GenericFileParser(FileParser): 'amount': float_or_zero, } super(GenericFileParser, self).__init__( - parse_name, ftype=ftype, + parse_name, ftype=ftype, extra_fields=conversion_dict, **kwargs) From 996f837fcb9cc9a5a8a439724d64f13d6352d148 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Fri, 26 Sep 2014 08:12:22 +0200 Subject: [PATCH 46/84] fix unreachable code flagged by pylint --- account_statement_one_move/statement.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/account_statement_one_move/statement.py b/account_statement_one_move/statement.py index 40c4f900..73e46c12 100644 --- a/account_statement_one_move/statement.py +++ b/account_statement_one_move/statement.py @@ -53,8 +53,6 @@ class AccountBankStatement(orm.Model): }) return res - return res - def _prepare_move(self, cr, uid, st_line, st_line_number, context=None): res = super(AccountBankStatement, self).\ _prepare_move(cr, uid, st_line, st_line_number, context=context) From 81b9befac14417794d2ea3fc635c4d58612c177d Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 9 Oct 2014 08:34:56 +0200 Subject: [PATCH 47/84] [FIX] rewrite to fix : https://bugs.launchpad.net/banking-addons/+bug/1301781 --- statement_voucher_killer/voucher.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/statement_voucher_killer/voucher.py b/statement_voucher_killer/voucher.py index b924b8a1..b678bfc5 100644 --- a/statement_voucher_killer/voucher.py +++ b/statement_voucher_killer/voucher.py @@ -72,7 +72,7 @@ class AccountStatementFromInvoiceLines(orm.TransientModel): elif line.journal_id.type in ('purchase', 'purhcase_refund'): s_type = 'supplier' vals = self._prepare_statement_line_vals( - cr, uid, line, s_type, statement_id, amount, context=context) + cr, uid, line, s_type, statement_id, amount, context=ctx) statement_line_obj.create(cr, uid, vals, context=context) return {'type': 'ir.actions.act_window_close'} @@ -86,7 +86,7 @@ class AccountStatementFromInvoiceLines(orm.TransientModel): 'statement_id': statement_id, 'ref': move_line.ref, 'voucher_id': False, - 'date': time.strftime('%Y-%m-%d'), + 'date': context['date'], } @@ -111,7 +111,7 @@ class AccountPaymentPopulateStatement(orm.TransientModel): for line in line_obj.browse(cr, uid, line_ids, context=context): ctx = context.copy() # Last value_date earlier,but this field exists no more now - ctx['date'] = line.ml_maturity_date + ctx['date'] = line.date or statement.date amount = currency_obj.compute( cr, uid, line.currency.id, statement.currency.id, line.amount_currency, context=ctx) @@ -119,7 +119,7 @@ class AccountPaymentPopulateStatement(orm.TransientModel): continue context.update({'move_line_ids': [line.move_line_id.id]}) vals = self._prepare_statement_line_vals( - cr, uid, line, -amount, statement, context=context) + cr, uid, line, -amount, statement, context=ctx) st_line_id = statement_line_obj.create(cr, uid, vals, context=context) line_obj.write( @@ -136,6 +136,5 @@ class AccountPaymentPopulateStatement(orm.TransientModel): 'account_id': payment_line.move_line_id.account_id.id, 'statement_id': statement.id, 'ref': payment_line.communication, - 'date': (payment_line.date or payment_line.ml_maturity_date or - statement.date) + 'date': context['date'] } From 9b4688bfe05af7b47621c5998df30860978a0a77 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 9 Oct 2014 09:26:38 +0200 Subject: [PATCH 48/84] [ADD] test file --- .../test/correct_date_in_move_line.yml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 statement_voucher_killer/test/correct_date_in_move_line.yml diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml new file mode 100644 index 00000000..4bb22d9c --- /dev/null +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -0,0 +1,29 @@ +- + In order to test if the correct date is set in the bank statement + I create a bank statement +- + !record {model: account.bank.statement, id: statement_test_date1}: + name: Statement for Date + journal_id: account.bank_journal + company_id: base.main_company + balance_end_real : 1000.0 +- + I create a statement line for a SO +- + !record {model: account.bank.statement.line, id: statement_line_so}: + name: Test autocompletion based on Sale Order Number + statement_id: statement_test_date1 + ref: DATE1 + date: '2014-12-20' + amount: 1000.0 +- + I confirm the bank statement +- + !python {model: account.bank.statement}: | + result = self.button_confirm_bank(cr, uid, [ref("statement_test_sale1")]) +- + Now I can check that all is nice and shiny, line 1. I expect the Sale Order + Number to be recognised. +- + !assert {model: account.move.line, statement_id: statement_test_date1, string: Check date in move line}: + - date == '2014-12-20' From 4088bf87c272ecce2151df8ad1b889b547b8780e Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 9 Oct 2014 09:29:09 +0200 Subject: [PATCH 49/84] [FIx] include test in __openerp__.py --- statement_voucher_killer/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statement_voucher_killer/__openerp__.py b/statement_voucher_killer/__openerp__.py index 8a595f2e..fc12607e 100644 --- a/statement_voucher_killer/__openerp__.py +++ b/statement_voucher_killer/__openerp__.py @@ -42,6 +42,6 @@ line will be take from imported line in this order: 'data': [ 'statement_view.xml', ], - 'test': [], + 'test': [test/correct_date_in_move_line.yml], 'installable': True, } From e0d576f07126a01f6ba6be566b4b0b0d0d465fbf Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 9 Oct 2014 10:33:33 +0200 Subject: [PATCH 50/84] [FIX] improve test --- statement_voucher_killer/__openerp__.py | 2 +- .../test/correct_date_in_move_line.yml | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/statement_voucher_killer/__openerp__.py b/statement_voucher_killer/__openerp__.py index fc12607e..d82792a8 100644 --- a/statement_voucher_killer/__openerp__.py +++ b/statement_voucher_killer/__openerp__.py @@ -42,6 +42,6 @@ line will be take from imported line in this order: 'data': [ 'statement_view.xml', ], - 'test': [test/correct_date_in_move_line.yml], + 'test': ['test/correct_date_in_move_line.yml'], 'installable': True, } diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml index 4bb22d9c..6867f562 100644 --- a/statement_voucher_killer/test/correct_date_in_move_line.yml +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -10,20 +10,22 @@ - I create a statement line for a SO - - !record {model: account.bank.statement.line, id: statement_line_so}: + !record {model: account.bank.statement.line, id: statement_line_date}: name: Test autocompletion based on Sale Order Number statement_id: statement_test_date1 ref: DATE1 + account_id : account.a_sale date: '2014-12-20' amount: 1000.0 - I confirm the bank statement - !python {model: account.bank.statement}: | - result = self.button_confirm_bank(cr, uid, [ref("statement_test_sale1")]) + result = self.button_confirm_bank(cr, uid, [ref("statement_test_date1")]) - - Now I can check that all is nice and shiny, line 1. I expect the Sale Order - Number to be recognised. + Now I can check that that the date in move line is equal to line date - - !assert {model: account.move.line, statement_id: statement_test_date1, string: Check date in move line}: - - date == '2014-12-20' + !python {model: account.move.line}: | + line_ids = self.search(cr, uid, [('statement_id', '=', ref('statement_test_date1'))],limit=1) + line = self.browse(cr, uid, line_ids)[0] + assert line.date == '2014-12-20', "Date (2014-12-20) not equal to = %s" % line.date From b7c37f8d7cfcb1b28e2de64af22132019f3fc5ee Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 9 Oct 2014 11:28:21 +0200 Subject: [PATCH 51/84] [FIX] test --- .../test/correct_date_in_move_line.yml | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml index 6867f562..4c691bed 100644 --- a/statement_voucher_killer/test/correct_date_in_move_line.yml +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -1,10 +1,26 @@ +- + In order to test the bank statement date , I first need to + create a profile +- + !record {model: account.statement.profile, id: profile_test_date}: + name: Bank EUR Profile for check date + journal_id: account.bank_journal + commission_account_id: account.a_expense + company_id: base.main_company + balance_check: True + rule_ids: + - account_statement_base_completion.bank_statement_completion_rule_4 + - account_statement_base_completion.bank_statement_completion_rule_5 + - account_statement_base_completion.bank_statement_completion_rule_2 + - account_statement_base_completion.bank_statement_completion_rule_3 + - bank_statement_completion_rule_1 - In order to test if the correct date is set in the bank statement I create a bank statement - !record {model: account.bank.statement, id: statement_test_date1}: name: Statement for Date - journal_id: account.bank_journal + profile_id: profile_test_date company_id: base.main_company balance_end_real : 1000.0 - @@ -15,7 +31,7 @@ statement_id: statement_test_date1 ref: DATE1 account_id : account.a_sale - date: '2014-12-20' + date: !eval time.strftime('%Y-12-20') amount: 1000.0 - I confirm the bank statement @@ -28,4 +44,4 @@ !python {model: account.move.line}: | line_ids = self.search(cr, uid, [('statement_id', '=', ref('statement_test_date1'))],limit=1) line = self.browse(cr, uid, line_ids)[0] - assert line.date == '2014-12-20', "Date (2014-12-20) not equal to = %s" % line.date + assert line.date == !eval time.strftime('%Y-12-20'), "Date (year-12-20) not equal to = %s" % line.date From 7f20dba3ec446f96e6ee51c78ccff15e1ac16c5a Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 9 Oct 2014 11:34:54 +0200 Subject: [PATCH 52/84] Typo in purchase_refund, resulting in a 'general' type instead of 'supplier' --- statement_voucher_killer/voucher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statement_voucher_killer/voucher.py b/statement_voucher_killer/voucher.py index b924b8a1..24575815 100644 --- a/statement_voucher_killer/voucher.py +++ b/statement_voucher_killer/voucher.py @@ -69,7 +69,7 @@ class AccountStatementFromInvoiceLines(orm.TransientModel): s_type = 'general' if line.journal_id.type in ('sale', 'sale_refund'): s_type = 'customer' - elif line.journal_id.type in ('purchase', 'purhcase_refund'): + elif line.journal_id.type in ('purchase', 'purchase_refund'): s_type = 'supplier' vals = self._prepare_statement_line_vals( cr, uid, line, s_type, statement_id, amount, context=context) From b7739606016978717b273fdfe2cc83c83d4efec3 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 10 Oct 2014 10:58:41 +0200 Subject: [PATCH 53/84] Add tests that fail to check the copy of supplier_invoice_number to reference on create and write --- account_invoice_reference/__openerp__.py | 1 + .../test/supplier_invoice_number.yml | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 account_invoice_reference/test/supplier_invoice_number.yml diff --git a/account_invoice_reference/__openerp__.py b/account_invoice_reference/__openerp__.py index 2ad8758d..cda206a0 100644 --- a/account_invoice_reference/__openerp__.py +++ b/account_invoice_reference/__openerp__.py @@ -141,6 +141,7 @@ Information propagated to the move lines: 'test/out_refund_without_origin.yml', 'test/in_refund_with_supplier_number.yml', 'test/in_refund_without_supplier_number.yml', + 'test/supplier_invoice_number.yml', ], 'installable': True, diff --git a/account_invoice_reference/test/supplier_invoice_number.yml b/account_invoice_reference/test/supplier_invoice_number.yml new file mode 100644 index 00000000..846fc63f --- /dev/null +++ b/account_invoice_reference/test/supplier_invoice_number.yml @@ -0,0 +1,47 @@ +- + In order to check if the reference is populated from the supplier_invoice_number + I create an invoice. +- + !record {model: account.invoice, id: invoice_supplier_invoice_number, view: account.invoice_supplier_form}: + account_id: account.a_pay + check_total: 3000.0 + company_id: base.main_company + currency_id: base.EUR + invoice_line: + - account_id: account.a_expense + name: '[PCSC234] PC Assemble SC234' + price_unit: 300.0 + product_id: product.product_product_3 + quantity: 10.0 + uos_id: product.product_uom_unit + journal_id: account.expenses_journal + partner_id: base.res_partner_12 + reference_type: none + supplier_invoice_number: ZZZ246 + type: in_invoice +- + Set again the type of the invoice (not set on the first one...) +- + !record {model: account.invoice, id: invoice_supplier_invoice_number, view: account.invoice_supplier_form}: + type: in_invoice +- + Ensure that the reference is the same than the supplier_invoice_number +- + !assert {model: account.invoice, id: invoice_supplier_invoice_number}: + - reference == 'ZZZ246' +- + In order to check if the supplier_invoice_number is copied to the supplier_invoice_number + when the reference is empty, I empty the reference +- + !record {model: account.invoice, id: invoice_supplier_invoice_number, view: account.invoice_supplier_form}: + reference: +- + And I write a new supplier_invoice_number +- + !record {model: account.invoice, id: invoice_supplier_invoice_number, view: account.invoice_supplier_form}: + supplier_invoice_number: ABC789 +- + Ensure that the reference is the same than the supplier_invoice_number +- + !assert {model: account.invoice, id: invoice_supplier_invoice_number}: + - reference == 'ABC789' From 00b71007ad7563144b7aa097a3c1eb6c858d30da Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 10 Oct 2014 11:12:20 +0200 Subject: [PATCH 54/84] Make the failing test passes, the fields is named supplier_invoice_number not supplier_invoice_reference Conflicts: account_invoice_reference/account_invoice.py Wrong cherry-pick --- account_invoice_reference/account_move.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/account_invoice_reference/account_move.py b/account_invoice_reference/account_move.py index b99689b8..b280679c 100644 --- a/account_invoice_reference/account_move.py +++ b/account_invoice_reference/account_move.py @@ -79,22 +79,23 @@ class AccountInvoice(orm.Model): return True def create(self, cr, uid, vals, context=None): - if (vals.get('supplier_invoice_reference') and not + if (vals.get('supplier_invoice_number') and not vals.get('reference')): - vals['reference'] = vals['supplier_invoice_reference'] + vals = vals.copy() + vals['reference'] = vals['supplier_invoice_number'] return super(AccountInvoice, self).create(cr, uid, vals, context=context) def write(self, cr, uid, ids, vals, context=None): - if vals.get('supplier_invoice_reference'): - if isinstance(ids, (int, long)): - ids = [ids] + if vals.get('supplier_invoice_number'): for invoice in self.browse(cr, uid, ids, context=context): + loc_vals = None if not invoice.reference: - locvals = vals.copy() - locvals['reference'] = vals['supplier_invoice_reference'] + loc_vals = vals.copy() + loc_vals['reference'] = vals['supplier_invoice_number'] super(AccountInvoice, self).write(cr, uid, [invoice.id], - locvals, context=context) + loc_vals or vals, + context=context) return True else: return super(AccountInvoice, self).write(cr, uid, ids, vals, From 7279247310e3f00a3cb005a3f8775c242803d566 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 10 Oct 2014 13:13:54 +0200 Subject: [PATCH 55/84] ids could be int/long --- account_invoice_reference/account_move.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/account_invoice_reference/account_move.py b/account_invoice_reference/account_move.py index b280679c..9dce2205 100644 --- a/account_invoice_reference/account_move.py +++ b/account_invoice_reference/account_move.py @@ -88,6 +88,8 @@ class AccountInvoice(orm.Model): def write(self, cr, uid, ids, vals, context=None): if vals.get('supplier_invoice_number'): + if isinstance(ids, (int, long)): + ids = [ids] for invoice in self.browse(cr, uid, ids, context=context): loc_vals = None if not invoice.reference: From e8931ac9aeedf92b43dd64e43e6c12ca80364554 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Fri, 10 Oct 2014 14:42:22 +0200 Subject: [PATCH 56/84] [FIX] improve test --- .../test/correct_date_in_move_line.yml | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml index 4c691bed..1206ecc6 100644 --- a/statement_voucher_killer/test/correct_date_in_move_line.yml +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -1,26 +1,10 @@ -- - In order to test the bank statement date , I first need to - create a profile -- - !record {model: account.statement.profile, id: profile_test_date}: - name: Bank EUR Profile for check date - journal_id: account.bank_journal - commission_account_id: account.a_expense - company_id: base.main_company - balance_check: True - rule_ids: - - account_statement_base_completion.bank_statement_completion_rule_4 - - account_statement_base_completion.bank_statement_completion_rule_5 - - account_statement_base_completion.bank_statement_completion_rule_2 - - account_statement_base_completion.bank_statement_completion_rule_3 - - bank_statement_completion_rule_1 - In order to test if the correct date is set in the bank statement I create a bank statement - !record {model: account.bank.statement, id: statement_test_date1}: name: Statement for Date - profile_id: profile_test_date + journal_id: account.bank_journal company_id: base.main_company balance_end_real : 1000.0 - From 50b2e859f025a1e37f38604af64145e8a01bee42 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Fri, 10 Oct 2014 14:44:20 +0200 Subject: [PATCH 57/84] [IMP] statement_voucher_killer is a not related to easy_reconcile module, it's useful to make the test without this module installed --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f3f41c18..40dc8cb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,11 @@ virtualenv: system_site_packages: true env: - - VERSION="7.0" ODOO_REPO="odoo/odoo" EXCLUDE="account_statement_ext_point_of_sale" - - VERSION="7.0" ODOO_REPO="OCA/OCB" EXCLUDE="account_statement_ext_point_of_sale" + - VERSION="7.0" ODOO_REPO="odoo/odoo" EXCLUDE="account_statement_ext_point_of_sale,statement_voucher_killer" + - VERSION="7.0" ODOO_REPO="OCA/OCB" EXCLUDE="account_statement_ext_point_of_sale,statement_voucher_killer" + + - VERSION="7.0" ODOO_REPO="odoo/odoo" INCLUDE="statement_voucher_killer" + - VERSION="7.0" ODOO_REPO="OCA/OCB" INCLUDE="statement_voucher_killer" install: - git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools From d600eff7a2773d697c16de8473d9ed51e29e9c47 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Fri, 10 Oct 2014 15:01:23 +0200 Subject: [PATCH 58/84] [FIX] remove eval in python --- statement_voucher_killer/test/correct_date_in_move_line.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml index 1206ecc6..84b29520 100644 --- a/statement_voucher_killer/test/correct_date_in_move_line.yml +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -28,4 +28,4 @@ !python {model: account.move.line}: | line_ids = self.search(cr, uid, [('statement_id', '=', ref('statement_test_date1'))],limit=1) line = self.browse(cr, uid, line_ids)[0] - assert line.date == !eval time.strftime('%Y-12-20'), "Date (year-12-20) not equal to = %s" % line.date + assert line.date == time.strftime('%Y-12-20'), "Date (year-12-20) not equal to = %s" % line.date From 7d29ec2f3387460f4d8bc5a9496147b9106521eb Mon Sep 17 00:00:00 2001 From: vrenaville Date: Fri, 10 Oct 2014 15:25:40 +0200 Subject: [PATCH 59/84] [FIX] missing import time --- statement_voucher_killer/test/correct_date_in_move_line.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml index 84b29520..c7147920 100644 --- a/statement_voucher_killer/test/correct_date_in_move_line.yml +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -26,6 +26,7 @@ Now I can check that that the date in move line is equal to line date - !python {model: account.move.line}: | + import time line_ids = self.search(cr, uid, [('statement_id', '=', ref('statement_test_date1'))],limit=1) line = self.browse(cr, uid, line_ids)[0] assert line.date == time.strftime('%Y-12-20'), "Date (year-12-20) not equal to = %s" % line.date From 0f9ee8776e1162d054fd1d0f83df643825231b32 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Fri, 10 Oct 2014 17:48:09 +0200 Subject: [PATCH 60/84] [FIX] improve test --- .../test/correct_date_in_move_line.yml | 113 ++++++++++++++++-- 1 file changed, 103 insertions(+), 10 deletions(-) diff --git a/statement_voucher_killer/test/correct_date_in_move_line.yml b/statement_voucher_killer/test/correct_date_in_move_line.yml index c7147920..77e44bfe 100644 --- a/statement_voucher_killer/test/correct_date_in_move_line.yml +++ b/statement_voucher_killer/test/correct_date_in_move_line.yml @@ -1,3 +1,96 @@ + +- + In order to test the process of payment order, I start with the supplier invoice. +- + !python {model: account.invoice}: | + self.write(cr, uid, [ref('account.demo_invoice_0')], {'check_total': -14}) + +- + In order to test account move line of journal, I check that there is no move attached to the invoice. +- + !python {model: account.invoice}: | + invoice = self.browse(cr, uid, ref("account.demo_invoice_0")) + assert (not invoice.move_id), "Moves are wrongly created for invoice." +- + I open the invoice. +- + !workflow {model: account.invoice, action: invoice_open, ref: account.demo_invoice_0} +- + I check that the invoice state is now "Open". +- + !assert {model: account.invoice, id: account.demo_invoice_0, severity: error, string: Invoice should be in 'Open' state}: + - state == 'open' +- + I create a payment order +- + !record {model: payment.order, id: date1_payment_order}: + #date_created + #date_done + date_prefered: due + #date_scheduled + #line_ids: + mode: account_payment.payment_mode_1 + #reference + state: draft + total: -14 + #user_id + +- + I confirm the payment order. +- + !workflow {model: payment.order, action: open, ref: date1_payment_order} +- + I check that payment order is now "Confirmed". +- + !assert {model: payment.order, id: date1_payment_order, severity: error, string: Payment Order should be 'Confirmed'.}: + - state == 'open' +- + !record {model: payment.order.create, id: payment_order_create_0}: + duedate: !eval time.strftime('%Y-%m-%d') + +- + I search for the invoice entries to make the payment. +- + !python {model: payment.order.create}: | + self.search_entries(cr, uid, [ref("payment_order_create_0")], { + "active_model": "payment.order", "active_ids": [ref("date1_payment_order")], + "active_id": ref("date1_payment_order"), }) +- + I create payment lines entries. +- + !python {model: payment.order.create}: | + invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account.demo_invoice_0")) + move_line = invoice.move_id.line_id[0] + self.write(cr, uid, [ref("payment_order_create_0")], {'entries': [(6,0,[move_line.id])]}) + self.create_payment(cr, uid, [ref("payment_order_create_0")], { + "active_model": "payment.order", "active_ids": [ref("date1_payment_order")], + "active_id": ref("date1_payment_order")}) + +- + After making all payments, I finish the payment order. +- + !python {model: payment.order}: | + self.set_done(cr, uid, [ref("date1_payment_order")]) +- + I check that payment order is now "Done". +- + !assert {model: payment.order, id: date1_payment_order, severity: error, string: Payment Order should be in 'Done' state}: + - state == 'done' + +- + I check that payment line is created with proper data. +- + !python {model: payment.order}: | + invoice = self.pool.get('account.invoice').browse(cr, uid, ref("account.demo_invoice_0")) + payment = self.browse(cr, uid, ref("date1_payment_order")) + payment_line = payment.line_ids[0] + + assert payment_line.move_line_id, "move line is not created in payment line." + assert invoice.move_id.name == payment_line.ml_inv_ref.number, "invoice reference number is not same created." + assert invoice.partner_id == payment_line.partner_id, "Partner is not correct." + assert invoice.date_due == payment_line.ml_maturity_date, "Due date is not correct." + assert invoice.amount_total == payment_line.amount, "Payment amount is not correct." + - In order to test if the correct date is set in the bank statement I create a bank statement @@ -6,17 +99,17 @@ name: Statement for Date journal_id: account.bank_journal company_id: base.main_company - balance_end_real : 1000.0 + balance_end_real : -14.0 - - I create a statement line for a SO + I import payment order lines for the bank statement. - - !record {model: account.bank.statement.line, id: statement_line_date}: - name: Test autocompletion based on Sale Order Number - statement_id: statement_test_date1 - ref: DATE1 - account_id : account.a_sale - date: !eval time.strftime('%Y-12-20') - amount: 1000.0 + !python {model: account.payment.populate.statement}: | + payment = self.pool.get('payment.order').browse(cr, uid, ref("date1_payment_order")) + payment_line = payment.line_ids[0] + import_payment_id = self.create(cr, uid, {'lines': [(6,0,[payment_line.id])]}) + self.populate_statement(cr, uid, [import_payment_id], {"statement_id": ref("statement_test_date1"), + "active_model": "account.bank.statement", "journal_type": "cash", + "active_id": ref("statement_test_date1")}) - I confirm the bank statement - @@ -29,4 +122,4 @@ import time line_ids = self.search(cr, uid, [('statement_id', '=', ref('statement_test_date1'))],limit=1) line = self.browse(cr, uid, line_ids)[0] - assert line.date == time.strftime('%Y-12-20'), "Date (year-12-20) not equal to = %s" % line.date + assert line.date == time.strftime('%Y-01-31'), "Date (year-01-31) not equal to = %s" % line.date From f72ae6b1b7beff70550f9001a458f667e3d953e0 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 13 Oct 2014 11:57:16 +0200 Subject: [PATCH 61/84] Fixes #55 bad encoding in account_statement_base_completion/i18n/fr.po --- account_statement_base_completion/i18n/fr.po | 34 ++++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/account_statement_base_completion/i18n/fr.po b/account_statement_base_completion/i18n/fr.po index c68fd383..eecfbb2a 100644 --- a/account_statement_base_completion/i18n/fr.po +++ b/account_statement_base_completion/i18n/fr.po @@ -84,7 +84,7 @@ msgstr "" #. module: account_statement_base_completion #: model:ir.model,name:account_statement_base_completion.model_account_bank_statement_line msgid "Bank Statement Line" -msgstr "Ligne de relevé bancaire" +msgstr "Ligne de relevé bancaire" #. module: account_statement_base_completion #: field:account.bank.statement.line,additionnal_bank_fields:0 @@ -94,12 +94,12 @@ msgstr "Informations additionnelles de la banque" #. module: account_statement_base_completion #: view:account.statement.profile:0 msgid "Auto-Completion Rules" -msgstr "Règles d'auto-complétion" +msgstr "Règles d'auto-complétion" #. module: account_statement_base_completion #: view:account.bank.statement:0 msgid "Importation related infos" -msgstr "Importation des informations liées" +msgstr "Importation des informations liées" #. module: account_statement_base_completion #: code:addons/account_statement_base_completion/statement.py:159 @@ -121,14 +121,14 @@ msgstr "" #. module: account_statement_base_completion #: view:account.bank.statement:0 msgid "Auto Completion" -msgstr "Auto-complétion" +msgstr "Auto-complétion" #. module: account_statement_base_completion #: view:account.statement.completion.rule:0 #: model:ir.actions.act_window,name:account_statement_base_completion.action_st_completion_rule_tree #: model:ir.ui.menu,name:account_statement_base_completion.menu_action_st_completion_rule_tree_menu msgid "Statement Completion Rule" -msgstr "Règle d'auto-complétion du relevé" +msgstr "Règle d'auto-complétion du relevé" #. module: account_statement_base_completion #: model:ir.model,name:account_statement_base_completion.model_account_statement_completion_rule @@ -146,7 +146,7 @@ msgstr "" #: field:account.statement.completion.rule,profile_ids:0 #: field:account.statement.profile,rule_ids:0 msgid "Related statement profiles" -msgstr "Profils liés" +msgstr "Profils liés" #. module: account_statement_base_completion #: code:addons/account_statement_base_completion/statement.py:158 @@ -158,7 +158,7 @@ msgstr "" #. module: account_statement_base_completion #: field:account.bank.statement.line,already_completed:0 msgid "Auto-Completed" -msgstr "Auto-Completé" +msgstr "Auto-Complété" #. module: account_statement_base_completion #: code:addons/account_statement_base_completion/statement.py:448 @@ -170,7 +170,7 @@ msgstr "" #. module: account_statement_base_completion #: field:account.statement.completion.rule,sequence:0 msgid "Sequence" -msgstr "Séquence" +msgstr "Séquence" #. module: account_statement_base_completion #: code:addons/account_statement_base_completion/statement.py:280 @@ -183,12 +183,12 @@ msgstr "" #. module: account_statement_base_completion #: help:account.statement.completion.rule,sequence:0 msgid "Lower means parsed first." -msgstr "Plus petite séquence analysée en premier." +msgstr "Plus petite séquence analysée en premier." #. module: account_statement_base_completion #: field:res.partner,bank_statement_label:0 msgid "Bank Statement Label" -msgstr "Description de relevé bancaire" +msgstr "Description de relevé bancaire" #. module: account_statement_base_completion #: help:account.bank.statement.line,already_completed:0 @@ -196,8 +196,8 @@ msgid "" "When this checkbox is ticked, the auto-completion process/button will ignore " "this line." msgstr "" -"Les lignes cochées seront ignorées lorsque vous cliquez sur le bouton auto-" -"complétion" +"Les lignes cochées seront ignorées lorsque vous cliquez sur le bouton auto-" +"complétion" #. module: account_statement_base_completion #: help:res.partner,bank_statement_label:0 @@ -207,10 +207,10 @@ msgid "" "partner will be automatically filled (as long as you use " "this method/rules in your statement profile)." msgstr "" -"Entrez les différentes descriptions/informations sur votre relevé bancaire " -"séparées par un ';' Si l'une d'entre elles figure dans la ligne du " -"relevé, le partenaire correspondant pourraêtre automatiquement retrouvé " -"(à condition d'utiliser un règle de lettrage dans le profil)." +"Entrez les différentes descriptions/informations sur votre relevé bancaire " +"séparées par un ';' Si l'une d'entre elles figure dans la ligne du " +"relevé, le partenaire correspondant sera automatiquement retrouvé " +"(à condition d'utiliser un règle de lettrage dans le profil)." #. module: account_statement_base_completion #: model:ir.model,name:account_statement_base_completion.model_res_partner @@ -220,4 +220,4 @@ msgstr "Partenaire" #. module: account_statement_base_completion #: view:account.bank.statement:0 msgid "Completion Logs" -msgstr "Journaux d'auto-complétion" +msgstr "Journaux d'auto-complétion" From a1d7b1513e32c2961730318333078f63ef70deff Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Fri, 17 Oct 2014 13:03:27 +0200 Subject: [PATCH 62/84] Modify _last_history function to correctly retrieve the date --- account_easy_reconcile/easy_reconcile.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index 8b12ee82..4195a895 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -162,11 +162,16 @@ class AccountEasyReconcile(orm.Model): def _last_history(self, cr, uid, ids, name, args, context=None): result = {} - for history in self.browse(cr, uid, ids, context=context): - result[history.id] = False - if history.history_ids: - # history is sorted by date desc - result[history.id] = history.history_ids[0].id + # do a search() for retrieving the latest history line, + # as a read() will badly split the list of ids with 'date desc' + # and return the wrong result. + for reconcile_id in ids: + history_obj = self.pool['easy.reconcile.history'] + last_history = history_obj.search( + cr, uid, [('easy_reconcile_id', '=', reconcile_id)], + limit=1, order='date desc' + ) + result[reconcile_id] = last_history return result _columns = { From 67f7ba24b6e1dbe7136001c7cd644466d811f621 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Fri, 17 Oct 2014 15:04:18 +0200 Subject: [PATCH 63/84] Remove self.pool from loop and unnecessary variable --- account_easy_reconcile/easy_reconcile.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index 4195a895..d3865477 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -165,13 +165,12 @@ class AccountEasyReconcile(orm.Model): # do a search() for retrieving the latest history line, # as a read() will badly split the list of ids with 'date desc' # and return the wrong result. + history_obj = self.pool['easy.reconcile.history'] for reconcile_id in ids: - history_obj = self.pool['easy.reconcile.history'] - last_history = history_obj.search( + result[reconcile_id] = history_obj.search( cr, uid, [('easy_reconcile_id', '=', reconcile_id)], limit=1, order='date desc' ) - result[reconcile_id] = last_history return result _columns = { From c15f22cec9322dcf8b0200a05990582020eb75e2 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Fri, 17 Oct 2014 15:27:52 +0200 Subject: [PATCH 64/84] Add length check + retrieve first element from search result --- account_easy_reconcile/easy_reconcile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index d3865477..c2c0cb93 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -167,10 +167,14 @@ class AccountEasyReconcile(orm.Model): # and return the wrong result. history_obj = self.pool['easy.reconcile.history'] for reconcile_id in ids: - result[reconcile_id] = history_obj.search( + last_history = history_obj.search( cr, uid, [('easy_reconcile_id', '=', reconcile_id)], limit=1, order='date desc' ) + if len(last_history) > 0: + result[reconcile_id] = last_history[0] + else: + result[reconcile_id] = False return result _columns = { From 4b5467fb280d03ae2394588531f4494f1c6258cb Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Fri, 17 Oct 2014 15:41:07 +0200 Subject: [PATCH 65/84] Replace by compact form (PEP8-compatible) --- account_easy_reconcile/easy_reconcile.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index c2c0cb93..ae1b9009 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -171,10 +171,8 @@ class AccountEasyReconcile(orm.Model): cr, uid, [('easy_reconcile_id', '=', reconcile_id)], limit=1, order='date desc' ) - if len(last_history) > 0: - result[reconcile_id] = last_history[0] - else: - result[reconcile_id] = False + result[reconcile_id] = len(last_history) \ + and last_history[0] or False return result _columns = { From 9754eb336bd91a761e69f671af5249ea35f8880e Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 17 Oct 2014 17:06:36 +0200 Subject: [PATCH 66/84] [PEP8] --- account_advanced_reconcile_bank_statement/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_advanced_reconcile_bank_statement/__openerp__.py b/account_advanced_reconcile_bank_statement/__openerp__.py index c90741fb..cd62e051 100644 --- a/account_advanced_reconcile_bank_statement/__openerp__.py +++ b/account_advanced_reconcile_bank_statement/__openerp__.py @@ -20,7 +20,7 @@ ############################################################################## {'name': 'Advanced Reconcile Bank Statement', - 'description': """ + 'description': """ Advanced reconciliation method for the module account_advanced_reconcile ======================================================================== Reconcile rules with bank statement name. From 0bdaa2d84fc2f60947c6e5803fdcbb273b3c0dc9 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Mon, 20 Oct 2014 11:07:41 +0200 Subject: [PATCH 67/84] Propagate context + rework ternary if --- account_easy_reconcile/easy_reconcile.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index ae1b9009..b3a14388 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -169,10 +169,9 @@ class AccountEasyReconcile(orm.Model): for reconcile_id in ids: last_history = history_obj.search( cr, uid, [('easy_reconcile_id', '=', reconcile_id)], - limit=1, order='date desc' + limit=1, order='date desc', context=context ) - result[reconcile_id] = len(last_history) \ - and last_history[0] or False + result[reconcile_id] = last_history[0] if last_history else False return result _columns = { From b741dbdb05a9cacdd16e39c46723aae3ada027b2 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Fri, 24 Oct 2014 09:49:59 +0200 Subject: [PATCH 68/84] Adapt TransactionIDFileParser to new FileParser (introduced with https://github.com/OCA/bank-statement-reconcile/commit/5e8830fde86a8432e5dda4becbd638f4c3bc0276) --- .../parser/transactionid_file_parser.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/account_statement_transactionid_import/parser/transactionid_file_parser.py b/account_statement_transactionid_import/parser/transactionid_file_parser.py index 873155e1..bc9aadb5 100644 --- a/account_statement_transactionid_import/parser/transactionid_file_parser.py +++ b/account_statement_transactionid_import/parser/transactionid_file_parser.py @@ -18,7 +18,10 @@ # ############################################################################## import datetime -from account_statement_base_import.parser.file_parser import FileParser +from openerp.tools import ustr +from account_statement_base_import.parser.file_parser import ( + FileParser, float_or_zero +) class TransactionIDFileParser(FileParser): @@ -36,14 +39,15 @@ class TransactionIDFileParser(FileParser): :param list: header : specify header fields if the csv file has no header """ - extra_fields = {'transaction_id': unicode} + conversion_dict = { + 'transaction_id': ustr, + 'label': ustr, + 'date': datetime.datetime, + 'amount': float_or_zero, + } super(TransactionIDFileParser, self).__init__( - profile, extra_fields=extra_fields, ftype=ftype, header=header, + profile, extra_fields=conversion_dict, ftype=ftype, header=header, **kwargs) - # ref is replaced by transaction_id thus we delete it from check - self.keys_to_validate = [ - k for k in self.keys_to_validate if k != 'ref'] - del self.conversion_dict['ref'] @classmethod def parser_for(cls, parser_name): From 5fa89db115f0a7b8399d11fddb26856eeae16993 Mon Sep 17 00:00:00 2001 From: ecino Date: Wed, 29 Oct 2014 15:45:12 +0100 Subject: [PATCH 69/84] [FIX] If balance_start is set by parser and equals 0.0, don't override it with default value --- account_statement_base_import/statement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_statement_base_import/statement.py b/account_statement_base_import/statement.py index f8301e1b..2c9b1212 100644 --- a/account_statement_base_import/statement.py +++ b/account_statement_base_import/statement.py @@ -135,7 +135,7 @@ class AccountStatementProfil(orm.Model): """ vals = {'profile_id': profile_id} vals.update(parser.get_st_vals()) - if not vals.get('balance_start'): + if 'balance_start' not in vals.keys(): # Get starting balance from journal balance if parser doesn't # fill this data, simulating the manual flow statement_obj = self.pool['account.bank.statement'] From bf9d9fd2a94d146856a772ef6a3d2a8c417f8a23 Mon Sep 17 00:00:00 2001 From: ecino Date: Wed, 29 Oct 2014 16:19:18 +0100 Subject: [PATCH 70/84] Code style improvement --- account_statement_base_import/statement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_statement_base_import/statement.py b/account_statement_base_import/statement.py index 2c9b1212..19671ee1 100644 --- a/account_statement_base_import/statement.py +++ b/account_statement_base_import/statement.py @@ -135,7 +135,7 @@ class AccountStatementProfil(orm.Model): """ vals = {'profile_id': profile_id} vals.update(parser.get_st_vals()) - if 'balance_start' not in vals.keys(): + if 'balance_start' not in vals: # Get starting balance from journal balance if parser doesn't # fill this data, simulating the manual flow statement_obj = self.pool['account.bank.statement'] From 5209acc765dc5f5476412cbf6db982082630382c Mon Sep 17 00:00:00 2001 From: ecino Date: Thu, 30 Oct 2014 07:48:33 +0100 Subject: [PATCH 71/84] Adapt to the fact that the parser always return something for balance_start. --- account_statement_base_import/statement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_statement_base_import/statement.py b/account_statement_base_import/statement.py index 19671ee1..c87013b0 100644 --- a/account_statement_base_import/statement.py +++ b/account_statement_base_import/statement.py @@ -135,7 +135,7 @@ class AccountStatementProfil(orm.Model): """ vals = {'profile_id': profile_id} vals.update(parser.get_st_vals()) - if 'balance_start' not in vals: + if vals.get('balance_start') is None: # Get starting balance from journal balance if parser doesn't # fill this data, simulating the manual flow statement_obj = self.pool['account.bank.statement'] From 3c585eb55bde97164ed6c76aa0881552f020bbe3 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Wed, 19 Nov 2014 16:18:10 +0100 Subject: [PATCH 72/84] Use the correct accounts for write-off --- account_easy_reconcile/base_reconciliation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_easy_reconcile/base_reconciliation.py b/account_easy_reconcile/base_reconciliation.py index 39d321ac..d133b994 100644 --- a/account_easy_reconcile/base_reconciliation.py +++ b/account_easy_reconcile/base_reconciliation.py @@ -183,7 +183,7 @@ class EasyReconcileBase(orm.AbstractModel): cr, uid, rec, lines, rec.date_base_on, context=context) rec_ctx = dict(context, date_p=date) if below_writeoff: - if sum_credit < sum_debit: + if sum_credit > sum_debit: writeoff_account_id = rec.account_profit_id.id else: writeoff_account_id = rec.account_lost_id.id From 2540f699b4c7991552ef481ef1fddc9639e134dd Mon Sep 17 00:00:00 2001 From: moylop260 Date: Thu, 13 Nov 2014 18:13:05 -0600 Subject: [PATCH 73/84] Fix Pylint warnings --- account_advanced_reconcile/__init__.py | 6 +++--- account_easy_reconcile/__init__.py | 10 +++++----- account_statement_base_completion/statement.py | 2 +- account_statement_base_import/__init__.py | 6 +++--- account_statement_base_import/parser/__init__.py | 8 ++++---- account_statement_base_import/parser/file_parser.py | 4 ++-- .../parser/generic_file_parser.py | 2 +- account_statement_base_import/statement.py | 3 +-- account_statement_base_import/wizard/__init__.py | 2 +- account_statement_cancel_line/__init__.py | 6 +++--- account_statement_cancel_line/wizard/__init__.py | 4 ++-- account_statement_commission/__init__.py | 2 +- account_statement_ext/__init__.py | 8 ++++---- account_statement_ext/report/__init__.py | 2 +- account_statement_ext/statement.py | 2 +- account_statement_ofx_import/__init__.py | 4 ++-- .../statement.py | 4 ++-- account_statement_transactionid_completion/__init__.py | 2 +- account_statement_transactionid_import/__init__.py | 4 ++-- .../parser/__init__.py | 2 +- 20 files changed, 41 insertions(+), 42 deletions(-) diff --git a/account_advanced_reconcile/__init__.py b/account_advanced_reconcile/__init__.py index 5ee0093a..e1a57902 100644 --- a/account_advanced_reconcile/__init__.py +++ b/account_advanced_reconcile/__init__.py @@ -20,6 +20,6 @@ # ############################################################################## -import easy_reconcile -import base_advanced_reconciliation -import advanced_reconciliation +from . import easy_reconcile +from . import base_advanced_reconciliation +from . import advanced_reconciliation diff --git a/account_easy_reconcile/__init__.py b/account_easy_reconcile/__init__.py index 87ea0fc3..0b0a2b53 100755 --- a/account_easy_reconcile/__init__.py +++ b/account_easy_reconcile/__init__.py @@ -19,8 +19,8 @@ # ############################################################################## -import easy_reconcile -import base_reconciliation -import simple_reconciliation -import easy_reconcile_history -import res_config +from . import easy_reconcile +from . import base_reconciliation +from . import simple_reconciliation +from . import easy_reconcile_history +from . import res_config diff --git a/account_statement_base_completion/statement.py b/account_statement_base_completion/statement.py index 4edf3cf3..12bf2d31 100644 --- a/account_statement_base_completion/statement.py +++ b/account_statement_base_completion/statement.py @@ -329,7 +329,7 @@ class AccountStatementCompletionRule(orm.Model): # to: # http://www.postgresql.org/docs/9.0/static/functions-matching.html # in chapter 9.7.3.6. Limits and Compatibility - sql = """ + sql = r""" SELECT id FROM ( SELECT id, regexp_matches(%s, diff --git a/account_statement_base_import/__init__.py b/account_statement_base_import/__init__.py index 7c864205..2fe60a3e 100644 --- a/account_statement_base_import/__init__.py +++ b/account_statement_base_import/__init__.py @@ -18,6 +18,6 @@ # along with this program. If not, see . # ############################################################################## -import parser -import wizard -import statement +from . import parser +from . import wizard +from . import statement diff --git a/account_statement_base_import/parser/__init__.py b/account_statement_base_import/parser/__init__.py index c802d6b1..cb73080b 100644 --- a/account_statement_base_import/parser/__init__.py +++ b/account_statement_base_import/parser/__init__.py @@ -19,7 +19,7 @@ # ############################################################################## -from parser import new_bank_statement_parser -from parser import BankStatementImportParser -import file_parser -import generic_file_parser +from .parser import new_bank_statement_parser +from .parser import BankStatementImportParser +from . import file_parser +from . import generic_file_parser diff --git a/account_statement_base_import/parser/file_parser.py b/account_statement_base_import/parser/file_parser.py index ff8ee482..ac8dfbe0 100644 --- a/account_statement_base_import/parser/file_parser.py +++ b/account_statement_base_import/parser/file_parser.py @@ -21,8 +21,8 @@ from openerp.tools.translate import _ from openerp.osv.orm import except_orm import tempfile import datetime -from parser import BankStatementImportParser -from parser import UnicodeDictReader +from .parser import BankStatementImportParser +from .parser import UnicodeDictReader try: import xlrd except: diff --git a/account_statement_base_import/parser/generic_file_parser.py b/account_statement_base_import/parser/generic_file_parser.py index 9e5e1a96..47e98445 100644 --- a/account_statement_base_import/parser/generic_file_parser.py +++ b/account_statement_base_import/parser/generic_file_parser.py @@ -19,7 +19,7 @@ ############################################################################## import datetime -from file_parser import FileParser +from .file_parser import FileParser from openerp.addons.account_statement_base_import.parser.file_parser import ( float_or_zero ) diff --git a/account_statement_base_import/statement.py b/account_statement_base_import/statement.py index c87013b0..83e250f3 100644 --- a/account_statement_base_import/statement.py +++ b/account_statement_base_import/statement.py @@ -23,7 +23,7 @@ import traceback from openerp.tools.translate import _ import datetime from openerp.osv import fields, orm -from parser import new_bank_statement_parser +from .parser import new_bank_statement_parser from openerp.tools.config import config @@ -74,7 +74,6 @@ class AccountStatementProfil(orm.Model): statement ID :param: context: global context """ - pass def write_logs_after_import(self, cr, uid, ids, statement_id, num_lines, context): diff --git a/account_statement_base_import/wizard/__init__.py b/account_statement_base_import/wizard/__init__.py index 5dbd2b0c..888026df 100644 --- a/account_statement_base_import/wizard/__init__.py +++ b/account_statement_base_import/wizard/__init__.py @@ -17,4 +17,4 @@ # along with this program. If not, see . # ############################################################################## -import import_statement +from . import import_statement diff --git a/account_statement_cancel_line/__init__.py b/account_statement_cancel_line/__init__.py index 153ef95a..9ec2ed82 100644 --- a/account_statement_cancel_line/__init__.py +++ b/account_statement_cancel_line/__init__.py @@ -20,6 +20,6 @@ ############################################################################### """Account Statement Cancel Line.""" -import statement # noqa -import statement_line # noqa -import wizard # noqa +from . import statement # noqa +from . import statement_line # noqa +from . import wizard # noqa diff --git a/account_statement_cancel_line/wizard/__init__.py b/account_statement_cancel_line/wizard/__init__.py index 49b74d3f..89af38cf 100644 --- a/account_statement_cancel_line/wizard/__init__.py +++ b/account_statement_cancel_line/wizard/__init__.py @@ -20,5 +20,5 @@ ############################################################################### """Wizard for asking the confirmation when some move is reconciled.""" -import cancel_statement # noqa -import cancel_statement_line # noqa +from . import cancel_statement # noqa +from . import cancel_statement_line # noqa diff --git a/account_statement_commission/__init__.py b/account_statement_commission/__init__.py index 5ba29072..65fff538 100644 --- a/account_statement_commission/__init__.py +++ b/account_statement_commission/__init__.py @@ -19,4 +19,4 @@ # along with this program. If not, see . # ############################################################################## -import commission +from . import commission diff --git a/account_statement_ext/__init__.py b/account_statement_ext/__init__.py index 7bf22aa2..5e15fac6 100644 --- a/account_statement_ext/__init__.py +++ b/account_statement_ext/__init__.py @@ -19,7 +19,7 @@ # ############################################################################## -import statement -import report -import account -import voucher +from . import statement +from . import report +from . import account +from . import voucher diff --git a/account_statement_ext/report/__init__.py b/account_statement_ext/report/__init__.py index 14b13013..29a4bdaf 100644 --- a/account_statement_ext/report/__init__.py +++ b/account_statement_ext/report/__init__.py @@ -23,4 +23,4 @@ # ############################################################################## -import bank_statement_report +from . import bank_statement_report diff --git a/account_statement_ext/statement.py b/account_statement_ext/statement.py index a3a45a2d..748db07e 100644 --- a/account_statement_ext/statement.py +++ b/account_statement_ext/statement.py @@ -447,7 +447,7 @@ class AccountBankStatement(orm.Model): def get_account_for_counterpart(self, cr, uid, amount, account_receivable, account_payable): """For backward compatibility.""" - account_id, type = self.get_account_and_type_for_counterpart( + account_id, account_type = self.get_account_and_type_for_counterpart( cr, uid, amount, account_receivable, account_payable) return account_id diff --git a/account_statement_ofx_import/__init__.py b/account_statement_ofx_import/__init__.py index 19462c05..71e18ac5 100644 --- a/account_statement_ofx_import/__init__.py +++ b/account_statement_ofx_import/__init__.py @@ -18,5 +18,5 @@ # along with this program. If not, see . # ############################################################################## -import statement -import parser +from . import statement +from . import parser diff --git a/account_statement_regex_account_completion/statement.py b/account_statement_regex_account_completion/statement.py index 6a232b02..cc697de0 100644 --- a/account_statement_regex_account_completion/statement.py +++ b/account_statement_regex_account_completion/statement.py @@ -54,7 +54,7 @@ class AccountStatementCompletionRule(Model): string="Account to set"), } - def set_account(self, cr, uid, id, st_line, context=None): + def set_account(self, cr, uid, account_id, st_line, context=None): """ If line name match regex, update account_id Then, call the generic st_line method to complete other values. @@ -69,7 +69,7 @@ class AccountStatementCompletionRule(Model): name = st_line['name'] res = {} if name: - rule = self.browse(cr, uid, id, context=context) + rule = self.browse(cr, uid, account_id, context=context) if re.match(rule.regex, name): res['account_id'] = rule.account_id.id return res diff --git a/account_statement_transactionid_completion/__init__.py b/account_statement_transactionid_completion/__init__.py index a8ce7c24..647f811c 100644 --- a/account_statement_transactionid_completion/__init__.py +++ b/account_statement_transactionid_completion/__init__.py @@ -19,4 +19,4 @@ # ############################################################################## -import statement +from . import statement diff --git a/account_statement_transactionid_import/__init__.py b/account_statement_transactionid_import/__init__.py index 29698b5e..874730ea 100644 --- a/account_statement_transactionid_import/__init__.py +++ b/account_statement_transactionid_import/__init__.py @@ -18,5 +18,5 @@ # along with this program. If not, see . # ############################################################################## -import parser -import statement +from . import parser +from . import statement diff --git a/account_statement_transactionid_import/parser/__init__.py b/account_statement_transactionid_import/parser/__init__.py index de4553b9..9cc12870 100644 --- a/account_statement_transactionid_import/parser/__init__.py +++ b/account_statement_transactionid_import/parser/__init__.py @@ -19,4 +19,4 @@ # ############################################################################## -import transactionid_file_parser +from . import transactionid_file_parser From fe3cfe406c921603b3a543e588342192f8ece897 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 27 Nov 2014 10:48:21 +0100 Subject: [PATCH 74/84] [ADD] allow exchange rate setting settings in easy reconcile --- account_easy_reconcile/base_reconciliation.py | 22 +++++++++++++++++ account_easy_reconcile/easy_reconcile.py | 24 +++++++++++++++++++ account_easy_reconcile/easy_reconcile.xml | 6 +++++ 3 files changed, 52 insertions(+) diff --git a/account_easy_reconcile/base_reconciliation.py b/account_easy_reconcile/base_reconciliation.py index d133b994..595c1201 100644 --- a/account_easy_reconcile/base_reconciliation.py +++ b/account_easy_reconcile/base_reconciliation.py @@ -215,10 +215,32 @@ class EasyReconcileBase(orm.AbstractModel): if set(line_ids) == partial_line_ids: return True, False + # We need to give a writeoff_acc_id + # in case we have a multi currency lines + # to reconcile. + # If amount in currency is equal between + # lines to reconcile + # it will do a full reconcile instead of a partial reconcile + # and make a write-off for exchange + if rec.account_id.currency_id: + if sum_credit > sum_debit: + writeoff_account_id = rec.income_exchange_account_id.id + else: + writeoff_account_id = rec.expense_exchange_account_id.id + period_id = self.pool.get('account.period').find( + cr, uid, dt=date, context=context)[0] + if rec.analytic_account_id: + rec_ctx['analytic_id'] = rec.analytic_account_id.id + else: + writeoff_account_id = False + period_id = False ml_obj.reconcile_partial( cr, uid, line_ids, type='manual', + writeoff_acc_id=writeoff_account_id, + writeoff_period_id=period_id, + writeoff_journal_id=rec.journal_id.id, context=rec_ctx) return True, False return False, False diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index b3a14388..bb598605 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -47,6 +47,14 @@ class EasyReconcileOptions(orm.AbstractModel): ('newest_debit', 'Date of most recent debit') ] + def _get_account_currency(self, cr, uid, ids, field_name, arg, + context=None): + result = {} + for line in self.browse(cr, uid, ids, context=context): + # Always provide second currency + result[line.id] = bool(line.task_id.account.currency_id.id) + return result + _columns = { 'write_off': fields.float('Write off allowed'), 'account_lost_id': fields.many2one( @@ -63,6 +71,16 @@ class EasyReconcileOptions(orm.AbstractModel): 'analytic_account_id': fields.many2one( 'account.analytic.account', 'Analytic Account', help="Analytic account for the write-off"), + 'account_has_currency': fields.function( + _get_account_currency, + type='boolean', + string='has currency', + help="Check if related account has currency."), + 'income_exchange_account_id': fields.many2one( + 'account.account', 'Gain Exchange Rate Account'), + 'expense_exchange_account_id': fields.many2one( + 'account.account', 'Loss Exchange Rate Account'), + } _defaults = { @@ -210,6 +228,12 @@ class AccountEasyReconcile(orm.Model): rec_method.account_profit_id.id), 'analytic_account_id': (rec_method.analytic_account_id and rec_method.analytic_account_id.id), + 'income_exchange_account_id': + (rec_method.income_exchange_account_id and + rec_method.income_exchange_account_id.id), + 'expense_exchange_account_id': + (rec_method.income_exchange_account_id and + rec_method.income_exchange_account_id.id), 'journal_id': (rec_method.journal_id and rec_method.journal_id.id), 'date_base_on': rec_method.date_base_on, diff --git a/account_easy_reconcile/easy_reconcile.xml b/account_easy_reconcile/easy_reconcile.xml index d191fbb8..c23c7f05 100644 --- a/account_easy_reconcile/easy_reconcile.xml +++ b/account_easy_reconcile/easy_reconcile.xml @@ -129,6 +129,9 @@ The lines should have the same amount (with the write-off) and the same referenc + + + @@ -147,6 +150,9 @@ The lines should have the same amount (with the write-off) and the same referenc + + + From 56adbb2195d583d42164f23b03d59206f9662536 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Thu, 27 Nov 2014 17:21:05 +0100 Subject: [PATCH 75/84] [ADD] translation --- .../i18n/account_easy_reconcile.pot | 21 ++++++++++++++++++ account_easy_reconcile/i18n/fr.po | 22 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/account_easy_reconcile/i18n/account_easy_reconcile.pot b/account_easy_reconcile/i18n/account_easy_reconcile.pot index 4f878273..598b81ea 100644 --- a/account_easy_reconcile/i18n/account_easy_reconcile.pot +++ b/account_easy_reconcile/i18n/account_easy_reconcile.pot @@ -404,3 +404,24 @@ msgstr "" msgid "account easy reconcile" msgstr "" +#. module: account_easy_reconcile +#: field:account.easy.reconcile.method,expense_exchange_account_id:0 +#: field:easy.reconcile.base,expense_exchange_account_id:0 +#: field:easy.reconcile.options,expense_exchange_account_id:0 +#: field:easy.reconcile.simple,expense_exchange_account_id:0 +#: field:easy.reconcile.simple.name,expense_exchange_account_id:0 +#: field:easy.reconcile.simple.partner,expense_exchange_account_id:0 +#: field:easy.reconcile.simple.reference,expense_exchange_account_id:0 +msgid "Loss Exchange Rate Account" +msgstr "" + +#. module: account_easy_reconcile +#: field:account.easy.reconcile.method,income_exchange_account_id:0 +#: field:easy.reconcile.base,income_exchange_account_id:0 +#: field:easy.reconcile.options,income_exchange_account_id:0 +#: field:easy.reconcile.simple,income_exchange_account_id:0 +#: field:easy.reconcile.simple.name,income_exchange_account_id:0 +#: field:easy.reconcile.simple.partner,income_exchange_account_id:0 +#: field:easy.reconcile.simple.reference,income_exchange_account_id:0 +msgid "Gain Exchange Rate Account" +msgstr "" diff --git a/account_easy_reconcile/i18n/fr.po b/account_easy_reconcile/i18n/fr.po index 431f2c0b..957765d4 100644 --- a/account_easy_reconcile/i18n/fr.po +++ b/account_easy_reconcile/i18n/fr.po @@ -427,3 +427,25 @@ msgstr "easy.reconcile.simple.reference" #: model:ir.model,name:account_easy_reconcile.model_account_easy_reconcile msgid "account easy reconcile" msgstr "Lettrage automatisé" + +#. module: account_easy_reconcile +#: field:account.easy.reconcile.method,expense_exchange_account_id:0 +#: field:easy.reconcile.base,expense_exchange_account_id:0 +#: field:easy.reconcile.options,expense_exchange_account_id:0 +#: field:easy.reconcile.simple,expense_exchange_account_id:0 +#: field:easy.reconcile.simple.name,expense_exchange_account_id:0 +#: field:easy.reconcile.simple.partner,expense_exchange_account_id:0 +#: field:easy.reconcile.simple.reference,expense_exchange_account_id:0 +msgid "Loss Exchange Rate Account" +msgstr "Compte de perte de change" + +#. module: account_easy_reconcile +#: field:account.easy.reconcile.method,income_exchange_account_id:0 +#: field:easy.reconcile.base,income_exchange_account_id:0 +#: field:easy.reconcile.options,income_exchange_account_id:0 +#: field:easy.reconcile.simple,income_exchange_account_id:0 +#: field:easy.reconcile.simple.name,income_exchange_account_id:0 +#: field:easy.reconcile.simple.partner,income_exchange_account_id:0 +#: field:easy.reconcile.simple.reference,income_exchange_account_id:0 +msgid "Gain Exchange Rate Account" +msgstr "Compte de gain de change" From 1934dff60d8bbe2a841f26d4928673527a26c6f0 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Fri, 28 Nov 2014 08:38:24 +0100 Subject: [PATCH 76/84] [FIX] remove test currency_id has it's done by required in the view --- account_easy_reconcile/base_reconciliation.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/account_easy_reconcile/base_reconciliation.py b/account_easy_reconcile/base_reconciliation.py index 595c1201..09606339 100644 --- a/account_easy_reconcile/base_reconciliation.py +++ b/account_easy_reconcile/base_reconciliation.py @@ -222,18 +222,14 @@ class EasyReconcileBase(orm.AbstractModel): # lines to reconcile # it will do a full reconcile instead of a partial reconcile # and make a write-off for exchange - if rec.account_id.currency_id: - if sum_credit > sum_debit: - writeoff_account_id = rec.income_exchange_account_id.id - else: - writeoff_account_id = rec.expense_exchange_account_id.id - period_id = self.pool.get('account.period').find( - cr, uid, dt=date, context=context)[0] - if rec.analytic_account_id: - rec_ctx['analytic_id'] = rec.analytic_account_id.id + if sum_credit > sum_debit: + writeoff_account_id = rec.income_exchange_account_id.id else: - writeoff_account_id = False - period_id = False + writeoff_account_id = rec.expense_exchange_account_id.id + period_id = self.pool.get('account.period').find( + cr, uid, dt=date, context=context)[0] + if rec.analytic_account_id: + rec_ctx['analytic_id'] = rec.analytic_account_id.id ml_obj.reconcile_partial( cr, uid, line_ids, From d58dc3decc65ea389e952f29c3f5d6425b2c832e Mon Sep 17 00:00:00 2001 From: vrenaville Date: Tue, 2 Dec 2014 09:35:28 +0100 Subject: [PATCH 77/84] [FIX] Improve by adding group multicurrency and remove test on currency of account --- account_easy_reconcile/easy_reconcile.py | 13 ------------- account_easy_reconcile/easy_reconcile.xml | 10 ++++------ 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index bb598605..34d0604c 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -47,14 +47,6 @@ class EasyReconcileOptions(orm.AbstractModel): ('newest_debit', 'Date of most recent debit') ] - def _get_account_currency(self, cr, uid, ids, field_name, arg, - context=None): - result = {} - for line in self.browse(cr, uid, ids, context=context): - # Always provide second currency - result[line.id] = bool(line.task_id.account.currency_id.id) - return result - _columns = { 'write_off': fields.float('Write off allowed'), 'account_lost_id': fields.many2one( @@ -71,11 +63,6 @@ class EasyReconcileOptions(orm.AbstractModel): 'analytic_account_id': fields.many2one( 'account.analytic.account', 'Analytic Account', help="Analytic account for the write-off"), - 'account_has_currency': fields.function( - _get_account_currency, - type='boolean', - string='has currency', - help="Check if related account has currency."), 'income_exchange_account_id': fields.many2one( 'account.account', 'Gain Exchange Rate Account'), 'expense_exchange_account_id': fields.many2one( diff --git a/account_easy_reconcile/easy_reconcile.xml b/account_easy_reconcile/easy_reconcile.xml index c23c7f05..1a95139b 100644 --- a/account_easy_reconcile/easy_reconcile.xml +++ b/account_easy_reconcile/easy_reconcile.xml @@ -129,9 +129,8 @@ The lines should have the same amount (with the write-off) and the same referenc - - - + + @@ -150,9 +149,8 @@ The lines should have the same amount (with the write-off) and the same referenc - - - + + From 59004faf8cea0e72df071dd4be7039bfc9fc3b8c Mon Sep 17 00:00:00 2001 From: vrenaville Date: Wed, 3 Dec 2014 10:43:21 +0100 Subject: [PATCH 78/84] [FIX] improve syntax --- account_easy_reconcile/base_reconciliation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_easy_reconcile/base_reconciliation.py b/account_easy_reconcile/base_reconciliation.py index 09606339..35ce4920 100644 --- a/account_easy_reconcile/base_reconciliation.py +++ b/account_easy_reconcile/base_reconciliation.py @@ -226,7 +226,7 @@ class EasyReconcileBase(orm.AbstractModel): writeoff_account_id = rec.income_exchange_account_id.id else: writeoff_account_id = rec.expense_exchange_account_id.id - period_id = self.pool.get('account.period').find( + period_id = self.pool['account.period'].find( cr, uid, dt=date, context=context)[0] if rec.analytic_account_id: rec_ctx['analytic_id'] = rec.analytic_account_id.id From 8bb62071f38d24f4908a7f848341acce8a137e77 Mon Sep 17 00:00:00 2001 From: florian-dacosta Date: Wed, 10 Dec 2014 18:44:29 +0100 Subject: [PATCH 79/84] add possibility to create a dialect for the csv file --- account_statement_base_import/parser/file_parser.py | 6 ++++-- account_statement_base_import/parser/parser.py | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/account_statement_base_import/parser/file_parser.py b/account_statement_base_import/parser/file_parser.py index ac8dfbe0..706e0b2d 100644 --- a/account_statement_base_import/parser/file_parser.py +++ b/account_statement_base_import/parser/file_parser.py @@ -41,7 +41,7 @@ class FileParser(BankStatementImportParser): """ def __init__(self, parse_name, ftype='csv', extra_fields=None, header=None, - **kwargs): + dialect=None, **kwargs): """ :param char: parse_name: The name of the parser :param char: ftype: extension of the file (could be csv, xls or @@ -64,6 +64,7 @@ class FileParser(BankStatementImportParser): self._datemode = 0 # used only for xls documents, # 0 means Windows mode (1900 based dates). # Set in _parse_xls, from the contents of the file + self.dialect = dialect def _custom_format(self, *args, **kwargs): """No other work on data are needed in this parser.""" @@ -111,7 +112,8 @@ class FileParser(BankStatementImportParser): csv_file.write(self.filebuffer) csv_file.flush() with open(csv_file.name, 'rU') as fobj: - reader = UnicodeDictReader(fobj, fieldnames=self.fieldnames) + reader = UnicodeDictReader(fobj, fieldnames=self.fieldnames, + dialect=self.dialect) return list(reader) def _parse_xls(self): diff --git a/account_statement_base_import/parser/parser.py b/account_statement_base_import/parser/parser.py index 9618157d..80cfbd0d 100644 --- a/account_statement_base_import/parser/parser.py +++ b/account_statement_base_import/parser/parser.py @@ -29,11 +29,15 @@ def UnicodeDictReader(utf8_data, **kwargs): pos = utf8_data.tell() sample_data = utf8_data.read(2048) utf8_data.seek(pos) - dialect = sniffer.sniff(sample_data, delimiters=',;\t') + if not kwargs.get('dialect'): + dialect = sniffer.sniff(sample_data, delimiters=',;\t') + del kwargs['dialect'] + else: + dialect = kwargs.pop('dialect') csv_reader = csv.DictReader(utf8_data, dialect=dialect, **kwargs) for row in csv_reader: - yield dict([(key, unicode(value, 'utf-8')) for key, value in - row.iteritems()]) + yield dict([(unicode(key, 'utf-8'), unicode(value, 'utf-8')) + for key, value in row.iteritems() if key]) class BankStatementImportParser(object): From 705ecf861c0d2e3ceb92619cad93b03f0322788b Mon Sep 17 00:00:00 2001 From: florian-dacosta Date: Thu, 11 Dec 2014 14:31:05 +0100 Subject: [PATCH 80/84] fix account_statement_base_import --- account_statement_base_import/parser/parser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/account_statement_base_import/parser/parser.py b/account_statement_base_import/parser/parser.py index 80cfbd0d..999be4b0 100644 --- a/account_statement_base_import/parser/parser.py +++ b/account_statement_base_import/parser/parser.py @@ -36,8 +36,9 @@ def UnicodeDictReader(utf8_data, **kwargs): dialect = kwargs.pop('dialect') csv_reader = csv.DictReader(utf8_data, dialect=dialect, **kwargs) for row in csv_reader: - yield dict([(unicode(key, 'utf-8'), unicode(value, 'utf-8')) - for key, value in row.iteritems() if key]) + yield dict([(unicode(key or '', 'utf-8'), + unicode(value or '', 'utf-8')) + for key, value in row.iteritems()]) class BankStatementImportParser(object): From d2b6bc8391e61242374cc507779081a72efe3247 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Wed, 7 Jan 2015 15:49:37 +0100 Subject: [PATCH 81/84] Add history line + error message if reconciliation fails --- account_easy_reconcile/easy_reconcile.py | 15 +++++++++++++++ account_easy_reconcile/easy_reconcile.xml | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index 34d0604c..ff65ad91 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -139,6 +139,7 @@ class AccountEasyReconcileMethod(orm.Model): class AccountEasyReconcile(orm.Model): _name = 'account.easy.reconcile' + _inherit = ['mail.thread'] _description = 'account easy reconcile' def _get_total_unrec(self, cr, uid, ids, name, arg, context=None): @@ -283,6 +284,20 @@ class AccountEasyReconcile(orm.Model): 'reconcile_ids': [(4, rid) for rid in reconcile_ids], 'reconcile_partial_ids': [(4, rid) for rid in partial_ids], }, context=context) + except Exception as e: + # In case of error, we log it in the mail thread, + # and create an empty history line; otherwise, the cron + # will just loop on this reconcile task. + message = "There was an error during reconciliation : %s" \ + % e.value + self.message_post(cr, uid, rec.id, + body=message, context=context) + self.pool.get('easy.reconcile.history').create(new_cr, uid, { + 'easy_reconcile_id': rec.id, + 'date': fields.datetime.now(), + 'reconcile_ids': [], + 'reconcile_partial_ids': [], + }) finally: if ctx['commit_every']: new_cr.commit() diff --git a/account_easy_reconcile/easy_reconcile.xml b/account_easy_reconcile/easy_reconcile.xml index 1a95139b..076bd3b3 100644 --- a/account_easy_reconcile/easy_reconcile.xml +++ b/account_easy_reconcile/easy_reconcile.xml @@ -71,6 +71,10 @@ The lines should have the same amount (with the write-off) and the same referenc +
+ + +
From 7784845f29ea7b07698bcdd3db9e12973aa2395c Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Thu, 8 Jan 2015 12:06:18 +0100 Subject: [PATCH 82/84] Add stack trace in case of exception --- account_easy_reconcile/easy_reconcile.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index ff65ad91..04482992 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -25,6 +25,9 @@ from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT from openerp.tools.translate import _ from openerp import pooler +import logging +_logger = logging.getLogger(__name__) + class EasyReconcileOptions(orm.AbstractModel): """Options of a reconciliation profile @@ -285,13 +288,15 @@ class AccountEasyReconcile(orm.Model): 'reconcile_partial_ids': [(4, rid) for rid in partial_ids], }, context=context) except Exception as e: - # In case of error, we log it in the mail thread, - # and create an empty history line; otherwise, the cron - # will just loop on this reconcile task. + # In case of error, we log it in the mail thread, log the + # stack trace and create an empty history line; otherwise, + # the cron will just loop on this reconcile task. message = "There was an error during reconciliation : %s" \ % e.value self.message_post(cr, uid, rec.id, body=message, context=context) + _logger.exception("The reconcile task %s had an exception: %s", + rec.name, e.value) self.pool.get('easy.reconcile.history').create(new_cr, uid, { 'easy_reconcile_id': rec.id, 'date': fields.datetime.now(), From 152add76f9605c577ede86a0d8a675b88532483d Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Thu, 8 Jan 2015 12:17:29 +0100 Subject: [PATCH 83/84] logger before message (to catch evental DB cursor issues) --- account_easy_reconcile/easy_reconcile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py index 04482992..89af1759 100644 --- a/account_easy_reconcile/easy_reconcile.py +++ b/account_easy_reconcile/easy_reconcile.py @@ -291,12 +291,12 @@ class AccountEasyReconcile(orm.Model): # In case of error, we log it in the mail thread, log the # stack trace and create an empty history line; otherwise, # the cron will just loop on this reconcile task. + _logger.exception("The reconcile task %s had an exception: %s", + rec.name, e.value) message = "There was an error during reconciliation : %s" \ % e.value self.message_post(cr, uid, rec.id, body=message, context=context) - _logger.exception("The reconcile task %s had an exception: %s", - rec.name, e.value) self.pool.get('easy.reconcile.history').create(new_cr, uid, { 'easy_reconcile_id': rec.id, 'date': fields.datetime.now(), From ae8742fbb55249241eff36eb1264ae79c6c5acba Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Tue, 13 Jan 2015 09:53:15 +0100 Subject: [PATCH 84/84] Fixes #80 --- account_statement_cancel_line/test/cancel_line.yml | 4 ++-- .../test/confirm_statement_no_double_moves.yml | 4 ++-- .../test/test_confirm_last_line_balance_check.yml | 2 +- .../test/test_confirm_last_line_no_balance_check.yml | 2 +- .../test/completion_transactionid_test.yml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/account_statement_cancel_line/test/cancel_line.yml b/account_statement_cancel_line/test/cancel_line.yml index 032ab054..579f1e79 100644 --- a/account_statement_cancel_line/test/cancel_line.yml +++ b/account_statement_cancel_line/test/cancel_line.yml @@ -22,7 +22,7 @@ name: line1 statement_id: statement_test ref: ref1 - date: '2014-01-20' + date: !eval "'%s-01-20' %(datetime.now().year)" amount: 100.0 - I create a second statement line @@ -31,7 +31,7 @@ name: line2 statement_id: statement_test ref: ref2 - date: '2014-01-25' + date: !eval "'%s-01-25' %(datetime.now().year)" amount: 200.0 - I check that the state of the statement is "Draft" diff --git a/account_statement_cancel_line/test/confirm_statement_no_double_moves.yml b/account_statement_cancel_line/test/confirm_statement_no_double_moves.yml index 0fa66bb3..cb649977 100644 --- a/account_statement_cancel_line/test/confirm_statement_no_double_moves.yml +++ b/account_statement_cancel_line/test/confirm_statement_no_double_moves.yml @@ -23,7 +23,7 @@ name: line11 statement_id: statement_test_10 ref: ref11 - date: '2014-01-20' + date: !eval "'%s-01-20' %(datetime.now().year)" amount: 100.0 - I create a second statement line @@ -32,7 +32,7 @@ name: line12 statement_id: statement_test_10 ref: ref12 - date: '2014-01-25' + date: !eval "'%s-01-25' %(datetime.now().year)" amount: 200.0 - Now I confirm only the first statement line diff --git a/account_statement_cancel_line/test/test_confirm_last_line_balance_check.yml b/account_statement_cancel_line/test/test_confirm_last_line_balance_check.yml index 8afc5a81..47c90f4b 100644 --- a/account_statement_cancel_line/test/test_confirm_last_line_balance_check.yml +++ b/account_statement_cancel_line/test/test_confirm_last_line_balance_check.yml @@ -25,7 +25,7 @@ name: line1 statement_id: statement_test3 ref: line1 - date: '2014-01-20' + date: !eval "'%s-01-20' %(datetime.now().year)" amount: 10.0 - Now I confirm the statement line. That should not pass the balance check diff --git a/account_statement_cancel_line/test/test_confirm_last_line_no_balance_check.yml b/account_statement_cancel_line/test/test_confirm_last_line_no_balance_check.yml index fb6cd3ec..6ae7ac61 100644 --- a/account_statement_cancel_line/test/test_confirm_last_line_no_balance_check.yml +++ b/account_statement_cancel_line/test/test_confirm_last_line_no_balance_check.yml @@ -25,7 +25,7 @@ name: line1 statement_id: statement_test4 ref: line1 - date: '2014-01-20' + date: !eval "'%s-01-20' %(datetime.now().year)" amount: 10.0 - Now I confirm the statement line diff --git a/account_statement_transactionid_completion/test/completion_transactionid_test.yml b/account_statement_transactionid_completion/test/completion_transactionid_test.yml index 0d9c0b2f..57066533 100644 --- a/account_statement_transactionid_completion/test/completion_transactionid_test.yml +++ b/account_statement_transactionid_completion/test/completion_transactionid_test.yml @@ -29,7 +29,7 @@ statement_id: statement_transactionid_test1 transaction_id: XXX66Z ref: 6 - date: '2014-01-06' + date: !eval "'%s-01-06' %(datetime.now().year)" amount: 118.4 - I run the auto complete