From 7d323c9a9b1f43dab1cacf1a2a856facede3cb46 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 3 Jan 2013 17:37:46 +0100 Subject: [PATCH] [IMP] account_advanced_reconcile: formatting, cleaning --- account_advanced_reconcile/__openerp__.py | 9 +--- .../advanced_reconciliation.py | 5 +-- .../base_advanced_reconciliation.py | 41 +++++++++---------- account_advanced_reconcile/easy_reconcile.py | 6 +-- 4 files changed, 27 insertions(+), 34 deletions(-) diff --git a/account_advanced_reconcile/__openerp__.py b/account_advanced_reconcile/__openerp__.py index 4212c3bc..795ec459 100644 --- a/account_advanced_reconcile/__openerp__.py +++ b/account_advanced_reconcile/__openerp__.py @@ -30,8 +30,6 @@ 'description': """ Advanced reconciliation methods for the module account_easy_reconcile. -account_easy_reconcile, which is a dependency, is available in the branch: lp:account-extra-addons - In addition to the features implemented in account_easy_reconcile, which are: - reconciliation facilities for big volume of transactions - setup different profiles of reconciliation by account @@ -39,7 +37,7 @@ In addition to the features implemented in account_easy_reconcile, which are: - this module is also a base to create others reconciliation methods which can plug in the profiles - a profile a reconciliation can be run manually or by a cron - - monitoring of reconcilation runs with a few logs + - monitoring of reconcilation runs with an history It implements a basis to created advanced reconciliation methods in a few lines of code. @@ -63,7 +61,6 @@ A method is already implemented in this module, it matches on entries: 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 payments, @@ -75,9 +72,7 @@ many offices. """, 'website': 'http://www.camptocamp.com', - 'init_xml': [], - 'update_xml': ['easy_reconcile_view.xml'], - 'demo_xml': [], + 'data': ['easy_reconcile_view.xml'], 'test': [], 'images': [], 'installable': True, diff --git a/account_advanced_reconcile/advanced_reconciliation.py b/account_advanced_reconcile/advanced_reconciliation.py index 8654284b..92011a1d 100644 --- a/account_advanced_reconcile/advanced_reconciliation.py +++ b/account_advanced_reconcile/advanced_reconciliation.py @@ -19,14 +19,13 @@ # ############################################################################## -from openerp.osv.orm import TransientModel +from openerp.osv import orm -class easy_reconcile_advanced_ref(TransientModel): +class easy_reconcile_advanced_ref(orm.TransientModel): _name = 'easy.reconcile.advanced.ref' _inherit = 'easy.reconcile.advanced' - _auto = True # False when inherited from AbstractModel def _skip_line(self, cr, uid, rec, move_line, context=None): """ diff --git a/account_advanced_reconcile/base_advanced_reconciliation.py b/account_advanced_reconcile/base_advanced_reconciliation.py index f4b74e80..14177f26 100644 --- a/account_advanced_reconcile/base_advanced_reconciliation.py +++ b/account_advanced_reconcile/base_advanced_reconciliation.py @@ -19,21 +19,17 @@ # ############################################################################## -from itertools import groupby, product -from operator import itemgetter -from openerp.osv.orm import Model, AbstractModel, TransientModel -from openerp.osv import fields, osv +from itertools import product +from openerp.osv import orm -class easy_reconcile_advanced(AbstractModel): +class easy_reconcile_advanced(orm.AbstractModel): _name = 'easy.reconcile.advanced' _inherit = 'easy.reconcile.base' def _query_debit(self, cr, uid, rec, context=None): - """Select all move (debit>0) as candidate. Optional choice on invoice - will filter with an inner join on the related moves. - """ + """Select all move (debit>0) as candidate. """ select = self._select(rec) sql_from = self._from(rec) where, params = self._where(rec) @@ -47,9 +43,7 @@ class easy_reconcile_advanced(AbstractModel): return cr.dictfetchall() def _query_credit(self, cr, uid, rec, context=None): - """Select all move (credit>0) as candidate. Optional choice on invoice - will filter with an inner join on the related moves. - """ + """Select all move (credit>0) as candidate. """ select = self._select(rec) sql_from = self._from(rec) where, params = self._where(rec) @@ -176,9 +170,9 @@ class easy_reconcile_advanced(AbstractModel): """ mkey, mvalue = matcher omkey, omvalue = opposite_matcher - assert mkey == omkey, "A matcher %s is compared with a matcher %s, " \ - " the _matchers and _opposite_matchers are probably wrong" % \ - (mkey, omkey) + assert mkey == omkey, ("A matcher %s is compared with a matcher %s, " + " the _matchers and _opposite_matchers are probably wrong" % + (mkey, omkey)) if not isinstance(mvalue, (list, tuple)): mvalue = mvalue, if not isinstance(omvalue, (list, tuple)): @@ -186,7 +180,13 @@ class easy_reconcile_advanced(AbstractModel): return easy_reconcile_advanced._compare_matcher_values(mkey, mvalue, omvalue) def _compare_opposite(self, cr, uid, rec, move_line, opposite_move_line, - matchers, context=None): + matchers, context=None): + """ Iterate over the matchers of the move lines vs opposite move lines + and if they all match, return True. + + 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, context=context) for matcher in matchers: @@ -216,14 +216,15 @@ class easy_reconcile_advanced(AbstractModel): :return: list of matching lines """ matchers = self._matchers(cr, uid, rec, move_line, context=context) - return [op for op in opposite_move_lines if \ - self._compare_opposite(cr, uid, rec, move_line, op, matchers, context=context)] + return [op for op in opposite_move_lines if + self._compare_opposite( + cr, uid, rec, move_line, op, matchers, context=context)] 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, debit_lines, context=context) + cr, uid, rec, credit_lines, debit_lines, context=context) def _skip_line(self, cr, uid, rec, move_line, context=None): """ @@ -234,9 +235,7 @@ class easy_reconcile_advanced(AbstractModel): return False def _rec_auto_lines_advanced(self, cr, uid, rec, credit_lines, debit_lines, context=None): - if context is None: - context = {} - + """ Advanced reconciliation main loop """ reconciled_ids = [] partial_reconciled_ids = [] reconcile_groups = [] diff --git a/account_advanced_reconcile/easy_reconcile.py b/account_advanced_reconcile/easy_reconcile.py index 0a4be152..5506917b 100644 --- a/account_advanced_reconcile/easy_reconcile.py +++ b/account_advanced_reconcile/easy_reconcile.py @@ -19,10 +19,10 @@ # ############################################################################## -from openerp.osv.orm import Model +from openerp.osv import orm -class account_easy_reconcile_method(Model): +class account_easy_reconcile_method(orm.Model): _inherit = 'account.easy.reconcile.method' @@ -31,6 +31,6 @@ class account_easy_reconcile_method(Model): _get_all_rec_method(cr, uid, context=context) methods += [ ('easy.reconcile.advanced.ref', - 'Advanced. Partner and Ref.'), + 'Advanced. Partner and Ref.'), ] return methods