[MIG] account_reconcile_model_strict_match_amount: Migration to 14.0

This commit is contained in:
nguyenhk
2021-10-13 17:15:37 +07:00
parent 3f229ede00
commit 37f1df7241
7 changed files with 101 additions and 63 deletions

View File

@@ -14,13 +14,13 @@ Account Reconciliation Model Strict Match Amount
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github
:target: https://github.com/OCA/account-reconcile/tree/13.0/account_reconcile_model_strict_match_amount
:target: https://github.com/OCA/account-reconcile/tree/14.0/account_reconcile_model_strict_match_amount
:alt: OCA/account-reconcile
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-reconcile-13-0/account-reconcile-13-0-account_reconcile_model_strict_match_amount
:target: https://translation.odoo-community.org/projects/account-reconcile-14-0/account-reconcile-14-0-account_reconcile_model_strict_match_amount
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/98/13.0
:target: https://runbot.odoo-community.org/runbot/98/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -41,7 +41,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-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 <https://github.com/OCA/account-reconcile/issues/new?body=module:%20account_reconcile_model_strict_match_amount%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/account-reconcile/issues/new?body=module:%20account_reconcile_model_strict_match_amount%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -57,6 +57,13 @@ Contributors
~~~~~~~~~~~~
* Akim Juillerat <akim.juillerat@camptocamp.com>
* `Trobz <https://trobz.com>`_:
* Nguyen Ho <nguyenhk@trobz.com>
Other credits
~~~~~~~~~~~~~
The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp
Maintainers
~~~~~~~~~~~
@@ -71,6 +78,6 @@ 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.
This module is part of the `OCA/account-reconcile <https://github.com/OCA/account-reconcile/tree/13.0/account_reconcile_model_strict_match_amount>`_ project on GitHub.
This module is part of the `OCA/account-reconcile <https://github.com/OCA/account-reconcile/tree/14.0/account_reconcile_model_strict_match_amount>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -3,7 +3,7 @@
{
"name": "Account Reconciliation Model Strict Match Amount",
"summary": "Restrict reconciliation propositions to matching amount parameter",
"version": "13.0.1.0.0",
"version": "14.0.1.0.0",
"category": "Accounting",
"website": "https://github.com/OCA/account-reconcile",
"author": "Camptocamp, Odoo Community Association (OCA)",

View File

@@ -28,11 +28,12 @@ class AccountReconcileModel(models.Model):
substring(REGEXP_REPLACE(aml.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*') != ''
AND
regexp_split_to_array(substring(REGEXP_REPLACE(aml.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'),'\s+')
&& regexp_split_to_array(substring(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
&& regexp_split_to_array(substring(REGEXP_REPLACE(st_line.payment_ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
)
OR
regexp_split_to_array(substring(REGEXP_REPLACE(move.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'),'\s+')
&& regexp_split_to_array(substring(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
&&
regexp_split_to_array(substring(REGEXP_REPLACE(st_line.payment_ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
OR
(
move.ref IS NOT NULL
@@ -40,7 +41,8 @@ class AccountReconcileModel(models.Model):
substring(REGEXP_REPLACE(move.ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*') != ''
AND
regexp_split_to_array(substring(REGEXP_REPLACE(move.ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'),'\s+')
&& regexp_split_to_array(substring(REGEXP_REPLACE(st_line.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
&&
regexp_split_to_array(substring(REGEXP_REPLACE(st_line.payment_ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
)
, FALSE)
AND
@@ -48,7 +50,7 @@ class AccountReconcileModel(models.Model):
WHEN abs(st_line.amount) < abs(aml.balance) THEN abs(st_line.amount) / abs(aml.balance) * 100
WHEN abs(st_line.amount) > abs(aml.balance) THEN abs(aml.balance) / abs(st_line.amount) * 100
ELSE 100
END >= {match_total_amount_param} AS communication_flag
END >= {match_total_amount_param}
""".format(
match_total_amount_param=self.match_total_amount_param
)
@@ -58,19 +60,20 @@ class AccountReconcileModel(models.Model):
return super()._get_select_payment_reference_flag()
else:
return r"""
-- Determine a matching or not with the statement line communication using the move.invoice_payment_ref.
-- Determine a matching or not with the statement line communication using the move.payment_reference.
COALESCE
(
move.invoice_payment_ref IS NOT NULL
move.payment_reference IS NOT NULL
AND
regexp_replace(move.invoice_payment_ref, '\s+', '', 'g') = regexp_replace(st_line.name, '\s+', '', 'g')
regexp_replace(move.payment_reference, '\s+', '', 'g') =
regexp_replace(st_line.payment_ref, '\s+', '', 'g')
, FALSE)
AND
CASE
WHEN abs(st_line.amount) < abs(aml.balance) THEN abs(st_line.amount) / abs(aml.balance) * 100
WHEN abs(st_line.amount) > abs(aml.balance) THEN abs(aml.balance) / abs(st_line.amount) * 100
ELSE 100
END >= {match_total_amount_param} AS payment_reference_flag
END >= {match_total_amount_param}
""".format(
match_total_amount_param=self.match_total_amount_param
)

View File

@@ -1 +1,3 @@
* Akim Juillerat <akim.juillerat@camptocamp.com>
* `Trobz <https://trobz.com>`_:
* Nguyen Ho <nguyenhk@trobz.com>

View File

@@ -0,0 +1 @@
The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Account Reconciliation Model Strict Match Amount</title>
<style type="text/css">
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-reconcile/tree/13.0/account_reconcile_model_strict_match_amount"><img alt="OCA/account-reconcile" src="https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-reconcile-13-0/account-reconcile-13-0-account_reconcile_model_strict_match_amount"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/98/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-reconcile/tree/14.0/account_reconcile_model_strict_match_amount"><img alt="OCA/account-reconcile" src="https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-reconcile-14-0/account-reconcile-14-0-account_reconcile_model_strict_match_amount"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/98/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows to cancel the bypassing of Amount Matching feature on
Reconciliation models “in case of a statement line communication matching
exactly existing entries”, to ensure only statement lines matching the total
@@ -379,7 +379,8 @@ amount (or according to its percentage) will be reconciled automatically.</p>
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
<li><a class="reference internal" href="#other-credits" id="id5">Other credits</a></li>
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
</ul>
</li>
</ul>
@@ -389,7 +390,7 @@ amount (or according to its percentage) will be reconciled automatically.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-reconcile/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/account-reconcile/issues/new?body=module:%20account_reconcile_model_strict_match_amount%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/account-reconcile/issues/new?body=module:%20account_reconcile_model_strict_match_amount%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@@ -404,16 +405,28 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
<ul class="simple">
<li>Akim Juillerat &lt;<a class="reference external" href="mailto:akim.juillerat&#64;camptocamp.com">akim.juillerat&#64;camptocamp.com</a>&gt;</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://trobz.com">Trobz</a>:</dt>
<dd><ul class="first last">
<li>Nguyen Ho &lt;<a class="reference external" href="mailto:nguyenhk&#64;trobz.com">nguyenhk&#64;trobz.com</a>&gt;</li>
</ul>
</dd>
</dl>
</li>
</ul>
</div>
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#id5">Other credits</a></h2>
<p>The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp</p>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-reconcile/tree/13.0/account_reconcile_model_strict_match_amount">OCA/account-reconcile</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-reconcile/tree/14.0/account_reconcile_model_strict_match_amount">OCA/account-reconcile</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -9,57 +9,69 @@ class TestAccountReconcileModelStrictMatchAmount(TestReconciliationMatchingRules
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.partner_3 = cls.env["res.partner"].create({"name": "partner_3"})
cls.partner_4 = cls.env["res.partner"].create({"name": "partner_4"})
cls.partner_5 = cls.env["res.partner"].create({"name": "partner_5"})
cls.partner_6 = cls.env["res.partner"].create({"name": "partner_6"})
cls.invoice_line_5 = cls._create_invoice_line(150, cls.partner_3, "out_invoice")
cls.invoice_line_5.ref = "ABC001XYZ"
cls.invoice_line_6 = cls._create_invoice_line(300, cls.partner_4, "out_invoice")
cls.invoice_line_6.name = "ABC002XYZ"
cls.invoice_line_7 = cls._create_invoice_line(450, cls.partner_5, "out_invoice")
cls.invoice_line_7.move_id.ref = "ABC003XYZ"
cls.invoice_line_8 = cls._create_invoice_line(600, cls.partner_6, "out_invoice")
cls.invoice_line_8.move_id.invoice_payment_ref = "ABC004XYZ"
cls.bank_st_2 = cls.env["account.bank.statement"].create(
cls.partner_s_3 = cls.env["res.partner"].create({"name": "partner_s_3"})
cls.partner_s_4 = cls.env["res.partner"].create({"name": "partner_s_4"})
cls.partner_s_5 = cls.env["res.partner"].create({"name": "partner_s_5"})
cls.partner_s_6 = cls.env["res.partner"].create({"name": "partner_s_6"})
cls.invoice_line_s_5 = cls._create_invoice_line(
150, cls.partner_s_3, "out_invoice"
)
cls.invoice_line_s_5.ref = "ABC001XYZ"
cls.invoice_line_s_6 = cls._create_invoice_line(
300, cls.partner_s_4, "out_invoice"
)
cls.invoice_line_s_6.name = "ABC002XYZ"
cls.invoice_line_s_7 = cls._create_invoice_line(
450, cls.partner_s_5, "out_invoice"
)
cls.invoice_line_s_7.move_id.ref = "ABC003XYZ"
cls.invoice_line_s_8 = cls._create_invoice_line(
600, cls.partner_s_6, "out_invoice"
)
cls.invoice_line_s_8.move_id.payment_reference = "ABC004XYZ"
cls.bank_st_s = cls.env["account.bank.statement"].create(
{
"name": "test bank journal 2",
"journal_id": cls.company_data["default_journal_bank"].id,
}
)
cls.bank_line_3 = cls.env["account.bank.statement.line"].create(
cls.bank_line_s_3 = cls.env["account.bank.statement.line"].create(
{
"statement_id": cls.bank_st_2.id,
"statement_id": cls.bank_st_s.id,
"name": "ABC001XYZ",
"partner_id": cls.partner_3.id,
"payment_ref": "REF0003",
"partner_id": cls.partner_s_3.id,
"amount": 135,
"sequence": 1,
}
)
cls.bank_line_4 = cls.env["account.bank.statement.line"].create(
cls.bank_line_s_4 = cls.env["account.bank.statement.line"].create(
{
"statement_id": cls.bank_st_2.id,
"statement_id": cls.bank_st_s.id,
"name": "ABC002XYZ",
"partner_id": cls.partner_4.id,
"payment_ref": "REF0004",
"partner_id": cls.partner_s_4.id,
"amount": 270,
"sequence": 2,
}
)
cls.bank_line_5 = cls.env["account.bank.statement.line"].create(
cls.bank_line_s_5 = cls.env["account.bank.statement.line"].create(
{
"statement_id": cls.bank_st_2.id,
"statement_id": cls.bank_st_s.id,
"name": "ABC003XYZ",
"partner_id": cls.partner_5.id,
"payment_ref": "REF0005",
"partner_id": cls.partner_s_5.id,
"amount": 405,
"sequence": 3,
}
)
cls.bank_line_6 = cls.env["account.bank.statement.line"].create(
cls.bank_line_s_6 = cls.env["account.bank.statement.line"].create(
{
"statement_id": cls.bank_st_2.id,
"statement_id": cls.bank_st_s.id,
"name": "ABC004XYZ",
"partner_id": cls.partner_6.id,
"payment_ref": "REF0006",
"partner_id": cls.partner_s_6.id,
"amount": 540,
"sequence": 4,
}
@@ -81,12 +93,12 @@ class TestAccountReconcileModelStrictMatchAmount(TestReconciliationMatchingRules
self._check_statement_matching(
my_rule,
{
self.bank_line_3.id: {"aml_ids": []},
self.bank_line_4.id: {"aml_ids": []},
self.bank_line_5.id: {"aml_ids": []},
self.bank_line_6.id: {"aml_ids": []},
self.bank_line_s_3.id: {"aml_ids": []},
self.bank_line_s_4.id: {"aml_ids": []},
self.bank_line_s_5.id: {"aml_ids": []},
self.bank_line_s_6.id: {"aml_ids": []},
},
statements=self.bank_st_2,
statements=self.bank_st_s,
)
def test_auto_reconcile_strict_match_90(self):
@@ -105,26 +117,26 @@ class TestAccountReconcileModelStrictMatchAmount(TestReconciliationMatchingRules
self._check_statement_matching(
my_rule,
{
self.bank_line_3.id: {
"aml_ids": [self.invoice_line_5.id],
self.bank_line_s_3.id: {
"aml_ids": [self.invoice_line_s_5.id],
"model": my_rule,
"status": "reconciled",
"partner": self.partner_s_3,
},
self.bank_line_4.id: {
"aml_ids": [self.invoice_line_6.id],
self.bank_line_s_4.id: {
"aml_ids": [self.invoice_line_s_6.id],
"model": my_rule,
"status": "reconciled",
"partner": self.partner_s_4,
},
self.bank_line_5.id: {
"aml_ids": [self.invoice_line_7.id],
self.bank_line_s_5.id: {
"aml_ids": [self.invoice_line_s_7.id],
"model": my_rule,
"status": "reconciled",
"partner": self.partner_s_5,
},
self.bank_line_6.id: {
"aml_ids": [self.invoice_line_8.id],
self.bank_line_s_6.id: {
"aml_ids": [self.invoice_line_s_8.id],
"model": my_rule,
"status": "reconciled",
"partner": self.partner_s_6,
},
},
statements=self.bank_st_2,
statements=self.bank_st_s,
)