From d72520dff42b5848ae3831df618fc213e067dd55 Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Mon, 10 Apr 2023 16:22:29 -0300 Subject: [PATCH 1/9] [ADD] account_move_change_financial_account: New module --- .../README.rst | 81 +++++++ .../__init__.py | 1 + .../__manifest__.py | 20 ++ .../models/__init__.py | 2 + .../models/account_account_financial_rules.py | 30 +++ .../models/account_move_line.py | 44 ++++ .../readme/CONTRIBUTORS.rst | 0 .../readme/DESCRIPTION.rst | 0 .../readme/USAGE.rst | 0 .../account_account_financial_rules.xml | 27 +++ .../static/description/icon.png | Bin 0 -> 2873 bytes .../tests/__init__.py | 1 + ...t_account_move_change_financial_account.py | 199 ++++++++++++++++++ .../views/account_account_financial_rules.xml | 78 +++++++ 14 files changed, 483 insertions(+) create mode 100644 account_move_change_financial_account/README.rst create mode 100644 account_move_change_financial_account/__init__.py create mode 100644 account_move_change_financial_account/__manifest__.py create mode 100644 account_move_change_financial_account/models/__init__.py create mode 100644 account_move_change_financial_account/models/account_account_financial_rules.py create mode 100644 account_move_change_financial_account/models/account_move_line.py create mode 100644 account_move_change_financial_account/readme/CONTRIBUTORS.rst create mode 100644 account_move_change_financial_account/readme/DESCRIPTION.rst create mode 100644 account_move_change_financial_account/readme/USAGE.rst create mode 100644 account_move_change_financial_account/security/account_account_financial_rules.xml create mode 100644 account_move_change_financial_account/static/description/icon.png create mode 100644 account_move_change_financial_account/tests/__init__.py create mode 100644 account_move_change_financial_account/tests/test_account_move_change_financial_account.py create mode 100644 account_move_change_financial_account/views/account_account_financial_rules.xml diff --git a/account_move_change_financial_account/README.rst b/account_move_change_financial_account/README.rst new file mode 100644 index 0000000..5d1d3ec --- /dev/null +++ b/account_move_change_financial_account/README.rst @@ -0,0 +1,81 @@ +=========================== +Account Move Change Account +=========================== +.. |badge1| image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +|badge1| + +Account Move Change Account + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To Configure... + +Usage +===== + +To usage... + +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 smash it by providing detailed and welcomed feedback. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Escodoo + +Contributors +~~~~~~~~~~~~ + +* Marcel Savegnago + +Other credits +~~~~~~~~~~~~~ + +The development of this module has been financially supported by: + +* Escodoo - `https://www.escodoo.com.br `_ + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the Escodoo. + +.. |maintainer-escodoo| image:: https://github.com/escodoo.png?size=80px + :target: https://github.com/Escodoo + :alt: escodoo + +|maintainer-escodoo| + +We at Escodoo are exclusively dedicated to deploying the Odoo Platform and are +focused on providing solutions that make our customers more competitive, lowering +costs, making technology more accessible and ensuring it is used strategically to +add even more value to the business. + +.. |maintainer-marcelsavegnago| image:: https://github.com/marcelsavegnago.png?size=40px + :target: https://github.com/marcelsavegnago + :alt: marcelsavegnago + +Current `maintainer `__: + +|maintainer-marcelsavegnago| + +To contribute to this module, please visit https://www.escodoo.com.br. diff --git a/account_move_change_financial_account/__init__.py b/account_move_change_financial_account/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/account_move_change_financial_account/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_move_change_financial_account/__manifest__.py b/account_move_change_financial_account/__manifest__.py new file mode 100644 index 0000000..dcc0bd0 --- /dev/null +++ b/account_move_change_financial_account/__manifest__.py @@ -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": "14.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": [], +} diff --git a/account_move_change_financial_account/models/__init__.py b/account_move_change_financial_account/models/__init__.py new file mode 100644 index 0000000..e1ced8a --- /dev/null +++ b/account_move_change_financial_account/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_move_line +from . import account_account_financial_rules diff --git a/account_move_change_financial_account/models/account_account_financial_rules.py b/account_move_change_financial_account/models/account_account_financial_rules.py new file mode 100644 index 0000000..86137c5 --- /dev/null +++ b/account_move_change_financial_account/models/account_account_financial_rules.py @@ -0,0 +1,30 @@ +# Copyright 2023 - TODAY, Marcel Savegnago +# 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" + _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="[" + "'|', ('internal_type', '=', 'receivable'), ('internal_type', '=', '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, + ) diff --git a/account_move_change_financial_account/models/account_move_line.py b/account_move_change_financial_account/models/account_move_line.py new file mode 100644 index 0000000..a14c470 --- /dev/null +++ b/account_move_change_financial_account/models/account_move_line.py @@ -0,0 +1,44 @@ +# Copyright 2023 - TODAY, Marcel Savegnago +# 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.user_type_id.type in ("receivable", "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 diff --git a/account_move_change_financial_account/readme/CONTRIBUTORS.rst b/account_move_change_financial_account/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..e69de29 diff --git a/account_move_change_financial_account/readme/DESCRIPTION.rst b/account_move_change_financial_account/readme/DESCRIPTION.rst new file mode 100644 index 0000000..e69de29 diff --git a/account_move_change_financial_account/readme/USAGE.rst b/account_move_change_financial_account/readme/USAGE.rst new file mode 100644 index 0000000..e69de29 diff --git a/account_move_change_financial_account/security/account_account_financial_rules.xml b/account_move_change_financial_account/security/account_account_financial_rules.xml new file mode 100644 index 0000000..aa33e51 --- /dev/null +++ b/account_move_change_financial_account/security/account_account_financial_rules.xml @@ -0,0 +1,27 @@ + + + + + + account.account.financial.rules access user + + + + + + + + + + + account.account.financial.rules access manager + + + + + + + + + diff --git a/account_move_change_financial_account/static/description/icon.png b/account_move_change_financial_account/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..12ab0051e3b9ac413f0f0016b7cff54f02fc763e GIT binary patch literal 2873 zcmV-93&!+`P)`uGecH7++*a9tqf=D4K3Mya}O@tpzNQ@yQCf@Kr zF!+nnKqBHT7^8%kXfz5&3vvk;1t}w7Z?N*D?A{ zHrd_G%z4iDJn#2;p6~mP`2CNcJjDNjrs?X8sbe)Nav^9t4K(ppCb-d2d)&lZ>k%SMT{9YBg-a+&W{!hd#wDr8Wl{eXS z*$7*96lqpl{PUr=s8^hIiDg}g*f5f1&&S6&>%w7_k{mf$=0jJV!9`c@;PA^Op1%JL zjvcP7X-sQIgb*+?KF9@EjIw?AMgZbC#&KNql%Q6tlgni}^ZZSmdHyEeJ2=g=55CEv zmnMkgHHh!qH~xB6FC&#;=S7>@bLA+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z?sv45gWOvE4eFE>qZUjkoRBK+sicvFHdR7XOOU0%|W1q%;d9)-MBq*+VWTdKUiy XXqTGI$C0NT00000NkvXXu0mjf?G|(} literal 0 HcmV?d00001 diff --git a/account_move_change_financial_account/tests/__init__.py b/account_move_change_financial_account/tests/__init__.py new file mode 100644 index 0000000..1c0eead --- /dev/null +++ b/account_move_change_financial_account/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_move_change_financial_account diff --git a/account_move_change_financial_account/tests/test_account_move_change_financial_account.py b/account_move_change_financial_account/tests/test_account_move_change_financial_account.py new file mode 100644 index 0000000..688d2e8 --- /dev/null +++ b/account_move_change_financial_account/tests/test_account_move_change_financial_account.py @@ -0,0 +1,199 @@ +# Copyright 2023 - TODAY, Marcel Savegnago +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import tagged + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon + + +@tagged("post_install", "-at_install") +class TestAccountAccountFinancialRules(AccountTestInvoicingCommon): + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) + cls.account_move = cls.env["account.move"] + cls.account_move_line = cls.env["account.move.line"] + cls.financial_rules = cls.env["account.account.financial.rules"] + + cls.partner = cls.env["res.partner"].create( + { + "name": "Test Partner", + } + ) + cls.receivable_account = cls.env["account.account"].search( + [("internal_type", "=", "receivable")], limit=1 + ) + cls.revenue_account = cls.env["account.account"].create( + { + "name": "Test Revenue Account", + "code": "TRA", + "user_type_id": cls.env.ref("account.data_account_type_revenue").id, + } + ) + cls.new_receivable_account = cls.env["account.account"].create( + { + "name": "New Receivable Account", + "code": "NEWRCV", + "user_type_id": cls.env.ref("account.data_account_type_receivable").id, + "reconcile": True, + } + ) + + def test_financial_rules_creation(self): + rule = self.financial_rules.create( + { + "name": "Test Rule", + "domain": "[('partner_id', '=', %s)]" % self.partner.id, + "financial_account_id": self.new_receivable_account.id, + } + ) + self.assertTrue(rule) + + def test_account_move_line_creation(self): + self.financial_rules.create( + { + "name": "Test Rule", + "domain": "[('partner_id', '=', %s)]" % self.partner.id, + "financial_account_id": self.new_receivable_account.id, + } + ) + + # Test a rule that will not be applied to any line + self.financial_rules.create( + { + "name": "Test Rule No Match", + "domain": "[('partner_id', '=', -1)]", + "financial_account_id": self.new_receivable_account.id, + } + ) + + move = self.account_move.create( + { + "partner_id": self.partner.id, + "line_ids": [ + ( + 0, + 0, + { + "account_id": self.receivable_account.id, + "partner_id": self.partner.id, + "name": "Receivable line", + "debit": 100.0, + "credit": 0.0, + }, + ), + ( + 0, + 0, + { + "account_id": self.revenue_account.id, + "partner_id": self.partner.id, + "name": "Revenue line", + "debit": 0.0, + "credit": 100.0, + }, + ), + ], + } + ) + + receivable_line = move.line_ids.filtered( + lambda line: line.account_id == self.receivable_account + ) + self.assertFalse(receivable_line) + + new_receivable_line = move.line_ids.filtered( + lambda line: line.account_id == self.new_receivable_account + ) + self.assertTrue(new_receivable_line) + + def test_lines_to_change_no_match(self): + # Test a rule that will not be applied to any line + self.financial_rules.create( + { + "name": "Test Rule No Match", + "domain": "[('partner_id', '=', -1)]", + "financial_account_id": self.new_receivable_account.id, + } + ) + + move = self.account_move.create( + { + "partner_id": self.partner.id, + "line_ids": [ + ( + 0, + 0, + { + "account_id": self.receivable_account.id, + "partner_id": self.partner.id, + "name": "Receivable line", + "debit": 100.0, + "credit": 0.0, + }, + ), + ( + 0, + 0, + { + "account_id": self.revenue_account.id, + "partner_id": self.partner.id, + "name": "Revenue line", + "debit": 0.0, + "credit": 100.0, + }, + ), + ], + } + ) + + # Check if the original receivable account is still used when there's no matching rule + receivable_line = move.line_ids.filtered( + lambda line: line.account_id == self.receivable_account + ) + self.assertTrue(receivable_line) + + # Check if the new_receivable_account is not used when there's no matching rule + new_receivable_line = move.line_ids.filtered( + lambda line: line.account_id == self.new_receivable_account + ) + self.assertFalse(new_receivable_line) + + def test_no_matching_financial_lines(self): + # Test that the code doesn't enter the for loop when there are no financial lines + + move = self.account_move.create( + { + "partner_id": self.partner.id, + "line_ids": [ + ( + 0, + 0, + { + "account_id": self.revenue_account.id, + "partner_id": self.partner.id, + "name": "Revenue line", + "debit": 0.0, + "credit": 100.0, + }, + ), + ( + 0, + 0, + { + "account_id": self.revenue_account.id, + "partner_id": self.partner.id, + "name": "Revenue line 2", + "debit": 100.0, + "credit": 0.0, + }, + ), + ], + } + ) + + # Check if the new_receivable_account is not used when there are no financial lines + new_receivable_line = move.line_ids.filtered( + lambda line: line.account_id == self.new_receivable_account + ) + self.assertFalse(new_receivable_line) diff --git a/account_move_change_financial_account/views/account_account_financial_rules.xml b/account_move_change_financial_account/views/account_account_financial_rules.xml new file mode 100644 index 0000000..53f8a98 --- /dev/null +++ b/account_move_change_financial_account/views/account_account_financial_rules.xml @@ -0,0 +1,78 @@ + + + + + + account.account.financial.rules.form (in account_move_change_financial_account) + account.account.financial.rules + +
+
+ +
+ + + + + + + +
+ + + + + + account.account.financial.rules.search (in account_move_change_financial_account) + account.account.financial.rules + + + + + + + + + + + account.account.financial.rules.tree (in account_move_change_financial_account) + account.account.financial.rules + + + + + + + + + + + Account Financial Rules + account.account.financial.rules + tree,form + [] + {} + + + + Account Financial Rules + + + + + + From d004112bcc3a5cb4a47fdb959f68522d024b74f5 Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Tue, 11 Apr 2023 16:40:32 -0300 Subject: [PATCH 2/9] [IMP] account_move_change_financial_account: update readme files --- .../README.rst | 82 ++-- .../readme/CONTRIBUTORS.rst | 3 + .../readme/DESCRIPTION.rst | 9 + .../readme/USAGE.rst | 4 + .../static/description/index.html | 434 ++++++++++++++++++ 5 files changed, 488 insertions(+), 44 deletions(-) create mode 100644 account_move_change_financial_account/static/description/index.html diff --git a/account_move_change_financial_account/README.rst b/account_move_change_financial_account/README.rst index 5d1d3ec..ca4961f 100644 --- a/account_move_change_financial_account/README.rst +++ b/account_move_change_financial_account/README.rst @@ -1,36 +1,54 @@ -=========================== -Account Move Change Account -=========================== -.. |badge1| image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg +===================================== +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| +|badge1| |badge2| |badge3| -Account Move Change Account +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: -Configuration -============= - -To Configure... - Usage ===== -To 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 -`_. In case of trouble, please -check there if your issue has already been reported. If you spotted it first, -help us smash it by providing detailed and welcomed feedback. +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 `_. Do not contact contributors directly about support or help with technical issues. @@ -45,37 +63,13 @@ Authors Contributors ~~~~~~~~~~~~ -* Marcel Savegnago - -Other credits -~~~~~~~~~~~~~ - -The development of this module has been financially supported by: +* `Escodoo `_: -* Escodoo - `https://www.escodoo.com.br `_ + * Marcel Savegnago Maintainers ~~~~~~~~~~~ -This module is maintained by the Escodoo. - -.. |maintainer-escodoo| image:: https://github.com/escodoo.png?size=80px - :target: https://github.com/Escodoo - :alt: escodoo - -|maintainer-escodoo| - -We at Escodoo are exclusively dedicated to deploying the Odoo Platform and are -focused on providing solutions that make our customers more competitive, lowering -costs, making technology more accessible and ensuring it is used strategically to -add even more value to the business. - -.. |maintainer-marcelsavegnago| image:: https://github.com/marcelsavegnago.png?size=40px - :target: https://github.com/marcelsavegnago - :alt: marcelsavegnago - -Current `maintainer `__: - -|maintainer-marcelsavegnago| +This module is part of the `escodoo/account-addons `_ project on GitHub. -To contribute to this module, please visit https://www.escodoo.com.br. +You are welcome to contribute. diff --git a/account_move_change_financial_account/readme/CONTRIBUTORS.rst b/account_move_change_financial_account/readme/CONTRIBUTORS.rst index e69de29..ae453a6 100644 --- a/account_move_change_financial_account/readme/CONTRIBUTORS.rst +++ b/account_move_change_financial_account/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Escodoo `_: + + * Marcel Savegnago diff --git a/account_move_change_financial_account/readme/DESCRIPTION.rst b/account_move_change_financial_account/readme/DESCRIPTION.rst index e69de29..76877ba 100644 --- a/account_move_change_financial_account/readme/DESCRIPTION.rst +++ b/account_move_change_financial_account/readme/DESCRIPTION.rst @@ -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. diff --git a/account_move_change_financial_account/readme/USAGE.rst b/account_move_change_financial_account/readme/USAGE.rst index e69de29..f0f798a 100644 --- a/account_move_change_financial_account/readme/USAGE.rst +++ b/account_move_change_financial_account/readme/USAGE.rst @@ -0,0 +1,4 @@ +- 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. diff --git a/account_move_change_financial_account/static/description/index.html b/account_move_change_financial_account/static/description/index.html new file mode 100644 index 0000000..faae1b3 --- /dev/null +++ b/account_move_change_financial_account/static/description/index.html @@ -0,0 +1,434 @@ + + + + + + +Account Move Change Financial Account + + + +
+

Account Move Change Financial Account

+ + +

Beta License: AGPL-3 escodoo/account-addons

+

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. +
  3. Apply the substitution rules during the creation of new accounting moves (account.move).
  4. +
  5. Supports rules based on specific criteria, such as the partner involved in the transaction.
  6. +
+

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

+ +
+

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. +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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Escodoo
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the escodoo/account-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + From b966ba5f108a4b74461cdb1a293851c1909570ea Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Tue, 11 Apr 2023 16:45:17 -0300 Subject: [PATCH 3/9] [FIX] account_move_change_financial_account: fix menuitem --- .../views/account_account_financial_rules.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/account_move_change_financial_account/views/account_account_financial_rules.xml b/account_move_change_financial_account/views/account_account_financial_rules.xml index 53f8a98..d5c9f16 100644 --- a/account_move_change_financial_account/views/account_account_financial_rules.xml +++ b/account_move_change_financial_account/views/account_account_financial_rules.xml @@ -70,9 +70,9 @@ Account Financial Rules - + - + From b732ca690d98003b0e79b2f9572d4b6ad326b38f Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Tue, 11 Apr 2023 17:27:56 -0300 Subject: [PATCH 4/9] [FIX] readme --- account_move_change_financial_account/readme/USAGE.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/account_move_change_financial_account/readme/USAGE.rst b/account_move_change_financial_account/readme/USAGE.rst index f0f798a..3f05f5f 100644 --- a/account_move_change_financial_account/readme/USAGE.rst +++ b/account_move_change_financial_account/readme/USAGE.rst @@ -1,3 +1,4 @@ + - 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. From bcc2b1c9f1495d46d16b60a3c3cc869ff494abab Mon Sep 17 00:00:00 2001 From: Kaynnan Bardauil Date: Fri, 14 Apr 2023 17:11:46 -0300 Subject: [PATCH 5/9] [MIG] account_move_change_financial_account: Migration to 15.0 --- account_move_change_financial_account/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_move_change_financial_account/__manifest__.py b/account_move_change_financial_account/__manifest__.py index dcc0bd0..430b918 100644 --- a/account_move_change_financial_account/__manifest__.py +++ b/account_move_change_financial_account/__manifest__.py @@ -5,7 +5,7 @@ "name": "Account Move Change Financial Account", "summary": """ Account Move Change Financial Account""", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "license": "AGPL-3", "author": "Escodoo", "website": "https://github.com/Escodoo/account-addons", From 9c01d005a6dffd93406b6eed5c0ed8cafb4f1228 Mon Sep 17 00:00:00 2001 From: oca-ci Date: Mon, 17 Apr 2023 12:48:17 +0000 Subject: [PATCH 6/9] [UPD] Update account_move_change_financial_account.pot --- .../account_move_change_financial_account.pot | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 account_move_change_financial_account/i18n/account_move_change_financial_account.pot diff --git a/account_move_change_financial_account/i18n/account_move_change_financial_account.pot b/account_move_change_financial_account/i18n/account_move_change_financial_account.pot new file mode 100644 index 0000000..b4ffcd5 --- /dev/null +++ b/account_move_change_financial_account/i18n/account_move_change_financial_account.pot @@ -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 "" From fd8f1efaffbc0ea9cc085f65ab0f8b9246cbf125 Mon Sep 17 00:00:00 2001 From: kaynnan Date: Wed, 3 May 2023 13:45:33 -0300 Subject: [PATCH 7/9] [IMP] account_move_change_financial_account: pre-commit stuff --- .../odoo/addons/account_move_change_financial_account | 1 + setup/account_move_change_financial_account/setup.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 120000 setup/account_move_change_financial_account/odoo/addons/account_move_change_financial_account create mode 100644 setup/account_move_change_financial_account/setup.py diff --git a/setup/account_move_change_financial_account/odoo/addons/account_move_change_financial_account b/setup/account_move_change_financial_account/odoo/addons/account_move_change_financial_account new file mode 120000 index 0000000..57ebffc --- /dev/null +++ b/setup/account_move_change_financial_account/odoo/addons/account_move_change_financial_account @@ -0,0 +1 @@ +../../../../account_move_change_financial_account \ No newline at end of file diff --git a/setup/account_move_change_financial_account/setup.py b/setup/account_move_change_financial_account/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/account_move_change_financial_account/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From f303d18b6b32c1c1676a16f5fe679f1d9b91c20c Mon Sep 17 00:00:00 2001 From: kaynnan Date: Wed, 3 May 2023 14:37:18 -0300 Subject: [PATCH 8/9] [MIG] account_move_change_financial_account: Migration to 16.0 --- account_move_change_financial_account/__manifest__.py | 2 +- .../models/account_account_financial_rules.py | 6 ++++-- .../models/account_move_line.py | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/account_move_change_financial_account/__manifest__.py b/account_move_change_financial_account/__manifest__.py index 430b918..ef1c01b 100644 --- a/account_move_change_financial_account/__manifest__.py +++ b/account_move_change_financial_account/__manifest__.py @@ -5,7 +5,7 @@ "name": "Account Move Change Financial Account", "summary": """ Account Move Change Financial Account""", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "license": "AGPL-3", "author": "Escodoo", "website": "https://github.com/Escodoo/account-addons", diff --git a/account_move_change_financial_account/models/account_account_financial_rules.py b/account_move_change_financial_account/models/account_account_financial_rules.py index 86137c5..53d288a 100644 --- a/account_move_change_financial_account/models/account_account_financial_rules.py +++ b/account_move_change_financial_account/models/account_account_financial_rules.py @@ -7,6 +7,7 @@ class AccountAccountFinancialRules(models.Model): _name = "account.account.financial.rules" + _inherit = ["mail.thread"] _description = "Account Account Financial Rules" name = fields.Char(required=True) @@ -20,8 +21,9 @@ class AccountAccountFinancialRules(models.Model): company_dependent=True, string="Account Receivable/Payable", domain="[" - "'|', ('internal_type', '=', 'receivable'), ('internal_type', '=', 'payable')," - "('deprecated', '=', False), " + "'|', ('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 " diff --git a/account_move_change_financial_account/models/account_move_line.py b/account_move_change_financial_account/models/account_move_line.py index a14c470..f89d4cf 100644 --- a/account_move_change_financial_account/models/account_move_line.py +++ b/account_move_change_financial_account/models/account_move_line.py @@ -18,7 +18,8 @@ def create(self, vals_list): def _get_financial_lines(self, lines): return lines.filtered( - lambda line: line.account_id.user_type_id.type in ("receivable", "payable") + lambda line: line.account_id.account_type + in ("asset_receivable", "liability_payable") ) def _apply_financial_rules(self, lines): From 00b44e5f0c1f7ad5bd209373e6c02b28d8194c1c Mon Sep 17 00:00:00 2001 From: kaynnan Date: Wed, 3 May 2023 14:50:42 -0300 Subject: [PATCH 9/9] [IMP] account_move_change_financial_account: change internal_type and user_type_id to account_type in tests --- .../tests/test_account_move_change_financial_account.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/account_move_change_financial_account/tests/test_account_move_change_financial_account.py b/account_move_change_financial_account/tests/test_account_move_change_financial_account.py index 688d2e8..a56b3d6 100644 --- a/account_move_change_financial_account/tests/test_account_move_change_financial_account.py +++ b/account_move_change_financial_account/tests/test_account_move_change_financial_account.py @@ -21,20 +21,20 @@ def setUpClass(cls, chart_template_ref=None): } ) cls.receivable_account = cls.env["account.account"].search( - [("internal_type", "=", "receivable")], limit=1 + [("account_type", "=", "asset_receivable")], limit=1 ) cls.revenue_account = cls.env["account.account"].create( { "name": "Test Revenue Account", "code": "TRA", - "user_type_id": cls.env.ref("account.data_account_type_revenue").id, + "account_type": "expense_direct_cost", } ) cls.new_receivable_account = cls.env["account.account"].create( { "name": "New Receivable Account", "code": "NEWRCV", - "user_type_id": cls.env.ref("account.data_account_type_receivable").id, + "account_type": "asset_receivable", "reconcile": True, } )