diff --git a/edi_account_oca/README.rst b/edi_account_oca/README.rst new file mode 100644 index 000000000..a652a4913 --- /dev/null +++ b/edi_account_oca/README.rst @@ -0,0 +1,104 @@ +=========== +Edi Account +=========== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:ad8dda700d5164a67ba1f1713e20676e0d7ab8b1c60e5253b555770041f6abde + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-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/18.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-18-0/edi-framework-18-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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module intends to create a base to be extended by local edi rules +for accounting. + +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 +------- + +* Creu Blanca + +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..0f00a6730 --- /dev/null +++ b/edi_account_oca/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import components diff --git a/edi_account_oca/__manifest__.py b/edi_account_oca/__manifest__.py new file mode 100644 index 000000000..5ff91fc2a --- /dev/null +++ b/edi_account_oca/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2020 Creu Blanca +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +{ + "name": "Edi Account", + "summary": """ + Define EDI Configuration for Account Moves""", + "version": "18.0.1.0.0", + "license": "LGPL-3", + "author": "Creu Blanca,Odoo Community Association (OCA)", + "maintainers": ["etobella"], + "development_status": "Beta", + "website": "https://github.com/OCA/edi-framework", + "depends": ["account", "edi_oca", "component_event"], + "data": [ + "views/account_journal.xml", + "views/res_partner.xml", + "views/account_move.xml", + "views/edi_exchange_record.xml", + ], + "demo": [], +} diff --git a/edi_account_oca/components/__init__.py b/edi_account_oca/components/__init__.py new file mode 100644 index 000000000..9430369c2 --- /dev/null +++ b/edi_account_oca/components/__init__.py @@ -0,0 +1 @@ +from . import listener diff --git a/edi_account_oca/components/listener.py b/edi_account_oca/components/listener.py new file mode 100644 index 000000000..897b054b9 --- /dev/null +++ b/edi_account_oca/components/listener.py @@ -0,0 +1,16 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.component.core import Component + + +class EDIConfigAccountListener(Component): + _name = "edi.listener.config.account.move" + _inherit = "base.event.listener" + _apply_on = ["account.move"] + + def on_send_via_email_account(self, record): + trigger = "on_send_via_email_account" + confs = record.partner_id.edi_account_conf_ids.edi_get_conf(trigger) + for conf in confs: + conf.edi_exec_snippet_do(record) 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..1c081dfae --- /dev/null +++ b/edi_account_oca/i18n/edi_account_oca.pot @@ -0,0 +1,99 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * edi_account_oca +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.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_terms:ir.ui.view,arch_db:edi_account_oca.account_move_form_view +msgid "EDI" +msgstr "" + +#. module: edi_account_oca +#: model:ir.actions.act_window,name:edi_account_oca.act_open_edi_exchange_record_account_move_view +msgid "Account Moves Exchange Record" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_bank_statement_line__edi_disable_auto +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__edi_disable_auto +#: model:ir.model.fields,field_description:edi_account_oca.field_account_payment__edi_disable_auto +msgid "Disable auto" +msgstr "" + +#. module: edi_account_oca +#: model_terms:ir.ui.view,arch_db:edi_account_oca.view_account_journal_form +#: model_terms:ir.ui.view,arch_db:edi_account_oca.view_partner_form +msgid "EDI Configuration" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__origin_exchange_type_id +msgid "EDI origin exchange type" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__origin_exchange_record_id +msgid "EDI origin record" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,help:edi_account_oca.field_account_move__origin_exchange_record_id +msgid "EDI record that originated this document." +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__edi_config +msgid "Edi Config" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__edi_has_form_config +msgid "Edi Has Form Config" +msgstr "" + +#. module: edi_account_oca +#: model_terms:ir.ui.view,arch_db:edi_account_oca.account_move_form_view +msgid "Electronic Data Interchange" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__exchange_record_ids +msgid "Exchange Record" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__exchange_record_count +msgid "Exchange Record Count" +msgstr "" + +#. module: edi_account_oca +#: model:ir.ui.menu,name:edi_account_oca.menu_account_edi_root +msgid "Exchange records" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model,name:edi_account_oca.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: edi_account_oca +#: model:ir.ui.menu,name:edi_account_oca.menu_account_edi_exchange_record +msgid "Moves" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,help:edi_account_oca.field_account_bank_statement_line__edi_disable_auto +#: model:ir.model.fields,help:edi_account_oca.field_account_move__edi_disable_auto +#: model:ir.model.fields,help:edi_account_oca.field_account_payment__edi_disable_auto +msgid "When marked, EDI automatic processing will be avoided" +msgstr "" diff --git a/edi_account_oca/i18n/fr.po b/edi_account_oca/i18n/fr.po new file mode 100644 index 000000000..95d5521b8 --- /dev/null +++ b/edi_account_oca/i18n/fr.po @@ -0,0 +1,105 @@ +# 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_terms:ir.ui.view,arch_db:edi_account_oca.account_move_form_view +msgid "EDI" +msgstr "" + +#. module: edi_account_oca +#: model:ir.actions.act_window,name:edi_account_oca.act_open_edi_exchange_record_account_move_view +msgid "Account Moves Exchange Record" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_bank_statement_line__edi_disable_auto +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__edi_disable_auto +#: model:ir.model.fields,field_description:edi_account_oca.field_account_payment__edi_disable_auto +msgid "Disable auto" +msgstr "" + +#. module: edi_account_oca +#: model_terms:ir.ui.view,arch_db:edi_account_oca.view_account_journal_form +#: model_terms:ir.ui.view,arch_db:edi_account_oca.view_partner_form +msgid "EDI Configuration" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__origin_exchange_type_id +msgid "EDI origin exchange type" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__origin_exchange_record_id +msgid "EDI origin record" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,help:edi_account_oca.field_account_move__origin_exchange_record_id +msgid "EDI record that originated this document." +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__edi_config +msgid "Edi Config" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__edi_has_form_config +msgid "Edi Has Form Config" +msgstr "" + +#. module: edi_account_oca +#: model_terms:ir.ui.view,arch_db:edi_account_oca.account_move_form_view +msgid "Electronic Data Interchange" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__exchange_record_ids +msgid "Exchange Record" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__exchange_record_count +msgid "Exchange Record Count" +msgstr "" + +#. module: edi_account_oca +#: model:ir.ui.menu,name:edi_account_oca.menu_account_edi_root +msgid "Exchange records" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model,name:edi_account_oca.model_account_move +msgid "Journal Entry" +msgstr "" + +#. module: edi_account_oca +#: model:ir.ui.menu,name:edi_account_oca.menu_account_edi_exchange_record +msgid "Moves" +msgstr "" + +#. module: edi_account_oca +#: model:ir.model.fields,help:edi_account_oca.field_account_bank_statement_line__edi_disable_auto +#: model:ir.model.fields,help:edi_account_oca.field_account_move__edi_disable_auto +#: model:ir.model.fields,help:edi_account_oca.field_account_payment__edi_disable_auto +msgid "When marked, EDI automatic processing will be avoided" +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..87453e508 --- /dev/null +++ b/edi_account_oca/i18n/it.po @@ -0,0 +1,102 @@ +# 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: 2024-07-29 08:58+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.6.2\n" + +#. module: edi_account_oca +#: model_terms:ir.ui.view,arch_db:edi_account_oca.account_move_form_view +msgid "EDI" +msgstr "EDI" + +#. module: edi_account_oca +#: model:ir.actions.act_window,name:edi_account_oca.act_open_edi_exchange_record_account_move_view +msgid "Account Moves Exchange Record" +msgstr "Recod scambio movimenti conto" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_bank_statement_line__edi_disable_auto +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__edi_disable_auto +#: model:ir.model.fields,field_description:edi_account_oca.field_account_payment__edi_disable_auto +msgid "Disable auto" +msgstr "Disabilita automatico" + +#. module: edi_account_oca +#: model_terms:ir.ui.view,arch_db:edi_account_oca.view_account_journal_form +#: model_terms:ir.ui.view,arch_db:edi_account_oca.view_partner_form +msgid "EDI Configuration" +msgstr "Configurazione EDI" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__origin_exchange_type_id +msgid "EDI origin exchange type" +msgstr "Tipo scambio origine EDI" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__origin_exchange_record_id +msgid "EDI origin record" +msgstr "Record origine EDI" + +#. module: edi_account_oca +#: model:ir.model.fields,help:edi_account_oca.field_account_move__origin_exchange_record_id +msgid "EDI record that originated this document." +msgstr "Record EDI che ha generato questo documento." + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__edi_config +msgid "Edi Config" +msgstr "Configurazione EDI" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__edi_has_form_config +msgid "Edi Has Form Config" +msgstr "EDI ha una maschera di configurazione" + +#. module: edi_account_oca +#: model_terms:ir.ui.view,arch_db:edi_account_oca.account_move_form_view +msgid "Electronic Data Interchange" +msgstr "Scambio Dati Elettronico" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__exchange_record_ids +msgid "Exchange Record" +msgstr "Record di scambio" + +#. module: edi_account_oca +#: model:ir.model.fields,field_description:edi_account_oca.field_account_move__exchange_record_count +msgid "Exchange Record Count" +msgstr "Conteggio record di scambio" + +#. module: edi_account_oca +#: model:ir.ui.menu,name:edi_account_oca.menu_account_edi_root +msgid "Exchange records" +msgstr "Record di scambio" + +#. module: edi_account_oca +#: model:ir.model,name:edi_account_oca.model_account_move +msgid "Journal Entry" +msgstr "Registrazione contabile" + +#. module: edi_account_oca +#: model:ir.ui.menu,name:edi_account_oca.menu_account_edi_exchange_record +msgid "Moves" +msgstr "Movimenti" + +#. module: edi_account_oca +#: model:ir.model.fields,help:edi_account_oca.field_account_bank_statement_line__edi_disable_auto +#: model:ir.model.fields,help:edi_account_oca.field_account_move__edi_disable_auto +#: model:ir.model.fields,help:edi_account_oca.field_account_payment__edi_disable_auto +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..ad9c91824 --- /dev/null +++ b/edi_account_oca/models/__init__.py @@ -0,0 +1,3 @@ +from . import account_move +from . import res_partner +from . import edi_configuration diff --git a/edi_account_oca/models/account_move.py b/edi_account_oca/models/account_move.py new file mode 100644 index 000000000..f0d87882c --- /dev/null +++ b/edi_account_oca/models/account_move.py @@ -0,0 +1,33 @@ +# Copyright 2020 Creu Blanca +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import fields, models + + +class AccountMove(models.Model): + _name = "account.move" + _inherit = ["account.move", "edi.exchange.consumer.mixin"] + + edi_disable_auto = fields.Boolean() + + 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/models/edi_configuration.py b/edi_account_oca/models/edi_configuration.py new file mode 100644 index 000000000..7d9a85a8c --- /dev/null +++ b/edi_account_oca/models/edi_configuration.py @@ -0,0 +1,17 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class EdiConfiguration(models.Model): + _inherit = "edi.configuration" + + trigger = fields.Selection( + selection_add=[ + ("on_send_via_email_account", "Send via Email Account"), + ], + ondelete={ + "on_send_via_email_account": "set default", + }, + ) diff --git a/edi_account_oca/models/res_partner.py b/edi_account_oca/models/res_partner.py new file mode 100644 index 000000000..86c25de47 --- /dev/null +++ b/edi_account_oca/models/res_partner.py @@ -0,0 +1,18 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + edi_account_conf_ids = fields.Many2many( + string="EDI Account Config Ids", + comodel_name="edi.configuration", + relation="res_partner_edi_configuration_account_rel", + column1="partner_id", + column2="conf_id", + domain="[('model_name', '=', 'account.move')]", + ) 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..99a98abfd --- /dev/null +++ b/edi_account_oca/readme/DESCRIPTION.md @@ -0,0 +1,18 @@ +This module intends to create a base to be extended by local edi rules +for accounting. + +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..fa3e14c40 --- /dev/null +++ b/edi_account_oca/static/description/index.html @@ -0,0 +1,443 @@ + + + + + +Edi Account + + + +
+

Edi Account

+ + +

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

+

This module intends to create a base to be extended by local edi rules +for accounting.

+

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

+
    +
  • Creu Blanca
  • +
+
+
+

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..12d1ab030 --- /dev/null +++ b/edi_account_oca/tests/test_edi.py @@ -0,0 +1,104 @@ +# Copyright 2020 Creu Blanca +# 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") diff --git a/edi_account_oca/views/account_journal.xml b/edi_account_oca/views/account_journal.xml new file mode 100644 index 000000000..60a07a511 --- /dev/null +++ b/edi_account_oca/views/account_journal.xml @@ -0,0 +1,15 @@ + + + + + account.journal.form (in edi_account) + account.journal + + + + + + + + diff --git a/edi_account_oca/views/account_move.xml b/edi_account_oca/views/account_move.xml new file mode 100644 index 000000000..5b568f39f --- /dev/null +++ b/edi_account_oca/views/account_move.xml @@ -0,0 +1,33 @@ + + + + + account.move.form (in edi_account) + account.move + + + + + + + + + + + + + diff --git a/edi_account_oca/views/edi_exchange_record.xml b/edi_account_oca/views/edi_exchange_record.xml new file mode 100644 index 000000000..5354d66c4 --- /dev/null +++ b/edi_account_oca/views/edi_exchange_record.xml @@ -0,0 +1,29 @@ + + + + + Account Moves Exchange Record + ir.actions.act_window + edi.exchange.record + tree,form + [('model', '=', 'account.move')] + {} + + + + diff --git a/edi_account_oca/views/res_partner.xml b/edi_account_oca/views/res_partner.xml new file mode 100644 index 000000000..b8e38aa2c --- /dev/null +++ b/edi_account_oca/views/res_partner.xml @@ -0,0 +1,34 @@ + + + + + res.partner.form (in edi_account) + res.partner + + + + + + + + + + res.partner.form.inherit.account + res.partner + + + + + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..28acf3e90 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-edi_oca @ git+https://github.com/thienvh332/edi-framework.git@refs/pull/6/head#subdirectory=edi_oca