diff --git a/account_move_total_by_account_internal_group/README.rst b/account_move_total_by_account_internal_group/README.rst new file mode 100644 index 00000000000..96f55031255 --- /dev/null +++ b/account_move_total_by_account_internal_group/README.rst @@ -0,0 +1,94 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============================================ +Account Move Total By Account Internal Group +============================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:94fb26a31f942a6e265b921efe62885d160e7035ad54215d27042b59c67bd7e1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/license-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--financial--tools-lightgray.png?logo=github + :target: https://github.com/OCA/account-financial-tools/tree/19.0/account_move_total_by_account_internal_group + :alt: OCA/account-financial-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-financial-tools-19-0/account-financial-tools-19-0-account_move_total_by_account_internal_group + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/account-financial-tools&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Displays the total balance by account internal group in the journal +entries. This could be necesssary in some context. For example, when +looking at the stock journal entries we would like to see the total +assets, as long as we would like to see the assets increasing when there +is a debit in the inventory account and deceasing when the inventory is +decreased. The standard field amount_total_signed does not serve, as it +shows this as a positive value in this case. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +New hidden columns in journal Entries tree view. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ForgeFlow + +Contributors +------------ + +- \`ForgeFlow + <`https://opensourceintegrators.com\\>\\\` \`>`__: + + - Aaron Henriquez + +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-financial-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_move_total_by_account_internal_group/__init__.py b/account_move_total_by_account_internal_group/__init__.py new file mode 100644 index 00000000000..6d58305f5dd --- /dev/null +++ b/account_move_total_by_account_internal_group/__init__.py @@ -0,0 +1,2 @@ +from . import models +from .hooks import pre_init_hook diff --git a/account_move_total_by_account_internal_group/__manifest__.py b/account_move_total_by_account_internal_group/__manifest__.py new file mode 100644 index 00000000000..654a04a20e8 --- /dev/null +++ b/account_move_total_by_account_internal_group/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2022 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Account Move Total By Account Internal Group", + "version": "19.0.1.0.0", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "summary": "Adds Totals by Account Internal Group in Journal Entries", + "website": "https://github.com/OCA/account-financial-tools", + "license": "AGPL-3", + "depends": ["account"], + "category": "Accounting", + "data": [ + "views/account_move_views.xml", + ], + "installable": True, + "maintainer": "AaronHForgeFlow", + "development_status": "Beta", + "pre_init_hook": "pre_init_hook", +} diff --git a/account_move_total_by_account_internal_group/hooks.py b/account_move_total_by_account_internal_group/hooks.py new file mode 100644 index 00000000000..fbd6399a194 --- /dev/null +++ b/account_move_total_by_account_internal_group/hooks.py @@ -0,0 +1,27 @@ +# Copyright 2022 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import logging + + +def pre_init_hook(env): + """Precreate account_internal_group and fill with appropriate values to prevent + a MemoryError when the ORM attempts to call its compute method on a large + amount of preexisting moves.""" + logger = logging.getLogger(__name__) + logger.info( + "Add account_move_line.account_internal_group column if it does not yet exist" + ) + env.cr.execute( + "ALTER TABLE account_move_line ADD COLUMN IF NOT EXISTS " + "account_internal_group VARCHAR" + ) + env.cr.execute( + """ UPDATE account_move_line aml0 SET account_internal_group = aa.account_type + FROM account_move_line aml + INNER JOIN account_account aa ON aa.id = aml.account_id + WHERE aml.id = aml0.id + AND aml.account_internal_group IS NULL + """ + ) + logger.info("Finished adding account_move_line.account_internal_group column") diff --git a/account_move_total_by_account_internal_group/i18n/account_move_total_by_account_internal_group.pot b/account_move_total_by_account_internal_group/i18n/account_move_total_by_account_internal_group.pot new file mode 100644 index 00000000000..d23d412826f --- /dev/null +++ b/account_move_total_by_account_internal_group/i18n/account_move_total_by_account_internal_group.pot @@ -0,0 +1,138 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_total_by_account_internal_group +# +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_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_bank_statement_line__amount_total_signed_account_internal_group_asset +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move__amount_total_signed_account_internal_group_asset +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_payment__amount_total_signed_account_internal_group_asset +msgid "Amount Total Signed Account Internal Group Asset" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_bank_statement_line__amount_total_signed_account_internal_group_equity +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move__amount_total_signed_account_internal_group_equity +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_payment__amount_total_signed_account_internal_group_equity +msgid "Amount Total Signed Account Internal Group Equity" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_bank_statement_line__amount_total_signed_account_internal_group_expense +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move__amount_total_signed_account_internal_group_expense +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_payment__amount_total_signed_account_internal_group_expense +msgid "Amount Total Signed Account Internal Group Expense" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_bank_statement_line__amount_total_signed_account_internal_group_income +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move__amount_total_signed_account_internal_group_income +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_payment__amount_total_signed_account_internal_group_income +msgid "Amount Total Signed Account Internal Group Income" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_bank_statement_line__amount_total_signed_account_internal_group_liability +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move__amount_total_signed_account_internal_group_liability +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_payment__amount_total_signed_account_internal_group_liability +msgid "Amount Total Signed Account Internal Group Liability" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_bank_statement_line__amount_total_signed_account_internal_group_off_balance +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move__amount_total_signed_account_internal_group_off_balance +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_payment__amount_total_signed_account_internal_group_off_balance +msgid "Amount Total Signed Account Internal Group Off Balance" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move_line__account_internal_group +msgid "Internal Group" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model,name:account_move_total_by_account_internal_group.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model,name:account_move_total_by_account_internal_group.model_account_move_line +msgid "Journal Item" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,help:account_move_total_by_account_internal_group.field_account_move_line__account_internal_group +msgid "" +"The 'Internal Group' is used to filter accounts based on the internal group " +"set on the account type." +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Asset" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Equity" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Expense" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Income" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Liability" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Off Balance" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Signed Asset" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Signed Equity" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Signed Expense" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Signed Income" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Signed Liability" +msgstr "" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Signed Off Balance" +msgstr "" diff --git a/account_move_total_by_account_internal_group/i18n/es.po b/account_move_total_by_account_internal_group/i18n/es.po new file mode 100644 index 00000000000..64cd9cc7da8 --- /dev/null +++ b/account_move_total_by_account_internal_group/i18n/es.po @@ -0,0 +1,143 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_move_total_by_account_internal_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-10-10 19:36+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_bank_statement_line__amount_total_signed_account_internal_group_asset +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move__amount_total_signed_account_internal_group_asset +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_payment__amount_total_signed_account_internal_group_asset +msgid "Amount Total Signed Account Internal Group Asset" +msgstr "Importe Total Cuenta Firmada Grupo Interno Activo" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_bank_statement_line__amount_total_signed_account_internal_group_equity +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move__amount_total_signed_account_internal_group_equity +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_payment__amount_total_signed_account_internal_group_equity +msgid "Amount Total Signed Account Internal Group Equity" +msgstr "Importe Total Cuenta firmada Patrimonio interno del Grupo" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_bank_statement_line__amount_total_signed_account_internal_group_expense +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move__amount_total_signed_account_internal_group_expense +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_payment__amount_total_signed_account_internal_group_expense +msgid "Amount Total Signed Account Internal Group Expense" +msgstr "Importe Total Cuenta firmada Gastos internos del grupo" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_bank_statement_line__amount_total_signed_account_internal_group_income +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move__amount_total_signed_account_internal_group_income +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_payment__amount_total_signed_account_internal_group_income +msgid "Amount Total Signed Account Internal Group Income" +msgstr "Importe Total Cuenta Firmada Ingresos Grupo Interno" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_bank_statement_line__amount_total_signed_account_internal_group_liability +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move__amount_total_signed_account_internal_group_liability +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_payment__amount_total_signed_account_internal_group_liability +msgid "Amount Total Signed Account Internal Group Liability" +msgstr "Importe Total Cuenta firmada Pasivo interno del grupo" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_bank_statement_line__amount_total_signed_account_internal_group_off_balance +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move__amount_total_signed_account_internal_group_off_balance +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_payment__amount_total_signed_account_internal_group_off_balance +msgid "Amount Total Signed Account Internal Group Off Balance" +msgstr "Importe Total Cuenta Firmada Grupo Interno Saldo" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,field_description:account_move_total_by_account_internal_group.field_account_move_line__account_internal_group +msgid "Internal Group" +msgstr "Grupo interno" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model,name:account_move_total_by_account_internal_group.model_account_move +msgid "Journal Entry" +msgstr "Entrada Diaria" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model,name:account_move_total_by_account_internal_group.model_account_move_line +msgid "Journal Item" +msgstr "Artículo Diario" + +#. module: account_move_total_by_account_internal_group +#: model:ir.model.fields,help:account_move_total_by_account_internal_group.field_account_move_line__account_internal_group +msgid "" +"The 'Internal Group' is used to filter accounts based on the internal group " +"set on the account type." +msgstr "" +"El \"Grupo interno\" se utiliza para filtrar las cuentas en función del " +"grupo interno establecido en el tipo de cuenta." + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Asset" +msgstr "Activo total" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Equity" +msgstr "Patrimonio neto total" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Expense" +msgstr "Gasto total" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Income" +msgstr "Ingresos totales" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Liability" +msgstr "Pasivo total" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Off Balance" +msgstr "Total fuera de balance" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Signed Asset" +msgstr "Total Activo Firmado" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Signed Equity" +msgstr "Total de fondos propios firmados" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Signed Expense" +msgstr "Gasto total firmado" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Signed Income" +msgstr "Ingresos totales firmados" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Signed Liability" +msgstr "Responsabilidad total firmada" + +#. module: account_move_total_by_account_internal_group +#: model_terms:ir.ui.view,arch_db:account_move_total_by_account_internal_group.view_account_move_user_type_tree +msgid "Total Signed Off Balance" +msgstr "Saldo total firmado" diff --git a/account_move_total_by_account_internal_group/models/__init__.py b/account_move_total_by_account_internal_group/models/__init__.py new file mode 100644 index 00000000000..0d5ab6a2fc6 --- /dev/null +++ b/account_move_total_by_account_internal_group/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_move +from . import account_move_line diff --git a/account_move_total_by_account_internal_group/models/account_move.py b/account_move_total_by_account_internal_group/models/account_move.py new file mode 100644 index 00000000000..1555fbbf15d --- /dev/null +++ b/account_move_total_by_account_internal_group/models/account_move.py @@ -0,0 +1,52 @@ +# Copyright 2022 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class AccountMove(models.Model): + _inherit = "account.move" + + amount_total_signed_account_internal_group_equity = fields.Monetary( + compute="_compute_amount_total_signed_account_internal_group" + ) + amount_total_signed_account_internal_group_asset = fields.Monetary( + compute="_compute_amount_total_signed_account_internal_group" + ) + amount_total_signed_account_internal_group_liability = fields.Monetary( + compute="_compute_amount_total_signed_account_internal_group" + ) + amount_total_signed_account_internal_group_income = fields.Monetary( + compute="_compute_amount_total_signed_account_internal_group" + ) + amount_total_signed_account_internal_group_expense = fields.Monetary( + compute="_compute_amount_total_signed_account_internal_group" + ) + amount_total_signed_account_internal_group_off_balance = fields.Monetary( + compute="_compute_amount_total_signed_account_internal_group" + ) + + def _compute_amount_total_signed_account_internal_group(self): + group_list = [ + "equity", + "asset", + "liability", + "income", + "expense", + "off_balance", + ] + for move in self: + for g in group_list: + move[f"amount_total_signed_account_internal_group_{g}"] = 0.0 + domain = [("move_id", "=", move.id)] + aml_groups = self.env["account.move.line"]._read_group( + domain=domain, + groupby=["account_internal_group"], + aggregates=["balance:sum"], + ) + for aml_group in aml_groups: + acc_type = aml_group[0] # e.g. "asset" + balance_sum = aml_group[1] # sum of balance + field_name = f"amount_total_signed_account_internal_group_{acc_type}" + if field_name in move._fields: + move[field_name] = balance_sum diff --git a/account_move_total_by_account_internal_group/models/account_move_line.py b/account_move_total_by_account_internal_group/models/account_move_line.py new file mode 100644 index 00000000000..93eba9e8ed7 --- /dev/null +++ b/account_move_total_by_account_internal_group/models/account_move_line.py @@ -0,0 +1,16 @@ +# Copyright 2022 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + # Making standard field stored in order to do the calculations faster + account_internal_group = fields.Selection( + related="account_id.internal_group", + string="Internal Group", + readonly=True, + store=True, + ) diff --git a/account_move_total_by_account_internal_group/pyproject.toml b/account_move_total_by_account_internal_group/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/account_move_total_by_account_internal_group/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_move_total_by_account_internal_group/readme/CONTRIBUTORS.md b/account_move_total_by_account_internal_group/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..cc0a43c3417 --- /dev/null +++ b/account_move_total_by_account_internal_group/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- \`ForgeFlow \\`: + - Aaron Henriquez \ diff --git a/account_move_total_by_account_internal_group/readme/DESCRIPTION.md b/account_move_total_by_account_internal_group/readme/DESCRIPTION.md new file mode 100644 index 00000000000..c978f049967 --- /dev/null +++ b/account_move_total_by_account_internal_group/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +Displays the total balance by account internal group in the journal +entries. This could be necesssary in some context. For example, when +looking at the stock journal entries we would like to see the total +assets, as long as we would like to see the assets increasing when there +is a debit in the inventory account and deceasing when the inventory is +decreased. The standard field amount_total_signed does not serve, as it +shows this as a positive value in this case. diff --git a/account_move_total_by_account_internal_group/readme/USAGE.md b/account_move_total_by_account_internal_group/readme/USAGE.md new file mode 100644 index 00000000000..af4771e983f --- /dev/null +++ b/account_move_total_by_account_internal_group/readme/USAGE.md @@ -0,0 +1 @@ +New hidden columns in journal Entries tree view. diff --git a/account_move_total_by_account_internal_group/static/description/icon.png b/account_move_total_by_account_internal_group/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/account_move_total_by_account_internal_group/static/description/icon.png differ diff --git a/account_move_total_by_account_internal_group/static/description/index.html b/account_move_total_by_account_internal_group/static/description/index.html new file mode 100644 index 00000000000..309430df11b --- /dev/null +++ b/account_move_total_by_account_internal_group/static/description/index.html @@ -0,0 +1,444 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Account Move Total By Account Internal Group

+ +

Beta License: AGPL-3 OCA/account-financial-tools Translate me on Weblate Try me on Runboat

+

Displays the total balance by account internal group in the journal +entries. This could be necesssary in some context. For example, when +looking at the stock journal entries we would like to see the total +assets, as long as we would like to see the assets increasing when there +is a debit in the inventory account and deceasing when the inventory is +decreased. The standard field amount_total_signed does not serve, as it +shows this as a positive value in this case.

+

Table of contents

+ +
+

Usage

+

New hidden columns in journal Entries tree view.

+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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-financial-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/account_move_total_by_account_internal_group/tests/__init__.py b/account_move_total_by_account_internal_group/tests/__init__.py new file mode 100644 index 00000000000..5ccaccb3b11 --- /dev/null +++ b/account_move_total_by_account_internal_group/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_account_move_totals_by_account_internal_group diff --git a/account_move_total_by_account_internal_group/tests/test_account_move_totals_by_account_internal_group.py b/account_move_total_by_account_internal_group/tests/test_account_move_totals_by_account_internal_group.py new file mode 100644 index 00000000000..0a6400a238a --- /dev/null +++ b/account_move_total_by_account_internal_group/tests/test_account_move_totals_by_account_internal_group.py @@ -0,0 +1,109 @@ +# Copyright 2022 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestAccountMoveTotalsByAccountType(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.account_model = cls.env["account.account"] + cls.company = cls.env.ref("base.main_company") + # Create account for Goods Received Not Invoiced + name = "Goods Received Not Invoiced" + code = "grni" + cls.account_grni = cls._create_account(cls, "liability_payable", name, code) + + # Create account for Cost of Goods Sold + name = "Cost of Goods Sold" + code = "cogs" + cls.account_cogs = cls._create_account(cls, "expense", name, code) + # Create account for Inventory + name = "Inventory" + code = "inventory" + cls.account_inventory = cls._create_account(cls, "asset_fixed", name, code) + # Create Income account + # Create account for Inventory + name = "Income" + code = "income" + cls.account_income = cls._create_account(cls, "income", name, code) + cls.journal = cls.env["account.journal"].search( + [("company_id", "=", cls.env.user.company_id.id)], limit=1 + ) + cls.partner = cls.env["res.partner"].create({"name": "Test Partner"}) + + def _create_account_move(self, dr_account, cr_account): + move_vals = { + "journal_id": self.journal.id, + "date": "1900-01-01", + "line_ids": [ + ( + 0, + 0, + { + "debit": 100.0, + "credit": 0.0, + "account_id": dr_account.id, + "partner_id": self.partner.id, + }, + ), + ( + 0, + 0, + { + "debit": 0.0, + "credit": 100.0, + "account_id": cr_account.id, + "partner_id": self.partner.id, + }, + ), + ], + } + return self.env["account.move"].create(move_vals) + + def _create_account(self, acc_type, name, code): + """Create an account.""" + account = self.account_model.create( + { + "name": name, + "code": code, + "account_type": acc_type, + "reconcile": True, + } + ) + return account + + def test_01_account_internal_group_balance(self): + """Create JE with different account types and check the amount total + by internal group + """ + account_move = self._create_account_move( + self.account_inventory, self.account_grni + ) + self.assertEqual( + account_move.amount_total_signed_account_internal_group_asset, + 100, + "Wrong asset", + ) + self.assertEqual( + account_move.amount_total_signed_account_internal_group_liability, + -100, + "Wrong liability", + ) + self.assertEqual( + account_move.amount_total_signed_account_internal_group_expense, + 0, + "Wrong expense", + ) + account_move = self._create_account_move(self.account_cogs, self.account_income) + self.assertEqual( + account_move.amount_total_signed_account_internal_group_expense, + 100, + "Wrong Expense", + ) + self.assertEqual( + account_move.amount_total_signed_account_internal_group_income, + -100, + "Wrong Income", + ) diff --git a/account_move_total_by_account_internal_group/views/account_move_views.xml b/account_move_total_by_account_internal_group/views/account_move_views.xml new file mode 100644 index 00000000000..6a21fd5c686 --- /dev/null +++ b/account_move_total_by_account_internal_group/views/account_move_views.xml @@ -0,0 +1,53 @@ + + + account.move.user.type.tree + account.move + + + + + + + + + + + + +