Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions account_move_change_financial_account/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
=====================================
Account Move Change Financial Account
=====================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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-escodoo%2Faccount--addons-lightgray.png?logo=github
:target: https://github.com/escodoo/account-addons/tree/14.0/account_move_change_financial_account
:alt: escodoo/account-addons

|badge1| |badge2| |badge3|

This module allows for the automatic changing of financial accounts in accounting move lines (account.move.line) based on predefined rules. This simplifies the application of specific accounting policies without the need for manually adjusting each accounting move.

Key Features:

1. Define financial account substitution rules through the account_account_financial_rule class.
2. Apply the substitution rules during the creation of new accounting moves (account.move).
3. Supports rules based on specific criteria, such as the partner involved in the transaction.

With the account_move_change_financial_account module, users can easily set up and apply custom financial rules, streamlining the accounting process and ensuring compliance with the company's accounting policies.

**Table of contents**

.. contents::
:local:

Usage
=====

- Install the account_move_change_financial_account module.
- Navigate to the financial rules menu (Accounting > Configuration > Financial Rules) and create a new rule by defining the domain condition and the new financial account to be applied.
- When a new accounting move is created and meets the financial rule's domain condition, the financial account of the applicable lines will be automatically changed according to the rule.
- Review the accounting moves to ensure that the financial rules have been correctly applied.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/escodoo/account-addons/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/escodoo/account-addons/issues/new?body=module:%20account_move_change_financial_account%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.

Credits
=======

Authors
~~~~~~~

* Escodoo

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

* `Escodoo <https://www.escodoo.com.br>`_:

* Marcel Savegnago <marcel.savegnago@escodoo.com.br>

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

This module is part of the `escodoo/account-addons <https://github.com/escodoo/account-addons/tree/14.0/account_move_change_financial_account>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions account_move_change_financial_account/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions account_move_change_financial_account/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 - TODAY, Escodoo
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Account Move Change Financial Account",
"summary": """
Account Move Change Financial Account""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Escodoo",
"website": "https://github.com/Escodoo/account-addons",
"depends": [
"account",
],
"data": [
"security/account_account_financial_rules.xml",
"views/account_account_financial_rules.xml",
],
"demo": [],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_move_change_financial_account
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.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_move_change_financial_account
#: model:ir.model,name:account_move_change_financial_account.model_account_account_financial_rules
msgid "Account Account Financial Rules"
msgstr ""

#. module: account_move_change_financial_account
#: model:ir.actions.act_window,name:account_move_change_financial_account.account_account_financial_rules_act_window
#: model:ir.ui.menu,name:account_move_change_financial_account.account_account_financial_rules_menu
msgid "Account Financial Rules"
msgstr ""

#. module: account_move_change_financial_account
#: model:ir.model.fields,field_description:account_move_change_financial_account.field_account_account_financial_rules__financial_account_id
msgid "Account Receivable/Payable"
msgstr ""

#. module: account_move_change_financial_account
#: model:ir.model.fields,field_description:account_move_change_financial_account.field_account_account_financial_rules__create_uid
msgid "Created by"
msgstr ""

#. module: account_move_change_financial_account
#: model:ir.model.fields,field_description:account_move_change_financial_account.field_account_account_financial_rules__create_date
msgid "Created on"
msgstr ""

#. module: account_move_change_financial_account
#: model:ir.model.fields,field_description:account_move_change_financial_account.field_account_account_financial_rules__display_name
msgid "Display Name"
msgstr ""

#. module: account_move_change_financial_account
#: model:ir.model.fields,field_description:account_move_change_financial_account.field_account_account_financial_rules__domain
msgid "Domain Value"
msgstr ""

#. module: account_move_change_financial_account
#: model:ir.model.fields,field_description:account_move_change_financial_account.field_account_account_financial_rules__id
msgid "ID"
msgstr ""

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

#. module: account_move_change_financial_account
#: model:ir.model.fields,field_description:account_move_change_financial_account.field_account_account_financial_rules____last_update
msgid "Last Modified on"
msgstr ""

#. module: account_move_change_financial_account
#: model:ir.model.fields,field_description:account_move_change_financial_account.field_account_account_financial_rules__write_uid
msgid "Last Updated by"
msgstr ""

#. module: account_move_change_financial_account
#: model:ir.model.fields,field_description:account_move_change_financial_account.field_account_account_financial_rules__write_date
msgid "Last Updated on"
msgstr ""

#. module: account_move_change_financial_account
#: model:ir.model.fields,field_description:account_move_change_financial_account.field_account_account_financial_rules__name
msgid "Name"
msgstr ""

#. module: account_move_change_financial_account
#: model:ir.model.fields,help:account_move_change_financial_account.field_account_account_financial_rules__domain
msgid ""
"Optional domain filtering of the destination data, as a Python expression"
msgstr ""

#. module: account_move_change_financial_account
#: model:ir.model.fields,help:account_move_change_financial_account.field_account_account_financial_rules__financial_account_id
msgid ""
"This account will be used instead of the default one as the receivable "
"account for the current partner"
msgstr ""
2 changes: 2 additions & 0 deletions account_move_change_financial_account/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_move_line
from . import account_account_financial_rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2023 - TODAY, Marcel Savegnago <marcel.savegnago@escodoo.com.br>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class AccountAccountFinancialRules(models.Model):

_name = "account.account.financial.rules"
_inherit = ["mail.thread"]
_description = "Account Account Financial Rules"

name = fields.Char(required=True)
domain = fields.Char(
string="Domain Value",
help="Optional domain filtering of the destination data, as a Python expression",
required=True,
)
financial_account_id = fields.Many2one(
"account.account",
company_dependent=True,
string="Account Receivable/Payable",
domain="["
"'|', ('account_type', '=', 'asset_receivable'),"
"('account_type', '=', 'liability_payable'),"
"('deprecated', '=', False),"
"('company_id', '=', current_company_id)"
"]",
help="This account will be used instead of the default one as the receivable "
"account for the current partner",
required=True,
)
45 changes: 45 additions & 0 deletions account_move_change_financial_account/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2023 - TODAY, Marcel Savegnago <marcel.savegnago@escodoo.com.br>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import ast

from odoo import api, models


class AccountMoveLine(models.Model):

_inherit = "account.move.line"

@api.model_create_multi
def create(self, vals_list):
lines_super = super().create(vals_list)
self._apply_financial_rules(lines_super)
return lines_super

def _get_financial_lines(self, lines):
return lines.filtered(
lambda line: line.account_id.account_type
in ("asset_receivable", "liability_payable")
)

def _apply_financial_rules(self, lines):
financial_lines = self._get_financial_lines(lines)

if not financial_lines:
return

domain_ids = self.env["account.account.financial.rules"].search(
[("domain", "!=", False)]
)

for domain_id in domain_ids:
if not financial_lines:
break

domain = ast.literal_eval(domain_id.domain)
lines_to_change = financial_lines.filtered_domain(domain)

if lines_to_change:
for line in lines_to_change:
line.account_id = domain_id.financial_account_id
financial_lines -= lines_to_change
3 changes: 3 additions & 0 deletions account_move_change_financial_account/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Escodoo <https://www.escodoo.com.br>`_:

* Marcel Savegnago <marcel.savegnago@escodoo.com.br>
9 changes: 9 additions & 0 deletions account_move_change_financial_account/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This module allows for the automatic changing of financial accounts in accounting move lines (account.move.line) based on predefined rules. This simplifies the application of specific accounting policies without the need for manually adjusting each accounting move.

Key Features:

1. Define financial account substitution rules through the account_account_financial_rule class.
2. Apply the substitution rules during the creation of new accounting moves (account.move).
3. Supports rules based on specific criteria, such as the partner involved in the transaction.

With the account_move_change_financial_account module, users can easily set up and apply custom financial rules, streamlining the accounting process and ensuring compliance with the company's accounting policies.
5 changes: 5 additions & 0 deletions account_move_change_financial_account/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

- Install the account_move_change_financial_account module.
- Navigate to the financial rules menu (Accounting > Configuration > Account Financial Rules) and create a new rule by defining the domain condition and the new financial account to be applied.
- When a new accounting move is created and meets the financial rule's domain condition, the financial account of the applicable lines will be automatically changed according to the rule.
- Review the accounting moves to ensure that the financial rules have been correctly applied.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 - TODAY, Marcel Savegnago <marcel.savegnago@escodoo.com.br>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.model.access" id="account_account_financial_rules_access_user">
<field name="name">account.account.financial.rules access user</field>
<field name="model_id" ref="model_account_account_financial_rules" />
<!-- TODO review and adapt -->
<field name="group_id" ref="base.group_user" />
<field name="perm_read" eval="1" />
<field name="perm_create" eval="0" />
<field name="perm_write" eval="0" />
<field name="perm_unlink" eval="0" />
</record>

<record model="ir.model.access" id="account_account_financial_rules_access_manager">
<field name="name">account.account.financial.rules access manager</field>
<field name="model_id" ref="model_account_account_financial_rules" />
<field name="group_id" ref="account.group_account_manager" />
<field name="perm_read" eval="1" />
<field name="perm_create" eval="1" />
<field name="perm_write" eval="1" />
<field name="perm_unlink" eval="1" />
</record>

</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading