diff --git a/edi_account_oca/README.rst b/edi_account_oca/README.rst new file mode 100644 index 000000000..d8f9b3f4a --- /dev/null +++ b/edi_account_oca/README.rst @@ -0,0 +1,105 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================= +Account Listeners +================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9c622b5f50e49edfdafbe10326f54e8154153ab55e2d0734a2a4cd1672659d4b + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi--framework-lightgray.png?logo=github + :target: https://github.com/OCA/edi-framework/tree/19.0/edi_account_oca + :alt: OCA/edi-framework +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/edi-framework-19-0/edi-framework-19-0-edi_account_oca + :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/edi-framework&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +In order to add a new integration for an account, you need to create a +listener: + +.. code:: python + + class MyEventListener(Component): + _name = "account.move.event.listener.demo" + _inherit = "base.event.listener" + _apply_on = ["account.move"] + + def on_post_account_move(self, move): + """Add your code here about creation of record""" + +A skip if decorator can be added in order to make some checks on the +state of the move + +**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 +------- + +* Dixmit + +Contributors +------------ + +- Enric Tobella +- [APSL-Nagarro](https://apsl.tech): + + - Antoni Marroig + +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-etobella| image:: https://github.com/etobella.png?size=40px + :target: https://github.com/etobella + :alt: etobella + +Current `maintainer `__: + +|maintainer-etobella| + +This module is part of the `OCA/edi-framework `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/edi_account_oca/__init__.py b/edi_account_oca/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/edi_account_oca/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/edi_account_oca/__manifest__.py b/edi_account_oca/__manifest__.py new file mode 100644 index 000000000..dde8a1709 --- /dev/null +++ b/edi_account_oca/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2020 Dixmit +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +{ + "name": "Account Listeners", + "summary": """ + Define some component listeners for Account Moves""", + "version": "19.0.1.0.0", + "license": "LGPL-3", + "author": "Dixmit,Odoo Community Association (OCA)", + "maintainers": ["etobella"], + "development_status": "Beta", + "website": "https://github.com/OCA/edi-framework", + "depends": ["edi_account_core_oca", "component_event"], + "data": [], + "demo": [], +} diff --git a/edi_account_oca/i18n/edi_account.pot b/edi_account_oca/i18n/edi_account.pot new file mode 100644 index 000000000..938887ab6 --- /dev/null +++ b/edi_account_oca/i18n/edi_account.pot @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * edi_account +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.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: edi_account +#: model_terms:ir.ui.view,arch_db:edi_account.account_move_form_view +msgid "EDI" +msgstr "" + +#. module: edi_account +#: model_terms:ir.ui.view,arch_db:edi_account.view_account_journal_form +#: model_terms:ir.ui.view,arch_db:edi_account.view_partner_form +msgid "EDI Configuration" +msgstr "" + +#. module: edi_account +#: model:ir.model,name:edi_account.model_account_move +msgid "Journal Entries" +msgstr "" diff --git a/edi_account_oca/i18n/edi_account_oca.pot b/edi_account_oca/i18n/edi_account_oca.pot new file mode 100644 index 000000000..e88ef45c6 --- /dev/null +++ b/edi_account_oca/i18n/edi_account_oca.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * edi_account_oca +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: edi_account_oca +#: model:ir.model,name:edi_account_oca.model_account_move +msgid "Journal Entry" +msgstr "" diff --git a/edi_account_oca/i18n/fr.po b/edi_account_oca/i18n/fr.po new file mode 100644 index 000000000..18420acf2 --- /dev/null +++ b/edi_account_oca/i18n/fr.po @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * edi_account_oca +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-06-17 15:48+0000\n" +"Last-Translator: Yves Le Doeuff \n" +"Language-Team: none\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.3.2\n" + +#. module: edi_account_oca +#: model:ir.model,name:edi_account_oca.model_account_move +msgid "Journal Entry" +msgstr "" + +#~ msgid "Display Name" +#~ msgstr "Nom affiché" diff --git a/edi_account_oca/i18n/it.po b/edi_account_oca/i18n/it.po new file mode 100644 index 000000000..336cdd86d --- /dev/null +++ b/edi_account_oca/i18n/it.po @@ -0,0 +1,76 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * edi_account_oca +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-09-15 08:42+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 5.10.4\n" + +#. module: edi_account_oca +#: model:ir.model,name:edi_account_oca.model_account_move +msgid "Journal Entry" +msgstr "Registrazione contabile" + +#~ msgid "EDI" +#~ msgstr "EDI" + +#~ msgid "Account Moves Exchange Record" +#~ msgstr "Recod scambio movimenti conto" + +#~ msgid "Disable auto" +#~ msgstr "Disabilita automatico" + +#~ msgid "EDI Configuration" +#~ msgstr "Configurazione EDI" + +#~ msgid "EDI origin endpoint" +#~ msgstr "Endpoint origine EDI" + +#~ msgid "EDI origin exchange type" +#~ msgstr "Tipo scambio origine EDI" + +#~ msgid "EDI origin record" +#~ msgstr "Record origine EDI" + +#~ msgid "EDI record that originated this document." +#~ msgstr "Record EDI che ha generato questo documento." + +#~ msgid "Edi Config" +#~ msgstr "Configurazione EDI" + +#~ msgid "Edi Has Form Config" +#~ msgstr "EDI ha una maschera di configurazione" + +#~ msgid "Electronic Data Interchange" +#~ msgstr "Scambio Dati Elettronico" + +#~ msgid "Exchange Record" +#~ msgstr "Record di scambio" + +#~ msgid "Exchange Record Count" +#~ msgstr "Conteggio record di scambio" + +#~ msgid "Exchange Related Record" +#~ msgstr "Record relativo allo scambio" + +#~ msgid "Exchange records" +#~ msgstr "Record di scambio" + +#~ msgid "Moves" +#~ msgstr "Movimenti" + +#~ msgid "Record generated via this endpoint" +#~ msgstr "Record generato attraverso questo endpoint" + +#~ msgid "When marked, EDI automatic processing will be avoided" +#~ msgstr "Quando selezionata, l'elaborazione EDI automatica verrà evitata" diff --git a/edi_account_oca/models/__init__.py b/edi_account_oca/models/__init__.py new file mode 100644 index 000000000..9c0a42138 --- /dev/null +++ b/edi_account_oca/models/__init__.py @@ -0,0 +1 @@ +from . import account_move diff --git a/edi_account_oca/models/account_move.py b/edi_account_oca/models/account_move.py new file mode 100644 index 000000000..d359978f4 --- /dev/null +++ b/edi_account_oca/models/account_move.py @@ -0,0 +1,30 @@ +# Copyright 2020 Dixmit +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import models + + +class AccountMove(models.Model): + _inherit = "account.move" + + def _post(self, soft=True): + result = super()._post(soft=soft) + # We will use this event to know which documents needs to be executed + if self: + self._event("on_post_account_move").notify(self) + return result + + def button_cancel(self): + """This could be used to notify our provider that we are not accepting the + invoice""" + result = super().button_cancel() + if self: + self._event("on_cancel_account_move").notify(self) + return result + + def _invoice_paid_hook(self): + """This could be used to notify our provider that we are paying""" + result = super()._invoice_paid_hook() + if self: + self._event("on_paid_account_move").notify(self) + return result diff --git a/edi_account_oca/pyproject.toml b/edi_account_oca/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/edi_account_oca/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/edi_account_oca/readme/CONTRIBUTORS.md b/edi_account_oca/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..0f141e1e4 --- /dev/null +++ b/edi_account_oca/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Enric Tobella \<\> +- \[APSL-Nagarro\](): + - Antoni Marroig \<\> \ No newline at end of file diff --git a/edi_account_oca/readme/DESCRIPTION.md b/edi_account_oca/readme/DESCRIPTION.md new file mode 100644 index 000000000..bab6513c8 --- /dev/null +++ b/edi_account_oca/readme/DESCRIPTION.md @@ -0,0 +1,15 @@ +In order to add a new integration for an account, you need to create a +listener: + +``` python +class MyEventListener(Component): + _name = "account.move.event.listener.demo" + _inherit = "base.event.listener" + _apply_on = ["account.move"] + + def on_post_account_move(self, move): + """Add your code here about creation of record""" +``` + +A skip if decorator can be added in order to make some checks on the +state of the move diff --git a/edi_account_oca/static/description/icon.png b/edi_account_oca/static/description/icon.png new file mode 100644 index 000000000..a79752645 Binary files /dev/null and b/edi_account_oca/static/description/icon.png differ diff --git a/edi_account_oca/static/description/index.html b/edi_account_oca/static/description/index.html new file mode 100644 index 000000000..a249416c4 --- /dev/null +++ b/edi_account_oca/static/description/index.html @@ -0,0 +1,447 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Account Listeners

+ +

Beta License: LGPL-3 OCA/edi-framework Translate me on Weblate Try me on Runboat

+

In order to add a new integration for an account, you need to create a +listener:

+
+class MyEventListener(Component):
+    _name = "account.move.event.listener.demo"
+    _inherit = "base.event.listener"
+    _apply_on = ["account.move"]
+
+    def on_post_account_move(self, move):
+        """Add your code here about creation of record"""
+
+

A skip if decorator can be added in order to make some checks on the +state of the move

+

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

+
    +
  • Dixmit
  • +
+
+
+

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:

+

etobella

+

This module is part of the OCA/edi-framework project on GitHub.

+

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

+
+
+
+
+ + diff --git a/edi_account_oca/tests/__init__.py b/edi_account_oca/tests/__init__.py new file mode 100644 index 000000000..25aeb70b8 --- /dev/null +++ b/edi_account_oca/tests/__init__.py @@ -0,0 +1 @@ +from . import test_edi diff --git a/edi_account_oca/tests/test_edi.py b/edi_account_oca/tests/test_edi.py new file mode 100644 index 000000000..69b72c75e --- /dev/null +++ b/edi_account_oca/tests/test_edi.py @@ -0,0 +1,104 @@ +# Copyright 2020 Dixmit +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +import logging + +from odoo import fields +from odoo.tests.common import tagged + +from odoo.addons.account.tests.common import AccountTestInvoicingCommon +from odoo.addons.component.core import Component +from odoo.addons.component.tests.common import TransactionComponentRegistryCase + +_logger = logging.getLogger(__name__) + + +@tagged("-at_install", "post_install") +class EDIBackendTestCase(AccountTestInvoicingCommon, TransactionComponentRegistryCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls._setup_registry(cls) + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + + class AccountMoveEventListenerDemo(Component): + _name = "account.move.event.listener.demo" + _inherit = "base.event.listener" + + def on_post_account_move(self, move): + move.name = "new_name" + + def on_paid_account_move(self, move): + move.name = "paid" + + def on_cancel_account_move(self, move): + move.name = "cancelled" + + AccountMoveEventListenerDemo._build_component(cls.comp_registry) + cls.comp_registry._cache.clear() + cls.test_move = ( + cls.env["account.move"] + .with_context(components_registry=cls.comp_registry) + .create( + { + "move_type": "out_invoice", + "partner_id": cls.partner_a.id, + "date": fields.Date.from_string("2016-01-01"), + "invoice_line_ids": [ + ( + 0, + None, + { + "name": "revenue line 1", + "account_id": cls.company_data[ + "default_account_revenue" + ].id, + "quantity": 1.0, + "price_unit": 100.0, + }, + ), + ( + 0, + None, + { + "name": "revenue line 2", + "account_id": cls.company_data[ + "default_account_revenue" + ].id, + "quantity": 1.0, + "price_unit": 100.0, + "tax_ids": [ + (6, 0, cls.company_data["default_tax_sale"].ids) + ], + }, + ), + ], + } + ) + ) + cls.test_move.invalidate_recordset() + + def test_paid_move(self): + self.test_move.action_post() + self.assertEqual(self.test_move.name, "new_name") + + payment_action = self.test_move.action_register_payment() + payment = ( + self.env[payment_action["res_model"]] + .with_context(**payment_action["context"]) + .create( + { + "journal_id": self.company_data["default_journal_bank"].id, + } + ) + ) + payment.with_context( + components_registry=self.comp_registry + ).action_create_payments() + self.assertEqual(self.test_move.name, "paid") + + def test_cancel_move(self): + self.test_move.action_post() + self.assertEqual(self.test_move.name, "new_name") + self.test_move.button_cancel() + self.assertEqual(self.test_move.name, "cancelled")