diff --git a/account_mass_reconcile_ref_deep_search/README.rst b/account_mass_reconcile_ref_deep_search/README.rst new file mode 100644 index 00000000..f89c953d --- /dev/null +++ b/account_mass_reconcile_ref_deep_search/README.rst @@ -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 +`_. 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 `_. + +Contributors +------------ + +* Matthieu Dietrich + +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. diff --git a/account_mass_reconcile_ref_deep_search/__init__.py b/account_mass_reconcile_ref_deep_search/__init__.py new file mode 100644 index 00000000..e1b56ad6 --- /dev/null +++ b/account_mass_reconcile_ref_deep_search/__init__.py @@ -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 diff --git a/account_mass_reconcile_ref_deep_search/__openerp__.py b/account_mass_reconcile_ref_deep_search/__openerp__.py new file mode 100644 index 00000000..c233bfa4 --- /dev/null +++ b/account_mass_reconcile_ref_deep_search/__openerp__.py @@ -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': [] +} diff --git a/account_mass_reconcile_ref_deep_search/models/__init__.py b/account_mass_reconcile_ref_deep_search/models/__init__.py new file mode 100644 index 00000000..b07ffa54 --- /dev/null +++ b/account_mass_reconcile_ref_deep_search/models/__init__.py @@ -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 diff --git a/account_mass_reconcile_ref_deep_search/models/advanced_reconciliation.py b/account_mass_reconcile_ref_deep_search/models/advanced_reconciliation.py new file mode 100644 index 00000000..d47b795b --- /dev/null +++ b/account_mass_reconcile_ref_deep_search/models/advanced_reconciliation.py @@ -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) diff --git a/account_mass_reconcile_ref_deep_search/models/mass_reconcile.py b/account_mass_reconcile_ref_deep_search/models/mass_reconcile.py new file mode 100644 index 00000000..ac13ec58 --- /dev/null +++ b/account_mass_reconcile_ref_deep_search/models/mass_reconcile.py @@ -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 diff --git a/account_mass_reconcile_ref_deep_search/views/mass_reconcile_view.xml b/account_mass_reconcile_ref_deep_search/views/mass_reconcile_view.xml new file mode 100644 index 00000000..41c30174 --- /dev/null +++ b/account_mass_reconcile_ref_deep_search/views/mass_reconcile_view.xml @@ -0,0 +1,17 @@ + + + + account.mass.reconcile.form + account.mass.reconcile + + + + + + + + + +