Rename and migrate to 9.0 "account_advanced_reconcile_ref_deep_search"

This commit is contained in:
Matthieu Dietrich
2015-08-06 14:24:00 +02:00
committed by Diep Huu Hoang
parent 6f643c7b58
commit bcedcf3d66
7 changed files with 173 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
==============================
Mass Reconcile Ref Deep Search
==============================
This module extends the functionality of account_mass_reconcile
and allows to search the credit entry ref inside the debit entry ref,
instead of an exact match.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/98/9.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/bank-statement-reconcile/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Matthieu Dietrich <matthieu.dietrich@camptocamp.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

View File

@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2015-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from . import models

View File

@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# © 2015-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
{
'name': 'Mass Reconcile Ref Deep Search',
'version': '9.0.1.0.0',
'author': "Camptocamp,Odoo Community Association (OCA)",
'category': 'Finance',
'website': 'http://www.camptocamp.com',
'depends': ['account_mass_reconcile'],
'data': [
'views/mass_reconcile_view.xml'
],
'demo': [],
'test': [],
'auto_install': False,
'installable': True,
'images': []
}

View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from . import mass_reconcile
from . import advanced_reconciliation

View File

@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-
# © 2015-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from openerp import _, models
from itertools import product
class MassReconciledAdvancedRefDeepSearch(models.TransientModel):
_name = 'mass.reconcile.advanced.ref.deep.search'
_inherit = 'mass.reconcile.advanced.ref'
@staticmethod
def _compare_values(key, value, opposite_value):
"""Can be inherited to modify the equality condition
specifically according to the matcher key (maybe using
a like operator instead of equality on 'ref' as instance)
"""
# consider that empty vals are not valid matchers
# it can still be inherited for some special cases
# where it would be allowed
if not (value and opposite_value):
return False
if value == opposite_value or \
(key == 'ref' and value in opposite_value):
return True
return False
@staticmethod
def _compare_matcher_values(key, values, opposite_values):
""" Compare every values from a matcher vs an opposite matcher
and return True if it matches
"""
for value, ovalue in product(values, opposite_values):
# we do not need to compare all values, if one matches
# we are done
if MassReconciledAdvancedRefDeepSearch._compare_values(
key, value, ovalue):
return True
return False
@staticmethod
def _compare_matchers(matcher, opposite_matcher):
"""
Prepare and check the matchers to compare
"""
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))
if not isinstance(mvalue, (list, tuple)):
mvalue = mvalue,
if not isinstance(omvalue, (list, tuple)):
omvalue = omvalue,
return MassReconciledAdvancedRefDeepSearch.\
_compare_matcher_values(mkey, mvalue, omvalue)

View File

@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# © 2015-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from openerp import api, models
class AccountMassReconcileMethod(models.Model):
_inherit = 'account.mass.reconcile.method'
@api.model
def _get_all_rec_method(self):
_super = super(AccountMassReconcileMethod, self)
methods = _super.get_all_rec_method()
methods += [
('mass.reconcile.advanced.ref.deep.search',
'Advanced. Partner and Ref. Deep Search'),
]
return methods

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_mass_reconcile_form" model="ir.ui.view">
<field name="name">account.mass.reconcile.form</field>
<field name="model">account.mass.reconcile</field>
<field name="inherit_id" ref="account_mass_reconcile.account_mass_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 Deep Search"/>
<label string="Match multiple debit vs multiple credit entries. Allow partial reconciliation.
The lines should have the partner, the credit entry ref is searched inside the debit entry ref." colspan="4"/>
</group>
</page>
</field>
</record>
</odoo>