diff --git a/account_invoice_overdue_warn/README.rst b/account_invoice_overdue_warn/README.rst new file mode 100644 index 000000000..4de77d07b --- /dev/null +++ b/account_invoice_overdue_warn/README.rst @@ -0,0 +1,108 @@ +=========================== +Warning on Overdue Invoices +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9721666b84a4f901d5ba4eaf9c3f772184465a5038f096680169f512f9c2a5b1 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcredit--control-lightgray.png?logo=github + :target: https://github.com/OCA/credit-control/tree/17.0/account_invoice_overdue_warn + :alt: OCA/credit-control +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/credit-control-17-0/credit-control-17-0-account_invoice_overdue_warn + :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/credit-control&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a warning banner on the customer form view when it has +overdue invoices. The banner informs the user about the number of +overdue invoices and the total overdue amount. It contains a link to see +the corresponding overdue invoices. + +|image1| + +If you also install the module *account_invoice_overdue_warn_sale*, you +will have the same banner on the form view of quotations and sale +orders. + +Implementation details: + +- in a multi-company configuration, the overdue invoices taken into + account are the invoices of the company of the partner, or, if the + partner is not attached to a company, in the current company. +- the overdue amount is in the company currency. +- the overdue banner is displayed on the parent partner and also all + its contacts. The overdue invoices taken into account are all the + overdue invoices of the parent partners and all its contacts. + +.. |image1| image:: https://raw.githubusercontent.com/OCA/credit-control/17.0/account_invoice_overdue_warn/static/description/partner_overdue_invoice_warn.png + +**Table of contents** + +.. contents:: + :local: + +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 +------- + +* Akretion + +Contributors +------------ + +- Alexis de Lattre +- `Sygel `__: + + - Valentín Vinagre + +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. + +.. |maintainer-alexis-via| image:: https://github.com/alexis-via.png?size=40px + :target: https://github.com/alexis-via + :alt: alexis-via + +Current `maintainer `__: + +|maintainer-alexis-via| + +This module is part of the `OCA/credit-control `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_invoice_overdue_warn/__init__.py b/account_invoice_overdue_warn/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/account_invoice_overdue_warn/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_invoice_overdue_warn/__manifest__.py b/account_invoice_overdue_warn/__manifest__.py new file mode 100644 index 000000000..6fd221c5c --- /dev/null +++ b/account_invoice_overdue_warn/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2021 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Warning on Overdue Invoices", + "version": "17.0.1.0.0", + "category": "Sales", + "license": "AGPL-3", + "summary": "Show warning on customer form view if it has overdue invoices", + "author": "Akretion,Odoo Community Association (OCA)", + "maintainers": ["alexis-via"], + "website": "https://github.com/OCA/credit-control", + "depends": ["account"], + "data": [ + "views/res_partner.xml", + ], + "installable": True, +} diff --git a/account_invoice_overdue_warn/i18n/account_invoice_overdue_warn.pot b/account_invoice_overdue_warn/i18n/account_invoice_overdue_warn.pot new file mode 100644 index 000000000..867c05e99 --- /dev/null +++ b/account_invoice_overdue_warn/i18n/account_invoice_overdue_warn.pot @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_overdue_warn +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_invoice_overdue_warn +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_partner__overdue_invoice_count +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_users__overdue_invoice_count +msgid "# of Overdue Invoices" +msgstr "" + +#. module: account_invoice_overdue_warn +#: model:ir.model,name:account_invoice_overdue_warn.model_res_partner +msgid "Contact" +msgstr "" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_partner__overdue_invoice_amount +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_users__overdue_invoice_amount +msgid "Overdue Invoices Residual" +msgstr "" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,help:account_invoice_overdue_warn.field_res_partner__overdue_invoice_amount +#: model:ir.model.fields,help:account_invoice_overdue_warn.field_res_users__overdue_invoice_amount +msgid "Overdue invoice total residual amount in company currency." +msgstr "" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "This customer has" +msgstr "" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "for a total residual of" +msgstr "" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "overdue invoice(s)" +msgstr "" diff --git a/account_invoice_overdue_warn/i18n/ca.po b/account_invoice_overdue_warn/i18n/ca.po new file mode 100644 index 000000000..85dc97d2e --- /dev/null +++ b/account_invoice_overdue_warn/i18n/ca.po @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_overdue_warn +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: ca\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" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_partner__overdue_invoice_count +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_users__overdue_invoice_count +msgid "# of Overdue Invoices" +msgstr "" + +#. module: account_invoice_overdue_warn +#: model:ir.model,name:account_invoice_overdue_warn.model_res_partner +msgid "Contact" +msgstr "" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_partner__overdue_invoice_amount +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_users__overdue_invoice_amount +msgid "Overdue Invoices Residual" +msgstr "" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,help:account_invoice_overdue_warn.field_res_partner__overdue_invoice_amount +#: model:ir.model.fields,help:account_invoice_overdue_warn.field_res_users__overdue_invoice_amount +msgid "Overdue invoice total residual amount in company currency." +msgstr "" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "This customer has" +msgstr "" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "for a total residual of" +msgstr "" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "overdue invoice(s)" +msgstr "" diff --git a/account_invoice_overdue_warn/i18n/es.po b/account_invoice_overdue_warn/i18n/es.po new file mode 100644 index 000000000..539c55a58 --- /dev/null +++ b/account_invoice_overdue_warn/i18n/es.po @@ -0,0 +1,65 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_overdue_warn +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-19 15:06+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_invoice_overdue_warn +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_partner__overdue_invoice_count +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_users__overdue_invoice_count +msgid "# of Overdue Invoices" +msgstr "# de Facturas Atrasadas" + +#. module: account_invoice_overdue_warn +#: model:ir.model,name:account_invoice_overdue_warn.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_partner__overdue_invoice_amount +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_users__overdue_invoice_amount +msgid "Overdue Invoices Residual" +msgstr "Residual de Facturas Vencidas" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,help:account_invoice_overdue_warn.field_res_partner__overdue_invoice_amount +#: model:ir.model.fields,help:account_invoice_overdue_warn.field_res_users__overdue_invoice_amount +msgid "Overdue invoice total residual amount in company currency." +msgstr "" +"Importe residual total de la factura vencida en la moneda de la empresa." + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "This customer has" +msgstr "Este cliente tiene" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "for a total residual of" +msgstr "para un residuo total de" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "overdue invoice(s)" +msgstr "factura(s) vencida(s)" + +#~ msgid "Display Name" +#~ msgstr "Mostrar Nombre" + +#~ msgid "ID" +#~ msgstr "ID (Identificación)" + +#~ msgid "Last Modified on" +#~ msgstr "Última Modificación el" diff --git a/account_invoice_overdue_warn/i18n/fr.po b/account_invoice_overdue_warn/i18n/fr.po new file mode 100644 index 000000000..9335be44e --- /dev/null +++ b/account_invoice_overdue_warn/i18n/fr.po @@ -0,0 +1,66 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_overdue_warn +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-08-28 16:49+0000\n" +"PO-Revision-Date: 2024-03-02 14:37+0000\n" +"Last-Translator: Alexis de Lattre \n" +"Language-Team: \n" +"Language: fr\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_invoice_overdue_warn +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_partner__overdue_invoice_count +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_users__overdue_invoice_count +msgid "# of Overdue Invoices" +msgstr "Nb de factures échues impayées" + +#. module: account_invoice_overdue_warn +#: model:ir.model,name:account_invoice_overdue_warn.model_res_partner +msgid "Contact" +msgstr "Contact" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_partner__overdue_invoice_amount +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_users__overdue_invoice_amount +msgid "Overdue Invoices Residual" +msgstr "Solde des factures échues impayées" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,help:account_invoice_overdue_warn.field_res_partner__overdue_invoice_amount +#: model:ir.model.fields,help:account_invoice_overdue_warn.field_res_users__overdue_invoice_amount +msgid "Overdue invoice total residual amount in company currency." +msgstr "" +"Total des montants impayés des factures échues dans la devise de la société." + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "This customer has" +msgstr "Ce client a" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "for a total residual of" +msgstr "pour un montant impayé de" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "overdue invoice(s)" +msgstr "facture(s) échue(s) impayées(s)" + +#~ msgid "Display Name" +#~ msgstr "Nom affiché" + +#~ msgid "ID" +#~ msgstr "ID" + +#~ msgid "Last Modified on" +#~ msgstr "Dernière modification le" diff --git a/account_invoice_overdue_warn/i18n/it.po b/account_invoice_overdue_warn/i18n/it.po new file mode 100644 index 000000000..8568b91ac --- /dev/null +++ b/account_invoice_overdue_warn/i18n/it.po @@ -0,0 +1,55 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_overdue_warn +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-04-19 10:37+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\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_invoice_overdue_warn +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_partner__overdue_invoice_count +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_users__overdue_invoice_count +msgid "# of Overdue Invoices" +msgstr "N° di fatture scadute" + +#. module: account_invoice_overdue_warn +#: model:ir.model,name:account_invoice_overdue_warn.model_res_partner +msgid "Contact" +msgstr "Contatto" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_partner__overdue_invoice_amount +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_users__overdue_invoice_amount +msgid "Overdue Invoices Residual" +msgstr "Residuo fatture scadute" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,help:account_invoice_overdue_warn.field_res_partner__overdue_invoice_amount +#: model:ir.model.fields,help:account_invoice_overdue_warn.field_res_users__overdue_invoice_amount +msgid "Overdue invoice total residual amount in company currency." +msgstr "Valore totale residuo fatture scadute nella valuta azienda." + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "This customer has" +msgstr "Questo cliente ha" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "for a total residual of" +msgstr "per un totale residuo di" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "overdue invoice(s)" +msgstr "fatture scadute" diff --git a/account_invoice_overdue_warn/i18n/pt_BR.po b/account_invoice_overdue_warn/i18n/pt_BR.po new file mode 100644 index 000000000..0bbe3f0ae --- /dev/null +++ b/account_invoice_overdue_warn/i18n/pt_BR.po @@ -0,0 +1,61 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_invoice_overdue_warn +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-10-26 13:49+0000\n" +"Last-Translator: felipemotter \n" +"Language-Team: none\n" +"Language: pt_BR\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_invoice_overdue_warn +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_partner__overdue_invoice_count +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_users__overdue_invoice_count +msgid "# of Overdue Invoices" +msgstr "Nº de Faturas Vencidas" + +#. module: account_invoice_overdue_warn +#: model:ir.model,name:account_invoice_overdue_warn.model_res_partner +msgid "Contact" +msgstr "Contato" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_partner__overdue_invoice_amount +#: model:ir.model.fields,field_description:account_invoice_overdue_warn.field_res_users__overdue_invoice_amount +msgid "Overdue Invoices Residual" +msgstr "Residual de Faturas Vencidas" + +#. module: account_invoice_overdue_warn +#: model:ir.model.fields,help:account_invoice_overdue_warn.field_res_partner__overdue_invoice_amount +#: model:ir.model.fields,help:account_invoice_overdue_warn.field_res_users__overdue_invoice_amount +msgid "Overdue invoice total residual amount in company currency." +msgstr "Valor residual total da fatura vencida na moeda da empresa." + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "This customer has" +msgstr "Este cliente tem" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "for a total residual of" +msgstr "para um resíduo total de" + +#. module: account_invoice_overdue_warn +#: model_terms:ir.ui.view,arch_db:account_invoice_overdue_warn.view_partner_form_overdue_warn +msgid "overdue invoice(s)" +msgstr "fatura(s) vencida(s)" + +#~ msgid "Display Name" +#~ msgstr "Nome de Exibição" + +#~ msgid "Last Modified on" +#~ msgstr "Última Modificação Em" diff --git a/account_invoice_overdue_warn/models/__init__.py b/account_invoice_overdue_warn/models/__init__.py new file mode 100644 index 000000000..91fed54d4 --- /dev/null +++ b/account_invoice_overdue_warn/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner diff --git a/account_invoice_overdue_warn/models/res_partner.py b/account_invoice_overdue_warn/models/res_partner.py new file mode 100644 index 000000000..af9f00d0d --- /dev/null +++ b/account_invoice_overdue_warn/models/res_partner.py @@ -0,0 +1,84 @@ +# Copyright 2021 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + overdue_invoice_count = fields.Integer( + compute="_compute_overdue_invoice_count_amount", + string="# of Overdue Invoices", + compute_sudo=True, + ) + # the currency_id field on res.partner = + # partner.company_id.currency_id or self.env.company.cueency_id + overdue_invoice_amount = fields.Monetary( + compute="_compute_overdue_invoice_count_amount", + string="Overdue Invoices Residual", + compute_sudo=True, + help="Overdue invoice total residual amount in company currency.", + ) + + def _compute_overdue_invoice_count_amount(self): + for partner in self: + company_id = partner.company_id.id or partner.env.company.id + ( + count, + amount_company_currency, + ) = partner._prepare_overdue_invoice_count_amount(company_id) + partner.overdue_invoice_count = count + partner.overdue_invoice_amount = amount_company_currency + + def _prepare_overdue_invoice_count_amount(self, company_id): + # This method is also called by the module + # account_invoice_overdue_warn_sale where the company_id arg is used + self.ensure_one() + domain = self._prepare_overdue_invoice_domain(company_id) + # amount_residual_signed is in company currency + rg_res = self.env["account.move"].read_group( + domain, ["amount_residual_signed"], [] + ) + count = 0 + overdue_invoice_amount = 0.0 + if rg_res: + count = rg_res[0]["__count"] + overdue_invoice_amount = rg_res[0]["amount_residual_signed"] + return (count, overdue_invoice_amount) + + def _prepare_overdue_invoice_domain(self, company_id): + # The use of commercial_partner_id is in this method + self.ensure_one() + today = fields.Date.context_today(self) + if company_id is None: + company_id = self.env.company.id + domain = [ + ("move_type", "=", "out_invoice"), + ("company_id", "=", company_id), + ("commercial_partner_id", "=", self.commercial_partner_id.id), + ("invoice_date_due", "<", today), + ("state", "=", "posted"), + ("payment_state", "in", ("not_paid", "partial")), + ] + return domain + + def _prepare_jump_to_overdue_invoices(self, company_id): + action = self.env["ir.actions.actions"]._for_xml_id( + "account.action_move_out_invoice_type" + ) + action["domain"] = self._prepare_overdue_invoice_domain(company_id) + action["context"] = { + "journal_type": "sale", + "move_type": "out_invoice", + "default_move_type": "out_invoice", + "default_partner_id": self.id, + } + return action + + def jump_to_overdue_invoices(self): + self.ensure_one() + company_id = self.company_id.id or self.env.company.id + action = self._prepare_jump_to_overdue_invoices(company_id) + return action diff --git a/account_invoice_overdue_warn/pyproject.toml b/account_invoice_overdue_warn/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/account_invoice_overdue_warn/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/account_invoice_overdue_warn/readme/CONTRIBUTORS.md b/account_invoice_overdue_warn/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..02fca3078 --- /dev/null +++ b/account_invoice_overdue_warn/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Alexis de Lattre \<\> +- [Sygel](https://sygel.es): + - Valentín Vinagre \<\> diff --git a/account_invoice_overdue_warn/readme/DESCRIPTION.md b/account_invoice_overdue_warn/readme/DESCRIPTION.md new file mode 100644 index 000000000..79dea20dc --- /dev/null +++ b/account_invoice_overdue_warn/readme/DESCRIPTION.md @@ -0,0 +1,20 @@ +This module adds a warning banner on the customer form view when it has +overdue invoices. The banner informs the user about the number of +overdue invoices and the total overdue amount. It contains a link to see +the corresponding overdue invoices. + +![](static/description/partner_overdue_invoice_warn.png) + +If you also install the module *account_invoice_overdue_warn_sale*, you +will have the same banner on the form view of quotations and sale +orders. + +Implementation details: + +- in a multi-company configuration, the overdue invoices taken into + account are the invoices of the company of the partner, or, if the + partner is not attached to a company, in the current company. +- the overdue amount is in the company currency. +- the overdue banner is displayed on the parent partner and also all its + contacts. The overdue invoices taken into account are all the overdue + invoices of the parent partners and all its contacts. diff --git a/account_invoice_overdue_warn/static/description/icon.png b/account_invoice_overdue_warn/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_invoice_overdue_warn/static/description/icon.png differ diff --git a/account_invoice_overdue_warn/static/description/index.html b/account_invoice_overdue_warn/static/description/index.html new file mode 100644 index 000000000..09fbb86ad --- /dev/null +++ b/account_invoice_overdue_warn/static/description/index.html @@ -0,0 +1,446 @@ + + + + + +Warning on Overdue Invoices + + + +
+

Warning on Overdue Invoices

+ + +

Beta License: AGPL-3 OCA/credit-control Translate me on Weblate Try me on Runboat

+

This module adds a warning banner on the customer form view when it has +overdue invoices. The banner informs the user about the number of +overdue invoices and the total overdue amount. It contains a link to see +the corresponding overdue invoices.

+

image1

+

If you also install the module account_invoice_overdue_warn_sale, you +will have the same banner on the form view of quotations and sale +orders.

+

Implementation details:

+
    +
  • in a multi-company configuration, the overdue invoices taken into +account are the invoices of the company of the partner, or, if the +partner is not attached to a company, in the current company.
  • +
  • the overdue amount is in the company currency.
  • +
  • the overdue banner is displayed on the parent partner and also all +its contacts. The overdue invoices taken into account are all the +overdue invoices of the parent partners and all its contacts.
  • +
+

Table of contents

+ +
+

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

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

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.

+

Current maintainer:

+

alexis-via

+

This module is part of the OCA/credit-control project on GitHub.

+

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

+
+
+
+ + diff --git a/account_invoice_overdue_warn/static/description/partner_overdue_invoice_warn.png b/account_invoice_overdue_warn/static/description/partner_overdue_invoice_warn.png new file mode 100644 index 000000000..cc6765b59 Binary files /dev/null and b/account_invoice_overdue_warn/static/description/partner_overdue_invoice_warn.png differ diff --git a/account_invoice_overdue_warn/tests/__init__.py b/account_invoice_overdue_warn/tests/__init__.py new file mode 100644 index 000000000..365cd2464 --- /dev/null +++ b/account_invoice_overdue_warn/tests/__init__.py @@ -0,0 +1 @@ +from . import test_overdue_warn diff --git a/account_invoice_overdue_warn/tests/test_overdue_warn.py b/account_invoice_overdue_warn/tests/test_overdue_warn.py new file mode 100644 index 000000000..7d782b9af --- /dev/null +++ b/account_invoice_overdue_warn/tests/test_overdue_warn.py @@ -0,0 +1,84 @@ +# Copyright 2021 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from datetime import datetime, timedelta + +from odoo.tests import tagged +from odoo.tests.common import TransactionCase + + +@tagged("post_install", "-at_install") +class TestOverdueWarn(TransactionCase): + def setUp(self): + super().setUp() + self.company = self.env.ref("base.main_company") + self.bad_payer = self.env["res.partner"].create( + { + "name": "Bad payer", + "country_id": self.env.ref("base.fr").id, + "company_id": self.company.id, + } + ) + today = datetime.now().date() + acc = self.env["account.account"].search( + [ + ("company_id", "=", self.company.id), + ("account_type", "=", "income"), + ], + limit=1, + ) + self.out_invoice1 = self.env["account.move"].create( + { + "partner_id": self.bad_payer.id, + "move_type": "out_invoice", + "company_id": self.company.id, + "currency_id": self.company.currency_id.id, + "invoice_date": today - timedelta(days=5), + "invoice_date_due": today - timedelta(days=5), + "invoice_line_ids": [ + ( + 0, + 0, + { + "name": "test line", + "display_type": "product", + "price_unit": 500, + "quantity": 1, + "account_id": acc.id, + "tax_ids": [], + }, + ) + ], + } + ) + self.out_invoice1.action_post() + self.out_invoice2 = self.env["account.move"].create( + { + "partner_id": self.bad_payer.id, + "move_type": "out_invoice", + "company_id": self.company.id, + "currency_id": self.company.currency_id.id, + "invoice_date": datetime.now().date(), + "invoice_date_due": today + timedelta(days=30), + "invoice_line_ids": [ + ( + 0, + 0, + { + "name": "test line", + "display_type": "product", + "price_unit": 1000, + "quantity": 1, + "account_id": acc.id, + "tax_ids": [], + }, + ) + ], + } + ) + self.out_invoice2.action_post() + + def test_overdue_warn(self): + self.assertEqual(self.bad_payer.overdue_invoice_count, 1) + self.assertEqual(self.bad_payer.overdue_invoice_amount, 500) diff --git a/account_invoice_overdue_warn/views/res_partner.xml b/account_invoice_overdue_warn/views/res_partner.xml new file mode 100644 index 000000000..a2fef8d94 --- /dev/null +++ b/account_invoice_overdue_warn/views/res_partner.xml @@ -0,0 +1,26 @@ + + + + + res.partner + + +
+ +
+
+
+ +