diff --git a/account_compensate_advance/README.rst b/account_compensate_advance/README.rst new file mode 100644 index 0000000..28f8e83 --- /dev/null +++ b/account_compensate_advance/README.rst @@ -0,0 +1,95 @@ +========================== +Account Compensate Advance +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:4cb5f509627dcbd4a2d3ab029ba91e76dae1e8a391c4f36a95bdcddcca955cd2 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/16.0/account_compensate_advance + :alt: Escodoo/account-addons + +|badge1| |badge2| |badge3| + +The Account Compensate Advance enhances the accounting functionality in Odoo by enabling advanced handling of advances for suppliers and customers. This module streamlines the process of creating, managing, and compensating advances, ensuring accurate financial. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +After installing the module, follow these steps to configure it for the desired company: + +#. Go to Invoice > Configuration > Journals. +#. Select an existing journal or create a new one of type Miscellaneous. +#. In the journal view, click on the Advance Journal tab. +#. Set the journal type to Advance. + +Usage +===== + +To use this module: + +#. Create an account of type "Prepayment" and ensure it is reconciliable. +#. Create or select a Journal that has the flag indicating it is an "Compensation Advance" journal. +#. Create a Product of type "Service," name it "Advance," and mark the options for it to be purchased and sold. Set the expense and revenue accounts according to the account created in the first step. +#. Create an Invoice. +#. Define the Partner and add the product created for the Advance. +#. Post the invoice and complete the payment in full. +#. Identify an Invoice for the same Partner. +#. Select the button to "Compensate Advance" +#. On the left side, choose one of the available advances and on the right side, select the line you wish to settle from the current invoice. +#. After filling in the necessary fields, click Compensate. +#. You will be redirected back to the invoice with the payment status updated to either Partial or Paid, depending on the amount entered. + +Observation: + +#. Please be informed that advance payments cannot be processed outside of the Purchase and Sales Journal (Invoice). Journal entries created as advances will not be considered as they need to be marked as paid, which is not currently tracked within our system. + +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 +~~~~~~~ + +* Escodoo + +Contributors +~~~~~~~~~~~~ + +* `Escodoo `_: + + * Marcel Savegnago + * Kaynnan Lemes + * Douglas Custodio + +Maintainers +~~~~~~~~~~~ + +This module is part of the `Escodoo/account-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/account_compensate_advance/__init__.py b/account_compensate_advance/__init__.py new file mode 100644 index 0000000..9b42961 --- /dev/null +++ b/account_compensate_advance/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizard diff --git a/account_compensate_advance/__manifest__.py b/account_compensate_advance/__manifest__.py new file mode 100644 index 0000000..d9e3752 --- /dev/null +++ b/account_compensate_advance/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2024 - TODAY, Escodoo +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Account Compensate Advance", + "summary": """ + Account Compensate Advance""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Escodoo", + "website": "https://github.com/Escodoo/account-addons", + "depends": ["account"], + "data": [ + "security/ir.model.access.csv", + "views/account_journal.xml", + "views/account_move.xml", + "wizard/account_compensate_advance_journal.xml", + ], +} diff --git a/account_compensate_advance/i18n/account_compensate_advance.pot b/account_compensate_advance/i18n/account_compensate_advance.pot new file mode 100644 index 0000000..70b45b3 --- /dev/null +++ b/account_compensate_advance/i18n/account_compensate_advance.pot @@ -0,0 +1,224 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_compensate_advance +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.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_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.account_compensate_advance_form_view +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.view_account_invoice_filter +msgid "Advance" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__advance_balance +msgid "Advance Balance" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_bank_statement_line__advance_invoice +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move__advance_invoice +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_payment__advance_invoice +msgid "Advance Invoice" +msgstr "" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.account_journal_form_view +msgid "Advance Journal" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__advance_id +msgid "Advance Line" +msgstr "" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/wizard/account_compensate_advance_journal.py:0 +#, python-format +msgid "Advance: %s" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__amount +msgid "Amount" +msgstr "" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/models/account_move_line.py:0 +#, python-format +msgid "Balance" +msgstr "" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.account_compensate_advance_form_view +msgid "Cancel" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,help:account_compensate_advance.field_account_journal__is_advance_journal +msgid "Check this box if this journal is for compensation advances" +msgstr "" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.account_compensate_advance_form_view +msgid "Compensate" +msgstr "" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/models/account_move.py:0 +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.view_move_form +#, python-format +msgid "Compensate Advance" +msgstr "" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.account_compensate_advance_form_view +msgid "Compensate Advance Account" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__date +msgid "Compensation Date" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__journal_id +msgid "Compesation Journal" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__create_uid +msgid "Created by" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__create_date +msgid "Created on" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__currency_id +msgid "Currency" +msgstr "" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/models/account_journal.py:0 +#, python-format +msgid "Customer" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__display_name +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_journal__display_name +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move__display_name +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move_line__display_name +msgid "Display Name" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__id +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_journal__id +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move__id +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move_line__id +msgid "ID" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_journal__is_advance_journal +msgid "Is Compensation Advance Journal" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model,name:account_compensate_advance.model_account_journal +msgid "Journal" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model,name:account_compensate_advance.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model,name:account_compensate_advance.model_account_move_line +msgid "Journal Item" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal____last_update +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_journal____last_update +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move____last_update +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move_line____last_update +msgid "Last Modified on" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__write_date +msgid "Last Updated on" +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__line_id +msgid "Line" +msgstr "" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/models/account_journal.py:0 +#, python-format +msgid "Supplier" +msgstr "" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/wizard/account_compensate_advance_journal.py:0 +#, python-format +msgid "The amount cannot exceed the residual amount of the line." +msgstr "" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/wizard/account_compensate_advance_journal.py:0 +#, python-format +msgid "The amount must be greater than zero." +msgstr "" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/wizard/account_compensate_advance_journal.py:0 +#, python-format +msgid "The entered amount exceeds the balance of the advance selected." +msgstr "" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.account_compensate_advance_form_view +msgid "To Compensate" +msgstr "" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.view_move_form +msgid "" +"You have advances that can be compensate for this customer using the button " +"Compensate Advance." +msgstr "" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.view_move_form +msgid "" +"You have advances that can be compensate for this vendor using the button " +"Compensate Advance." +msgstr "" + +#. module: account_compensate_advance +#: model:ir.model,name:account_compensate_advance.model_account_compensate_advance_journal +msgid "account.compensate.advance.journal" +msgstr "" diff --git a/account_compensate_advance/i18n/pt_BR.po b/account_compensate_advance/i18n/pt_BR.po new file mode 100644 index 0000000..0074794 --- /dev/null +++ b/account_compensate_advance/i18n/pt_BR.po @@ -0,0 +1,230 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_compensate_advance +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-06-21 19:25+0000\n" +"PO-Revision-Date: 2024-06-21 16:28-0300\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Generator: Poedit 3.4.2\n" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.account_compensate_advance_form_view +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.view_account_invoice_filter +msgid "Advance" +msgstr "Adiantamento" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__advance_balance +msgid "Advance Balance" +msgstr "Saldo do Adiantamento" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_bank_statement_line__advance_invoice +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move__advance_invoice +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_payment__advance_invoice +msgid "Advance Invoice" +msgstr "Fatura de Adiantamento" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.account_journal_form_view +msgid "Advance Journal" +msgstr "Diário de Adiantamento" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__advance_id +msgid "Advance Line" +msgstr "Linha de Adiantamento" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/wizard/account_compensate_advance_journal.py:0 +#, python-format +msgid "Advance: %s" +msgstr "Adiantamento: %s" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__amount +msgid "Amount" +msgstr "Quantidade" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/models/account_move_line.py:0 +#, python-format +msgid "Balance" +msgstr "Saldo" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.account_compensate_advance_form_view +msgid "Cancel" +msgstr "Cancelar" + +#. module: account_compensate_advance +#: model:ir.model.fields,help:account_compensate_advance.field_account_journal__is_advance_journal +msgid "Check this box if this journal is for compensation advances" +msgstr "Marque este campo se este diário for para compensação de adiantamentos" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.account_compensate_advance_form_view +msgid "Compensate" +msgstr "Compensar" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/models/account_move.py:0 +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.view_move_form +#, python-format +msgid "Compensate Advance" +msgstr "Compensar Adiantamento" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.account_compensate_advance_form_view +msgid "Compensate Advance Account" +msgstr "Conta para compensar Adiantamento" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__journal_id +msgid "Compesation Journal" +msgstr "Diário de Compensação" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__date +msgid "Compesation Date" +msgstr "Data de Compensação" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__create_uid +msgid "Created by" +msgstr "Criado por" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__create_date +msgid "Created on" +msgstr "Criado em" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__currency_id +msgid "Currency" +msgstr "Moeda" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/models/account_journal.py:0 +#, python-format +msgid "Customer" +msgstr "Cliente" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__display_name +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_journal__display_name +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move__display_name +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move_line__display_name +msgid "Display Name" +msgstr "Nome de exibição" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__id +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_journal__id +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move__id +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move_line__id +msgid "ID" +msgstr "ID" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_journal__is_advance_journal +msgid "Is Compensation Advance Journal" +msgstr "É diário de Compensação de Adiantamento" + +#. module: account_compensate_advance +#: model:ir.model,name:account_compensate_advance.model_account_journal +msgid "Journal" +msgstr "Diário" + +#. module: account_compensate_advance +#: model:ir.model,name:account_compensate_advance.model_account_move +msgid "Journal Entry" +msgstr "Lançamento de diário" + +#. module: account_compensate_advance +#: model:ir.model,name:account_compensate_advance.model_account_move_line +msgid "Journal Item" +msgstr "Item de diário" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal____last_update +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_journal____last_update +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move____last_update +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_move_line____last_update +msgid "Last Modified on" +msgstr "Última modificação em" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__write_uid +msgid "Last Updated by" +msgstr "Última atualização por" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__write_date +msgid "Last Updated on" +msgstr "Última atualização em" + +#. module: account_compensate_advance +#: model:ir.model.fields,field_description:account_compensate_advance.field_account_compensate_advance_journal__line_id +msgid "Line" +msgstr "Linha" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/models/account_journal.py:0 +#, python-format +msgid "Supplier" +msgstr "Fornecedor" + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/wizard/account_compensate_advance_journal.py:0 +#, python-format +msgid "The amount cannot exceed the residual amount of the line." +msgstr "O valor não pode ultrapassar o valor da linha." + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/wizard/account_compensate_advance_journal.py:0 +#, python-format +msgid "The amount must be greater than zero." +msgstr "O valor deve ser maior que zero." + +#. module: account_compensate_advance +#: code:addons/account_compensate_advance/wizard/account_compensate_advance_journal.py:0 +#, python-format +msgid "The entered amount exceeds the balance of the advance selected." +msgstr "O valor informado excede o saldo do adiantamento selecionado." + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.account_compensate_advance_form_view +msgid "To Compensate" +msgstr "Para Compensar" + +#. module: account_compensate_advance +#: model:ir.model,name:account_compensate_advance.model_account_compensate_advance_journal +msgid "account.compensate.advance.journal" +msgstr "" + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.view_move_form +msgid "" +"You have advances that can be compensate for this customer using the button Compensate Advance." +msgstr "" +"Você tem adiantamentos que podem ser compensados ​​para este cliente através do botão Compensar Adiantamento." + +#. module: account_compensate_advance +#: model_terms:ir.ui.view,arch_db:account_compensate_advance.view_move_form +msgid "" +"You have advances that can be compensate for this vendor using the button Compensate Advance." +msgstr "" +"Você tem adiantamentos que podem ser compensados ​​para este fornecedor através do botão Compensar Adiantamento." diff --git a/account_compensate_advance/models/__init__.py b/account_compensate_advance/models/__init__.py new file mode 100644 index 0000000..3279b6f --- /dev/null +++ b/account_compensate_advance/models/__init__.py @@ -0,0 +1,3 @@ +from . import account_move +from . import account_move_line +from . import account_journal diff --git a/account_compensate_advance/models/account_journal.py b/account_compensate_advance/models/account_journal.py new file mode 100644 index 0000000..b1a5ef7 --- /dev/null +++ b/account_compensate_advance/models/account_journal.py @@ -0,0 +1,19 @@ +# Copyright 2024 - TODAY, Kaynnan Lemes +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, fields, models + +ACCOUNT_TYPES = [ + ("supplier", _("Supplier")), + ("customer", _("Customer")), +] + + +class AccountJournal(models.Model): + + _inherit = "account.journal" + + is_advance_journal = fields.Boolean( + string="Is Compensation Advance Journal", + help="Check this box if this journal is for compensation advances", + ) diff --git a/account_compensate_advance/models/account_move.py b/account_compensate_advance/models/account_move.py new file mode 100644 index 0000000..0449a2f --- /dev/null +++ b/account_compensate_advance/models/account_move.py @@ -0,0 +1,55 @@ +# Copyright 2024 - TODAY, Kaynnan Lemes +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +from odoo import _, api, fields, models + + +class AccountMove(models.Model): + + _inherit = "account.move" + advance_invoice = fields.Boolean(compute="_compute_advance_invoice") + + @api.depends( + "payment_state", + "partner_id", + "line_ids", + "line_ids.account_id", + "line_ids.account_id.user_type_id", + "line_ids.amount_residual", + ) + def _compute_advance_invoice(self): + account_type_id = self.env.ref("account.data_account_type_prepayments").id + for record in self: + domain = [ + ("move_id.payment_state", "=", "paid"), + ("partner_id", "=", record.partner_id.id), + ("account_id.user_type_id", "=", account_type_id), + ("account_id.reconcile", "=", True), + ] + if record.move_type == "in_invoice": + domain.append(("amount_residual", ">", 0.0)) + elif record.move_type == "out_invoice": + domain.append(("amount_residual", "<", 0.0)) + + line_ids = self.env["account.move.line"].search(domain) + + if line_ids: + record.advance_invoice = True + else: + record.advance_invoice = False + + def action_compensate_advance(self): + + return { + "name": _("Compensate Advance"), + "res_model": "account.compensate.advance.journal", + "view_mode": "form", + "context": { + "active_model": "account.move", + "active_ids": self.ids, + "default_move_type": self.env.context.get("default_move_type"), + }, + "target": "new", + "type": "ir.actions.act_window", + } diff --git a/account_compensate_advance/models/account_move_line.py b/account_compensate_advance/models/account_move_line.py new file mode 100644 index 0000000..28811cf --- /dev/null +++ b/account_compensate_advance/models/account_move_line.py @@ -0,0 +1,57 @@ +# Copyright 2024 - TODAY, Kaynnan Lemes +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +# flake8: noqa: B950 + +from odoo import _, models +from odoo.tools.misc import formatLang + + +class AccountMoveLine(models.Model): + + _inherit = "account.move.line" + + def name_get(self): + """ + Override the name_get method to customize the display name of records based on the context. + """ + context = self._context or {} + + # Customize name display for 'advance_id' based on context + if "advance_id_name_get" in context and context["advance_id_name_get"]: + result = [] + balance_str = _("Balance") + for rec in self: + total_str = formatLang( + self.env, abs(rec.price_total), currency_obj=rec.currency_id + ) + balance_residual_str = formatLang( + self.env, abs(rec.amount_residual), currency_obj=rec.currency_id + ) + # Format name with localized date, total, and balance + name = ( + f"{rec.name} | " + f"{_('Date')}: {rec.move_id.date.strftime('%x')} | " + f"{_('Total')}: {total_str} | " + f"{balance_str}: {balance_residual_str}" + ) + result.append((rec.id, name)) + return result + + # Customize name display for 'line_id' based on context + if "line_id_name_get" in context and context["line_id_name_get"]: + result = [] + for rec in self: + total_str = formatLang( + self.env, abs(rec.price_total), currency_obj=rec.currency_id + ) + # Format name with localized date and total + name = ( + f"{rec.name or rec.move_id.name} | " + f"{_('Date')}: {rec.date_maturity.strftime('%x')} | " + f"{_('Total')}: {total_str}" + ) + result.append((rec.id, name)) + return result + + # Call super method to get default name display + return super().name_get() diff --git a/account_compensate_advance/readme/CONFIGURE.rst b/account_compensate_advance/readme/CONFIGURE.rst new file mode 100644 index 0000000..76cb1ef --- /dev/null +++ b/account_compensate_advance/readme/CONFIGURE.rst @@ -0,0 +1,6 @@ +After installing the module, follow these steps to configure it for the desired company: + +#. Go to Invoice > Configuration > Journals. +#. Select an existing journal or create a new one of type Miscellaneous. +#. In the journal view, click on the Advance Journal tab. +#. Set the journal type to Advance. diff --git a/account_compensate_advance/readme/CONTRIBUTORS.rst b/account_compensate_advance/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..77968e7 --- /dev/null +++ b/account_compensate_advance/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* `Escodoo `_: + + * Marcel Savegnago + * Kaynnan Lemes + * Douglas Custodio diff --git a/account_compensate_advance/readme/DESCRIPTION.rst b/account_compensate_advance/readme/DESCRIPTION.rst new file mode 100644 index 0000000..ae3fb69 --- /dev/null +++ b/account_compensate_advance/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +The Account Compensate Advance enhances the accounting functionality in Odoo by enabling advanced handling of advances for suppliers and customers. This module streamlines the process of creating, managing, and compensating advances, ensuring accurate financial. diff --git a/account_compensate_advance/readme/USAGE.rst b/account_compensate_advance/readme/USAGE.rst new file mode 100644 index 0000000..0ccf762 --- /dev/null +++ b/account_compensate_advance/readme/USAGE.rst @@ -0,0 +1,17 @@ +To use this module: + +#. Create an account of type "Prepayment" and ensure it is reconciliable. +#. Create or select a Journal that has the flag indicating it is an "Compensation Advance" journal. +#. Create a Product of type "Service," name it "Advance," and mark the options for it to be purchased and sold. Set the expense and revenue accounts according to the account created in the first step. +#. Create an Invoice. +#. Define the Partner and add the product created for the Advance. +#. Post the invoice and complete the payment in full. +#. Identify an Invoice for the same Partner. +#. Select the button to "Compensate Advance" +#. On the left side, choose one of the available advances and on the right side, select the line you wish to settle from the current invoice. +#. After filling in the necessary fields, click Compensate. +#. You will be redirected back to the invoice with the payment status updated to either Partial or Paid, depending on the amount entered. + +Observation: + +#. Please be informed that advance payments cannot be processed outside of the Purchase and Sales Journal (Invoice). Journal entries created as advances will not be considered as they need to be marked as paid, which is not currently tracked within our system. diff --git a/account_compensate_advance/security/ir.model.access.csv b/account_compensate_advance/security/ir.model.access.csv new file mode 100644 index 0000000..5f33beb --- /dev/null +++ b/account_compensate_advance/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_account_compensate_advance,account.compensate.advance.journal,model_account_compensate_advance_journal,account.group_account_invoice,1,1,1,1 diff --git a/account_compensate_advance/static/description/icon.png b/account_compensate_advance/static/description/icon.png new file mode 100644 index 0000000..12ab005 Binary files /dev/null and b/account_compensate_advance/static/description/icon.png differ diff --git a/account_compensate_advance/static/description/index.html b/account_compensate_advance/static/description/index.html new file mode 100644 index 0000000..8ce448a --- /dev/null +++ b/account_compensate_advance/static/description/index.html @@ -0,0 +1,454 @@ + + + + + +Account Compensate Advance + + + +
+

Account Compensate Advance

+ + +

Beta License: AGPL-3 Escodoo/account-addons

+

The Account Compensate Advance enhances the accounting functionality in Odoo by enabling advanced handling of advances for suppliers and customers. This module streamlines the process of creating, managing, and compensating advances, ensuring accurate financial.

+

Table of contents

+ +
+

Configuration

+

After installing the module, follow these steps to configure it for the desired company:

+
    +
  1. Go to Invoice > Configuration > Journals.
  2. +
  3. Select an existing journal or create a new one of type Miscellaneous.
  4. +
  5. In the journal view, click on the Advance Journal tab.
  6. +
  7. Set the journal type to Advance.
  8. +
+
+
+

Usage

+

To use this module:

+
    +
  1. Create an account of type “Prepayment” and ensure it is reconciliable.
  2. +
  3. Create or select a Journal that has the flag indicating it is an “Compensation Advance” journal.
  4. +
  5. Create a Product of type “Service,” name it “Advance,” and mark the options for it to be purchased and sold. Set the expense and revenue accounts according to the account created in the first step.
  6. +
  7. Create an Invoice.
  8. +
  9. Define the Partner and add the product created for the Advance.
  10. +
  11. Post the invoice and complete the payment in full.
  12. +
  13. Identify an Invoice for the same Partner.
  14. +
  15. Select the button to “Compensate Advance”
  16. +
  17. On the left side, choose one of the available advances and on the right side, select the line you wish to settle from the current invoice.
  18. +
  19. After filling in the necessary fields, click Compensate.
  20. +
  21. You will be redirected back to the invoice with the payment status updated to either Partial or Paid, depending on the amount entered.
  22. +
+

Observation:

+
    +
  1. Please be informed that advance payments cannot be processed outside of the Purchase and Sales Journal (Invoice). Journal entries created as advances will not be considered as they need to be marked as paid, which is not currently tracked within our system.
  2. +
+
+
+

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

+
    +
  • Escodoo
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

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

+

You are welcome to contribute.

+
+
+
+ + diff --git a/account_compensate_advance/views/account_journal.xml b/account_compensate_advance/views/account_journal.xml new file mode 100644 index 0000000..83d0ed9 --- /dev/null +++ b/account_compensate_advance/views/account_journal.xml @@ -0,0 +1,28 @@ + + + + + + + account.journal.form (in account_compensate_advance) + account.journal + + + + + + + + + + + + + + + diff --git a/account_compensate_advance/views/account_move.xml b/account_compensate_advance/views/account_move.xml new file mode 100644 index 0000000..4e48bf9 --- /dev/null +++ b/account_compensate_advance/views/account_move.xml @@ -0,0 +1,69 @@ + + + + + + + account.move.form in (account_compensate_advance) + account.move + + + + + + +