mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[IMP] account_reconcile_model_strict_match_amount: black, isort, prettier
This commit is contained in:
@@ -10,10 +10,6 @@
|
|||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"application": False,
|
"application": False,
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"depends": [
|
"depends": ["account",],
|
||||||
"account",
|
"data": ["views/account_reconcile_model.xml",],
|
||||||
],
|
|
||||||
"data": [
|
|
||||||
"views/account_reconcile_model.xml",
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ from odoo import api, fields, models
|
|||||||
|
|
||||||
class AccountReconcileModel(models.Model):
|
class AccountReconcileModel(models.Model):
|
||||||
|
|
||||||
_inherit = 'account.reconcile.model'
|
_inherit = "account.reconcile.model"
|
||||||
|
|
||||||
strict_match_total_amount = fields.Boolean(
|
strict_match_total_amount = fields.Boolean(
|
||||||
string="Strict Amount Matching",
|
string="Strict Amount Matching",
|
||||||
help="Avoid bypassing the Amount Matching parameter in case of a "
|
help="Avoid bypassing the Amount Matching parameter in case of a "
|
||||||
"statement line communication matching exactly existing entries."
|
"statement line communication matching exactly existing entries.",
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@@ -19,7 +19,7 @@ class AccountReconcileModel(models.Model):
|
|||||||
return super()._get_select_communication_flag()
|
return super()._get_select_communication_flag()
|
||||||
else:
|
else:
|
||||||
regexp = r"'[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+'"
|
regexp = r"'[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+'"
|
||||||
return r'''
|
return r"""
|
||||||
-- Determine a matching or not with the statement line communication using the move.name or move.ref.
|
-- Determine a matching or not with the statement line communication using the move.name or move.ref.
|
||||||
-- only digits are considered and reference are split by any space characters
|
-- only digits are considered and reference are split by any space characters
|
||||||
COALESCE(
|
COALESCE(
|
||||||
@@ -39,4 +39,6 @@ class AccountReconcileModel(models.Model):
|
|||||||
WHEN abs(st_line.amount) > abs(aml.balance) THEN abs(aml.balance) / abs(st_line.amount) * 100
|
WHEN abs(st_line.amount) > abs(aml.balance) THEN abs(aml.balance) / abs(st_line.amount) * 100
|
||||||
ELSE 100
|
ELSE 100
|
||||||
END >= {match_total_amount_param} AS communication_flag
|
END >= {match_total_amount_param} AS communication_flag
|
||||||
'''.format(regexp=regexp, match_total_amount_param=self.match_total_amount_param)
|
""".format(
|
||||||
|
regexp=regexp, match_total_amount_param=self.match_total_amount_param
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,80 +1,101 @@
|
|||||||
# Copyright 2020 Camptocamp SA
|
# Copyright 2020 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||||
from odoo.addons.account.tests.test_reconciliation_matching_rules import TestReconciliationMatchingRules
|
from odoo.addons.account.tests.test_reconciliation_matching_rules import (
|
||||||
|
TestReconciliationMatchingRules,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestAccountReconcileModelStrictMatchAmount(TestReconciliationMatchingRules):
|
class TestAccountReconcileModelStrictMatchAmount(TestReconciliationMatchingRules):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.partner_3 = self.env['res.partner'].create({'name': 'partner_3'})
|
self.partner_3 = self.env["res.partner"].create({"name": "partner_3"})
|
||||||
self.partner_4 = self.env['res.partner'].create({'name': 'partner_4'})
|
self.partner_4 = self.env["res.partner"].create({"name": "partner_4"})
|
||||||
self.invoice_line_5 = self._create_invoice_line(
|
self.invoice_line_5 = self._create_invoice_line(
|
||||||
150, self.partner_3, 'out_invoice'
|
150, self.partner_3, "out_invoice"
|
||||||
)
|
)
|
||||||
self.invoice_line_5.ref = 'ABC001XYZ'
|
self.invoice_line_5.ref = "ABC001XYZ"
|
||||||
self.invoice_line_6 = self._create_invoice_line(
|
self.invoice_line_6 = self._create_invoice_line(
|
||||||
300, self.partner_4, 'out_invoice'
|
300, self.partner_4, "out_invoice"
|
||||||
)
|
)
|
||||||
self.invoice_line_6.name = 'ABC002XYZ'
|
self.invoice_line_6.name = "ABC002XYZ"
|
||||||
|
|
||||||
self.bank_st_2 = self.env['account.bank.statement'].create({
|
self.bank_st_2 = self.env["account.bank.statement"].create(
|
||||||
'name': 'test bank journal 2', 'journal_id': self.bank_journal.id,
|
{"name": "test bank journal 2", "journal_id": self.bank_journal.id,}
|
||||||
})
|
)
|
||||||
|
|
||||||
self.bank_line_3 = self.env['account.bank.statement.line'].create({
|
self.bank_line_3 = self.env["account.bank.statement.line"].create(
|
||||||
'statement_id': self.bank_st_2.id,
|
{
|
||||||
'name': 'ABC001XYZ',
|
"statement_id": self.bank_st_2.id,
|
||||||
'partner_id': self.partner_3.id,
|
"name": "ABC001XYZ",
|
||||||
'amount': 70,
|
"partner_id": self.partner_3.id,
|
||||||
'sequence': 1,
|
"amount": 70,
|
||||||
})
|
"sequence": 1,
|
||||||
self.bank_line_4 = self.env['account.bank.statement.line'].create({
|
}
|
||||||
'statement_id': self.bank_st_2.id,
|
)
|
||||||
'name': 'ABC002XYZ',
|
self.bank_line_4 = self.env["account.bank.statement.line"].create(
|
||||||
'partner_id': self.partner_4.id,
|
{
|
||||||
'amount': 270,
|
"statement_id": self.bank_st_2.id,
|
||||||
'sequence': 1,
|
"name": "ABC002XYZ",
|
||||||
})
|
"partner_id": self.partner_4.id,
|
||||||
|
"amount": 270,
|
||||||
|
"sequence": 1,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def test_auto_reconcile_strict_match_100(self):
|
def test_auto_reconcile_strict_match_100(self):
|
||||||
my_rule = self.env['account.reconcile.model'].create({
|
my_rule = self.env["account.reconcile.model"].create(
|
||||||
'name': 'Strict Invoice matching amount 100%',
|
{
|
||||||
'rule_type': 'invoice_matching',
|
"name": "Strict Invoice matching amount 100%",
|
||||||
'auto_reconcile': True,
|
"rule_type": "invoice_matching",
|
||||||
'match_nature': 'both',
|
"auto_reconcile": True,
|
||||||
'match_partner': True,
|
"match_nature": "both",
|
||||||
'match_same_currency': True,
|
"match_partner": True,
|
||||||
'match_total_amount': True,
|
"match_same_currency": True,
|
||||||
'match_total_amount_param': 100.0,
|
"match_total_amount": True,
|
||||||
'strict_match_total_amount': True,
|
"match_total_amount_param": 100.0,
|
||||||
# 'match_partner_ids': [
|
"strict_match_total_amount": True,
|
||||||
# (6, 0, [self.partner_3.id, self.partner_4.id])
|
# 'match_partner_ids': [
|
||||||
# ],
|
# (6, 0, [self.partner_3.id, self.partner_4.id])
|
||||||
})
|
# ],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
self._check_statement_matching(my_rule, {
|
self._check_statement_matching(
|
||||||
self.bank_line_3.id: {'aml_ids': []},
|
my_rule,
|
||||||
self.bank_line_4.id: {'aml_ids': []},
|
{
|
||||||
}, statements=self.bank_st_2)
|
self.bank_line_3.id: {"aml_ids": []},
|
||||||
|
self.bank_line_4.id: {"aml_ids": []},
|
||||||
|
},
|
||||||
|
statements=self.bank_st_2,
|
||||||
|
)
|
||||||
|
|
||||||
def test_auto_reconcile_strict_match_80(self):
|
def test_auto_reconcile_strict_match_80(self):
|
||||||
my_rule = self.env['account.reconcile.model'].create({
|
my_rule = self.env["account.reconcile.model"].create(
|
||||||
'name': 'Strict Invoice matching amount 80%',
|
{
|
||||||
'rule_type': 'invoice_matching',
|
"name": "Strict Invoice matching amount 80%",
|
||||||
'auto_reconcile': True,
|
"rule_type": "invoice_matching",
|
||||||
'match_nature': 'both',
|
"auto_reconcile": True,
|
||||||
'match_partner': True,
|
"match_nature": "both",
|
||||||
'match_same_currency': True,
|
"match_partner": True,
|
||||||
'match_total_amount': True,
|
"match_same_currency": True,
|
||||||
'match_total_amount_param': 80.0,
|
"match_total_amount": True,
|
||||||
'strict_match_total_amount': True,
|
"match_total_amount_param": 80.0,
|
||||||
# 'match_partner_ids': [
|
"strict_match_total_amount": True,
|
||||||
# (6, 0, [self.partner_3.id, self.partner_4.id])
|
# 'match_partner_ids': [
|
||||||
# ],
|
# (6, 0, [self.partner_3.id, self.partner_4.id])
|
||||||
})
|
# ],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
self._check_statement_matching(my_rule, {
|
self._check_statement_matching(
|
||||||
self.bank_line_3.id: {'aml_ids': []},
|
my_rule,
|
||||||
self.bank_line_4.id: {'aml_ids': [self.invoice_line_6.id], 'model': my_rule, 'status': 'reconciled'},
|
{
|
||||||
}, statements=self.bank_st_2)
|
self.bank_line_3.id: {"aml_ids": []},
|
||||||
|
self.bank_line_4.id: {
|
||||||
|
"aml_ids": [self.invoice_line_6.id],
|
||||||
|
"model": my_rule,
|
||||||
|
"status": "reconciled",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
statements=self.bank_st_2,
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="view_account_reconcile_model_form" model="ir.ui.view">
|
<record id="view_account_reconcile_model_form" model="ir.ui.view">
|
||||||
<field name="name">account.reconcile.model.form</field>
|
<field name="name">account.reconcile.model.form</field>
|
||||||
@@ -6,10 +6,18 @@
|
|||||||
<field name="inherit_id" ref="account.view_account_reconcile_model_form" />
|
<field name="inherit_id" ref="account.view_account_reconcile_model_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//div[field[@name='match_total_amount']]" position="after">
|
<xpath expr="//div[field[@name='match_total_amount']]" position="after">
|
||||||
<field name="strict_match_total_amount" attrs="{'invisible': ['|', ('rule_type', '!=', 'invoice_matching'), ('match_total_amount', '=', False)]}"/>
|
<field
|
||||||
|
name="strict_match_total_amount"
|
||||||
|
attrs="{'invisible': ['|', ('rule_type', '!=', 'invoice_matching'), ('match_total_amount', '=', False)]}"
|
||||||
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//div[field[@name='match_total_amount']]/div[@class='text-muted']" position="attributes">
|
<xpath
|
||||||
<attribute name="attrs">{'invisible': ['|', '|', ('rule_type', '!=', 'invoice_matching'), ('match_total_amount', '=', False), ('strict_match_total_amount', '=', True)]}</attribute>
|
expr="//div[field[@name='match_total_amount']]/div[@class='text-muted']"
|
||||||
|
position="attributes"
|
||||||
|
>
|
||||||
|
<attribute
|
||||||
|
name="attrs"
|
||||||
|
>{'invisible': ['|', '|', ('rule_type', '!=', 'invoice_matching'), ('match_total_amount', '=', False), ('strict_match_total_amount', '=', True)]}</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user