Skip to content

Commit

Permalink
Merge PR #298 into 13.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Dec 27, 2019
2 parents d40f344 + 0b9bf6f commit 4b6d309
Show file tree
Hide file tree
Showing 16 changed files with 923 additions and 0 deletions.
84 changes: 84 additions & 0 deletions account_reconcile_restrict_partner_mismatch/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
===================================
Reconcile restrict partner mismatch
===================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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_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-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/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module restricts reconciliation between journal items when:

- both items have different partners
- one item is with partner and the other without it

This rule applies only for journal items using receivable and payable account type.

As at the moment of installation some journal items could have been reconciled
using different partners, you can detect them in menu Accounting > Adviser >
Reconciled items with partner mismatch.

**Table of contents**

.. contents::
:local:

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:%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.

Credits
=======

Authors
~~~~~~~

* Camptocamp

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:

* Ernesto Tejeda

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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_restrict_partner_mismatch>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions account_reconcile_restrict_partner_mismatch/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import report
16 changes: 16 additions & 0 deletions account_reconcile_restrict_partner_mismatch/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Reconcile restrict partner mismatch",
"summary": "Restrict reconciliation on receivable "
"and payable accounts to the same partner",
"version": "13.0.1.0.0",
"depends": ["account"],
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "http://www.github.com/OCA/account-reconcile",
"category": "Finance",
"license": "AGPL-3",
"data": ["report/account_move_lines_report.xml", "security/ir.model.access.csv"],
"installable": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_reconcile_restrict_partner_mismatch
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report__account_id
msgid "Account"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model,name:account_reconcile_restrict_partner_mismatch.model_account_reconcile_partner_mismatch_report
msgid "Account Reconcile Partner Mismatch Report"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report__account_type_id
msgid "Account type"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report__credit_amount
msgid "Credit amount"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report__credit_move_id
msgid "Credit move"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report__credit_partner_id
msgid "Credit partner"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report__debit_amount
msgid "Debit amount"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report__debit_move_id
msgid "Debit move"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report__debit_partner_id
msgid "Debit partner"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report__display_name
msgid "Display Name"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report__full_reconcile_id
msgid "Full Reconcile"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report__id
msgid "ID"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model,name:account_reconcile_restrict_partner_mismatch.model_account_move_line
msgid "Journal Item"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report____last_update
msgid "Last Modified on"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.model.fields,field_description:account_reconcile_restrict_partner_mismatch.field_account_reconcile_partner_mismatch_report__partial_reconcile_id
msgid "Partial Reconcile"
msgstr ""

#. module: account_reconcile_restrict_partner_mismatch
#: model:ir.actions.act_window,name:account_reconcile_restrict_partner_mismatch.action_account_reconcile_partner_mismatch_report
#: model:ir.ui.menu,name:account_reconcile_restrict_partner_mismatch.menu_account_reconcile_partner_mismatch_report
#: model_terms:ir.ui.view,arch_db:account_reconcile_restrict_partner_mismatch.account_reconcile_partner_mismatch_report_view_form
#: model_terms:ir.ui.view,arch_db:account_reconcile_restrict_partner_mismatch.view_account_move_reconciled_report_tree
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
#, python-format
msgid "The partner has to be the same on all lines for receivable and payable accounts!"
msgstr ""

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_move_line
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import _, models
from odoo.exceptions import UserError
from odoo.tools import config


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

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)

# to be consistent with parent method
if not self:
return True
partners = set()
for line in self:
if line.account_id.internal_type in ("receivable", "payable"):
partners.add(line.partner_id.id)
if len(partners) > 1:
raise UserError(
_(
"The partner has to be the same on all"
" lines for receivable and payable accounts!"
)
)
return super().reconcile(writeoff_acc_id, writeoff_journal_id)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Ernesto Tejeda
10 changes: 10 additions & 0 deletions account_reconcile_restrict_partner_mismatch/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This module restricts reconciliation between journal items when:

- both items have different partners
- one item is with partner and the other without it

This rule applies only for journal items using receivable and payable account type.

As at the moment of installation some journal items could have been reconciled
using different partners, you can detect them in menu Accounting > Adviser >
Reconciled items with partner mismatch.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import report_reconciled_lines
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?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">
<!-- 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>
<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>
</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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).


from odoo import fields, models, tools


class AccountReconcilePartnerMismatchReport(models.Model):
_name = "account.reconcile.partner.mismatch.report"
_description = "Account Reconcile Partner Mismatch Report"
_auto = False

partial_reconcile_id = fields.Many2one(
"account.partial.reconcile", string="Partial Reconcile"
)
full_reconcile_id = fields.Many2one("account.full.reconcile")
account_id = fields.Many2one("account.account", string="Account")
account_type_id = fields.Many2one("account.account.type", string="Account type")
debit_move_id = fields.Many2one("account.move.line", string="Debit move")
debit_amount = fields.Float("Debit amount")
debit_partner_id = fields.Many2one("res.partner", string="Debit partner")
credit_move_id = fields.Many2one("account.move.line", string="Credit move")
credit_amount = fields.Float("Credit amount")
credit_partner_id = fields.Many2one("res.partner", string="Credit partner")

def init(self):
"""Select lines which violate defined rules"""
tools.drop_view_if_exists(self.env.cr, self._table)
self._cr.execute(
"""CREATE OR REPLACE VIEW %s AS (
SELECT pr.id id
, pr.id partial_reconcile_id
, pr.full_reconcile_id
, pr.debit_move_id
, daml.debit debit_amount
, aat.id account_type_id
, daml.partner_id debit_partner_id
, daml.account_id account_id
, pr.credit_move_id
, caml.credit credit_amount
, caml.partner_id credit_partner_id
FROM account_partial_reconcile pr
LEFT JOIN account_move_line daml
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 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
AND caml.partner_id IS NOT NULL)
OR (caml.partner_id IS NULL
AND daml.partner_id IS NOT NULL))
)
"""
% self._table
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_account_reconcile_partner_mismatch_report,access_account_reconcile_partner_mismatch_report,model_account_reconcile_partner_mismatch_report,account.group_account_user,1,0,0,0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4b6d309

Please sign in to comment.