[MIG] account_reconcile_restrict_partner_mismatch: Migration to 13.0

pull/596/head
ernestotejeda 2019-11-26 11:37:54 -05:00 committed by sbejaoui
parent eb17203388
commit ac3e238736
11 changed files with 161 additions and 122 deletions

View File

@ -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 <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_restrict_partner_mismatch%0Aversion:%2012.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_restrict_partner_mismatch%0Aversion:%2013.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.
@ -59,6 +59,13 @@ Authors
* Camptocamp
Contributors
~~~~~~~~~~~~
* `Tecnativa <https://www.tecnativa.com>`_:
* 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 <https://github.com/OCA/account-reconcile/tree/12.0/account_reconcile_restrict_partner_mismatch>`_ project on GitHub.
This module is part of the `OCA/account-reconcile <https://github.com/OCA/account-reconcile/tree/13.0/account_reconcile_restrict_partner_mismatch>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -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",

View File

@ -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 ""

View File

@ -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)

View File

@ -0,0 +1,3 @@
* `Tecnativa <https://www.tecnativa.com>`_:
* Ernesto Tejeda

View File

@ -1,61 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_account_move_reconciled_report_tree" model="ir.ui.view">
<field name="name">Reconciled items with partner mismatch</field>
<field name="model">account.reconcile.partner.mismatch.report</field>
<field name="arch" type="xml">
<tree string="Reconciled items with partner mismatch" create="false" delete="false" edit="false">
<record id="view_account_move_reconciled_report_tree" model="ir.ui.view">
<field name="name">Reconciled items with partner mismatch</field>
<field name="model">account.reconcile.partner.mismatch.report</field>
<field name="arch" type="xml">
<tree
string="Reconciled items with partner mismatch"
create="false"
delete="false"
edit="false"
>
<!-- links are not clickable in tree view
only after open form view -->
<field name="partial_reconcile_id" />
<field name="full_reconcile_id" />
<field name="debit_move_id" />
<field name="debit_amount" />
<field name="debit_partner_id" />
<field name="credit_move_id" />
<field name="credit_amount" />
<field name="credit_partner_id" />
<field name="account_type_id" />
<field name="account_id" />
</tree>
</field>
</record>
<record id="account_reconcile_partner_mismatch_report_view_form" model="ir.ui.view">
<field name="name">account.reconcile.partner.mismatch.report.form</field>
<field name="model">account.reconcile.partner.mismatch.report</field>
<field name="arch" type="xml">
<form string="Reconciled items with partner mismatch" create="false" delete="false" edit="false">
<sheet>
<field name="partial_reconcile_id" />
<field name="full_reconcile_id" />
<field name="debit_move_id" />
<field name="debit_amount" />
<field name="debit_partner_id" />
<field name="credit_move_id" />
<field name="credit_amount" />
<field name="credit_partner_id" />
<field name="account_type_id" />
<field name="account_id" />
</tree>
</field>
</record>
<record id="account_reconcile_partner_mismatch_report_view_form" model="ir.ui.view">
<field name="name">account.reconcile.partner.mismatch.report.form</field>
<field name="model">account.reconcile.partner.mismatch.report</field>
<field name="arch" type="xml">
<form
string="Reconciled items with partner mismatch"
create="false"
delete="false"
edit="false"
>
<sheet>
<group>
<group>
<group>
<field name="partial_reconcile_id" />
<field name="full_reconcile_id" />
<field name="debit_amount" />
<field name="credit_amount" />
<field name="debit_partner_id" />
<field name="credit_partner_id" />
</group>
<group>
<field name="account_id" />
<field name="account_type_id" />
<field name="debit_move_id" />
<field name="credit_move_id" />
</group>
<field name="partial_reconcile_id" />
<field name="full_reconcile_id" />
<field name="debit_amount" />
<field name="credit_amount" />
<field name="debit_partner_id" />
<field name="credit_partner_id" />
</group>
</sheet>
</form>
</field>
</record>
<record id="action_account_reconcile_partner_mismatch_report" model="ir.actions.act_window">
<field name="name">Reconciled items with partner mismatch</field>
<field name="res_model">account.reconcile.partner.mismatch.report</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="menu_account_reconcile_partner_mismatch_report"
parent="account.menu_finance_entries" sequence="80"
action="action_account_reconcile_partner_mismatch_report"
name="Reconciled items with partner mismatch"/>
<group>
<field name="account_id" />
<field name="account_type_id" />
<field name="debit_move_id" />
<field name="credit_move_id" />
</group>
</group>
</sheet>
</form>
</field>
</record>
<record
id="action_account_reconcile_partner_mismatch_report"
model="ir.actions.act_window"
>
<field name="name">Reconciled items with partner mismatch</field>
<field name="res_model">account.reconcile.partner.mismatch.report</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem
id="menu_account_reconcile_partner_mismatch_report"
parent="account.menu_finance_entries"
sequence="80"
action="action_account_reconcile_partner_mismatch_report"
name="Reconciled items with partner mismatch"
/>
</odoo>

View File

@ -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

View File

@ -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/12.0/account_reconcile_restrict_partner_mismatch"><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-12-0/account-reconcile-12-0-account_reconcile_restrict_partner_mismatch"><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/12.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/13.0/account_reconcile_restrict_partner_mismatch"><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_restrict_partner_mismatch"><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>This module restricts reconciliation between journal items when:</p>
<blockquote>
<ul class="simple">
@ -385,7 +385,8 @@ Reconciled items with partner mismatch.</p>
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
<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="#maintainers" id="id4">Maintainers</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>
</ul>
</li>
</ul>
@ -395,7 +396,7 @@ Reconciled items with partner mismatch.</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_restrict_partner_mismatch%0Aversion:%2012.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_restrict_partner_mismatch%0Aversion:%2013.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">
@ -406,14 +407,23 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Camptocamp</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Ernesto Tejeda</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id4">Maintainers</a></h2>
<h2><a class="toc-backref" href="#id5">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/12.0/account_reconcile_restrict_partner_mismatch">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/13.0/account_reconcile_restrict_partner_mismatch">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

@ -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()