mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[FIX] account_advanced_reconcile: pep8, pylint, eyeballing
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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):
|
||||
"""
|
||||
@@ -117,4 +116,3 @@ class easy_reconcile_advanced_ref(TransientModel):
|
||||
yield ('partner_id', move_line['partner_id'])
|
||||
yield ('ref', (move_line['ref'].lower().strip(),
|
||||
move_line['name'].lower().strip()))
|
||||
|
||||
|
||||
@@ -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 = []
|
||||
@@ -271,4 +270,3 @@ class easy_reconcile_advanced(AbstractModel):
|
||||
partial_reconciled_ids += reconcile_group_ids
|
||||
|
||||
return reconciled_ids, partial_reconciled_ids
|
||||
|
||||
|
||||
@@ -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,7 +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
|
||||
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
<record id="view_easy_reconcile_form" model="ir.ui.view">
|
||||
<field name="name">account.easy.reconcile.form</field>
|
||||
<field name="model">account.easy.reconcile</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="account_easy_reconcile.account_easy_reconcile_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<page name="information" position="inside">
|
||||
<group colspan="2" col="2">
|
||||
<separator colspan="4" string="Advanced. Partner and Ref"/>
|
||||
<label string="Match multiple debit vs multiple credit entries. Allow partial reconcilation.
|
||||
<label string="Match multiple debit vs multiple credit entries. Allow partial reconciliation.
|
||||
The lines should have the partner, the credit entry ref. is matched vs the debit entry ref. or name." colspan="4"/>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
Reference in New Issue
Block a user