From 954945b5e1efdbe9e781c4e8a377636b30968f77 Mon Sep 17 00:00:00 2001
From: ernestotejeda
Date: Tue, 26 Nov 2019 11:37:54 -0500
Subject: [PATCH] [MIG] account_reconcile_restrict_partner_mismatch: Migration
to 13.0
---
.../README.rst | 17 ++-
.../__init__.py | 0
.../__manifest__.py | 2 +-
...nt_reconcile_restrict_partner_mismatch.pot | 13 +-
.../models/__init__.py | 0
.../models/account_move_line.py | 3 +-
.../readme/CONTRIBUTORS.rst | 3 +
.../report/account_move_lines_report.xml | 123 ++++++++++--------
.../report/report_reconciled_lines.py | 7 +-
.../static/description/index.html | 20 ++-
.../tests/test_reconciliation.py | 95 +++++++-------
11 files changed, 161 insertions(+), 122 deletions(-)
mode change 100755 => 100644 account_reconcile_restrict_partner_mismatch/__init__.py
mode change 100755 => 100644 account_reconcile_restrict_partner_mismatch/models/__init__.py
create mode 100644 account_reconcile_restrict_partner_mismatch/readme/CONTRIBUTORS.rst
diff --git a/account_reconcile_restrict_partner_mismatch/README.rst b/account_reconcile_restrict_partner_mismatch/README.rst
index 8abb6497..145d112a 100644
--- a/account_reconcile_restrict_partner_mismatch/README.rst
+++ b/account_reconcile_restrict_partner_mismatch/README.rst
@@ -14,13 +14,13 @@ Reconcile restrict partner mismatch
: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/12.0/account_reconcile_restrict_partner_mismatch
+ :target: https://github.com/OCA/account-reconcile/tree/13.0/account_reconcile_restrict_partner_mismatch
: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-12-0/account-reconcile-12-0-account_reconcile_restrict_partner_mismatch
+ :target: https://translation.odoo-community.org/projects/account-reconcile-13-0/account-reconcile-13-0-account_reconcile_restrict_partner_mismatch
: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/12.0
+ :target: https://runbot.odoo-community.org/runbot/98/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -47,7 +47,7 @@ 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 `_.
+`feedback `_.
Do not contact contributors directly about support or help with technical issues.
@@ -59,6 +59,13 @@ Authors
* Camptocamp
+Contributors
+~~~~~~~~~~~~
+
+* `Tecnativa `_:
+
+ * Ernesto Tejeda
+
Maintainers
~~~~~~~~~~~
@@ -72,6 +79,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 `_ project on GitHub.
+This module is part of the `OCA/account-reconcile `_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/account_reconcile_restrict_partner_mismatch/__init__.py b/account_reconcile_restrict_partner_mismatch/__init__.py
old mode 100755
new mode 100644
diff --git a/account_reconcile_restrict_partner_mismatch/__manifest__.py b/account_reconcile_restrict_partner_mismatch/__manifest__.py
index 92fb8619..694d288e 100644
--- a/account_reconcile_restrict_partner_mismatch/__manifest__.py
+++ b/account_reconcile_restrict_partner_mismatch/__manifest__.py
@@ -5,7 +5,7 @@
"name": "Reconcile restrict partner mismatch",
"summary": "Restrict reconciliation on receivable "
"and payable accounts to the same partner",
- "version": "12.0.1.0.0",
+ "version": "13.0.1.0.0",
"depends": ["account"],
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "http://www.github.com/OCA/account-reconcile",
diff --git a/account_reconcile_restrict_partner_mismatch/i18n/account_reconcile_restrict_partner_mismatch.pot b/account_reconcile_restrict_partner_mismatch/i18n/account_reconcile_restrict_partner_mismatch.pot
index 89588632..b3d9f2af 100644
--- a/account_reconcile_restrict_partner_mismatch/i18n/account_reconcile_restrict_partner_mismatch.pot
+++ b/account_reconcile_restrict_partner_mismatch/i18n/account_reconcile_restrict_partner_mismatch.pot
@@ -1,12 +1,12 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
-# * account_reconcile_restrict_partner_mismatch
+# * account_reconcile_restrict_partner_mismatch
#
msgid ""
msgstr ""
-"Project-Id-Version: Odoo Server 12.0\n"
+"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
-"Last-Translator: <>\n"
+"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -97,8 +97,9 @@ msgid "Reconciled items with partner mismatch"
msgstr ""
#. module: account_reconcile_restrict_partner_mismatch
-#: code:addons/account_reconcile_restrict_partner_mismatch/models/account_move_line.py:26
+#: code:addons/account_reconcile_restrict_partner_mismatch/models/account_move_line.py:0
#, python-format
-msgid "The partner has to be the same on all lines for receivable and payable accounts!"
+msgid ""
+"The partner has to be the same on all lines for receivable and payable "
+"accounts!"
msgstr ""
-
diff --git a/account_reconcile_restrict_partner_mismatch/models/__init__.py b/account_reconcile_restrict_partner_mismatch/models/__init__.py
old mode 100755
new mode 100644
diff --git a/account_reconcile_restrict_partner_mismatch/models/account_move_line.py b/account_reconcile_restrict_partner_mismatch/models/account_move_line.py
index 9cd800fe..adafe6e4 100644
--- a/account_reconcile_restrict_partner_mismatch/models/account_move_line.py
+++ b/account_reconcile_restrict_partner_mismatch/models/account_move_line.py
@@ -1,7 +1,7 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from odoo import _, api, models
+from odoo import _, models
from odoo.exceptions import UserError
from odoo.tools import config
@@ -9,7 +9,6 @@ from odoo.tools import config
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
- @api.multi
def reconcile(self, writeoff_acc_id=False, writeoff_journal_id=False):
if config["test_enable"] and not self.env.context.get("test_partner_mismatch"):
return super().reconcile(writeoff_acc_id, writeoff_journal_id)
diff --git a/account_reconcile_restrict_partner_mismatch/readme/CONTRIBUTORS.rst b/account_reconcile_restrict_partner_mismatch/readme/CONTRIBUTORS.rst
new file mode 100644
index 00000000..0b6bee44
--- /dev/null
+++ b/account_reconcile_restrict_partner_mismatch/readme/CONTRIBUTORS.rst
@@ -0,0 +1,3 @@
+* `Tecnativa `_:
+
+ * Ernesto Tejeda
diff --git a/account_reconcile_restrict_partner_mismatch/report/account_move_lines_report.xml b/account_reconcile_restrict_partner_mismatch/report/account_move_lines_report.xml
index 91aef714..ee82bcc8 100644
--- a/account_reconcile_restrict_partner_mismatch/report/account_move_lines_report.xml
+++ b/account_reconcile_restrict_partner_mismatch/report/account_move_lines_report.xml
@@ -1,61 +1,74 @@
-
+
-
- Reconciled items with partner mismatch
- account.reconcile.partner.mismatch.report
-
-
+
+ Reconciled items with partner mismatch
+ account.reconcile.partner.mismatch.report
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- account.reconcile.partner.mismatch.report.form
- account.reconcile.partner.mismatch.report
-
-
+
+
+
+ account.reconcile.partner.mismatch.report.form
+ account.reconcile.partner.mismatch.report
+
+
-
-
-
-
- Reconciled items with partner mismatch
- account.reconcile.partner.mismatch.report
- tree,form
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+ Reconciled items with partner mismatch
+ account.reconcile.partner.mismatch.report
+ tree,form
+
+
diff --git a/account_reconcile_restrict_partner_mismatch/report/report_reconciled_lines.py b/account_reconcile_restrict_partner_mismatch/report/report_reconciled_lines.py
index 06e0e86b..a1ceeab4 100644
--- a/account_reconcile_restrict_partner_mismatch/report/report_reconciled_lines.py
+++ b/account_reconcile_restrict_partner_mismatch/report/report_reconciled_lines.py
@@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-from odoo import api, fields, models, tools
+from odoo import fields, models, tools
class AccountReconcilePartnerMismatchReport(models.Model):
@@ -23,7 +23,6 @@ class AccountReconcilePartnerMismatchReport(models.Model):
credit_amount = fields.Float("Credit amount")
credit_partner_id = fields.Many2one("res.partner", string="Credit partner")
- @api.model_cr
def init(self):
"""Select lines which violate defined rules"""
tools.drop_view_if_exists(self.env.cr, self._table)
@@ -45,8 +44,10 @@ class AccountReconcilePartnerMismatchReport(models.Model):
ON daml.id = pr.debit_move_id
LEFT JOIN account_move_line caml
ON caml.id = pr.credit_move_id
+ LEFT JOIN account_account aa
+ ON daml.account_id = aa.id
LEFT JOIN account_account_type aat
- ON daml.user_type_id = aat.id
+ ON aa.user_type_id = aat.id
WHERE aat.type in ('receivable', 'payable')
AND (daml.partner_id <> caml.partner_id
OR (daml.partner_id IS NULL
diff --git a/account_reconcile_restrict_partner_mismatch/static/description/index.html b/account_reconcile_restrict_partner_mismatch/static/description/index.html
index aa278bcf..3ddd6fd3 100644
--- a/account_reconcile_restrict_partner_mismatch/static/description/index.html
+++ b/account_reconcile_restrict_partner_mismatch/static/description/index.html
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
-

+

This module restricts reconciliation between journal items when:
@@ -385,7 +385,8 @@ Reconciled items with partner mismatch.
Bug Tracker
Credits
@@ -395,7 +396,7 @@ Reconciled items with partner mismatch.
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.
+feedback.
Do not contact contributors directly about support or help with technical issues.
@@ -406,14 +407,23 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
Camptocamp
+
-
+
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.
-
This module is part of the OCA/account-reconcile project on GitHub.
+
This module is part of the OCA/account-reconcile project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
diff --git a/account_reconcile_restrict_partner_mismatch/tests/test_reconciliation.py b/account_reconcile_restrict_partner_mismatch/tests/test_reconciliation.py
index 5711a687..6f1e61f1 100644
--- a/account_reconcile_restrict_partner_mismatch/tests/test_reconciliation.py
+++ b/account_reconcile_restrict_partner_mismatch/tests/test_reconciliation.py
@@ -2,67 +2,66 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.exceptions import UserError
-
-from odoo.addons.account.tests.account_test_classes import AccountingTestCase
+from odoo.tests.common import SavepointCase
-class TestReconciliation(AccountingTestCase):
- def setUp(self):
- super().setUp()
- self.env = self.env(
+class TestReconciliation(SavepointCase):
+ @classmethod
+ def setUpClass(cls):
+ super().setUpClass()
+ cls.env = cls.env(
context=dict(
- self.env.context, tracking_disable=True, test_partner_mismatch=True
+ cls.env.context, tracking_disable=True, test_partner_mismatch=True
)
)
-
- self.partner = self.env.ref("base.res_partner_2")
- self.partner_id = self.partner.id
- rec_type = self.env["account.account"].search(
- [
- (
- "user_type_id",
- "=",
- self.env.ref("account.data_account_type_receivable").id,
- )
- ],
- limit=1,
+ cls.partner = cls.env.ref("base.res_partner_2")
+ cls.partner_id = cls.partner.id
+ cls.account_rcv = cls.env["account.account"].create(
+ {
+ "code": "RA1000",
+ "name": "Test Receivable Account",
+ "user_type_id": cls.env.ref("account.data_account_type_receivable").id,
+ "reconcile": True,
+ }
)
- pay_type = self.env["account.account"].search(
- [
- (
- "user_type_id",
- "=",
- self.env.ref("account.data_account_type_payable").id,
- )
- ],
- limit=1,
+ cls.account_rsa = cls.env["account.account"].create(
+ {
+ "code": "PA1000",
+ "name": "Test Payable Account",
+ "user_type_id": cls.env.ref("account.data_account_type_payable").id,
+ "reconcile": True,
+ }
)
- self.account_rcv = self.partner.property_account_receivable_id or rec_type
- self.account_rsa = self.partner.property_account_payable_id or pay_type
-
- self.bank_journal = self.env["account.journal"].create(
+ cls.bank_journal = cls.env["account.journal"].create(
{"name": "Bank", "type": "bank", "code": "BNK67"}
)
- self.aml = self.init_moves()
+ cls.aml = cls.init_moves()
- def create_move(self, name, amount):
+ @classmethod
+ def create_move(cls, name, amount):
debit_line_vals = {
"name": name,
"debit": amount > 0 and amount or 0.0,
"credit": amount < 0 and -amount or 0.0,
- "account_id": self.account_rcv.id,
+ "account_id": cls.account_rcv.id,
}
credit_line_vals = debit_line_vals.copy()
credit_line_vals["debit"] = debit_line_vals["credit"]
credit_line_vals["credit"] = debit_line_vals["debit"]
- credit_line_vals["account_id"] = self.account_rsa.id
+ credit_line_vals["account_id"] = cls.account_rsa.id
vals = {
- "journal_id": self.bank_journal.id,
+ "journal_id": cls.bank_journal.id,
"line_ids": [(0, 0, debit_line_vals), (0, 0, credit_line_vals)],
}
- return self.env["account.move"].create(vals).id
+ return (
+ cls.env["account.move"]
+ .with_context(default_journal_id=cls.bank_journal.id)
+ .create(vals)
+ .id
+ )
- def init_moves(self):
+ @classmethod
+ def init_moves(cls):
move_list_vals = [
("1", -1.83),
("2", 728.35),
@@ -73,9 +72,9 @@ class TestReconciliation(AccountingTestCase):
]
move_ids = []
for name, amount in move_list_vals:
- move_ids.append(self.create_move(name, amount))
- aml_recs = self.env["account.move.line"].search(
- [("move_id", "in", move_ids), ("account_id", "=", self.account_rcv.id)]
+ move_ids.append(cls.create_move(name, amount))
+ aml_recs = cls.env["account.move.line"].search(
+ [("move_id", "in", move_ids), ("account_id", "=", cls.account_rcv.id)]
)
return aml_recs
@@ -97,10 +96,16 @@ class TestReconciliation(AccountingTestCase):
with self.assertRaises(UserError):
self.aml.reconcile()
# reconciliation forbiden only for certain types of accounts
- account = self.env["account.account"].search(
- [("user_type_id.type", "=", "other")], limit=1
+ account = self.env["account.account"].create(
+ {
+ "code": "CAA1000",
+ "name": "Test Current Assets Account",
+ "user_type_id": self.env.ref(
+ "account.data_account_type_current_assets"
+ ).id,
+ "reconcile": True,
+ }
)
- account.reconcile = True
self.aml[0].account_id = account.id
with self.assertRaises(UserError):
self.aml.reconcile()