diff --git a/sale_transaction_form_link/README.rst b/sale_transaction_form_link/README.rst new file mode 100644 index 00000000000..b1d93f5fa66 --- /dev/null +++ b/sale_transaction_form_link/README.rst @@ -0,0 +1,106 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +========================== +Sale Transaction Form Link +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:52173faba620ae08f18630852c534e37689f75526805f703d24fd0189e8103e4 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/sale-workflow/tree/19.0/sale_transaction_form_link + :alt: OCA/sale-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/sale-workflow-19-0/sale-workflow-19-0-sale_transaction_form_link + :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/sale-workflow&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +- This module adds a button on Sale Order Form in order to see all the + payment transactions related to that Sale Order. + +|image| + +.. |image| image:: https://user-images.githubusercontent.com/19529533/129061695-62739c7a-2d35-4764-b922-d5ea6dc0102d.png + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +- Go to Sales > Orders > Orders and pick one. +- On Sale Order form, you have a button to go to the payment transaction + if some exist. + +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 +------- + +* ACSONE SA/NV + +Contributors +------------ + +- Denis Roussel + +- `Binhex `__: + + - Zuzanna Elzbieta Szalaty Szalaty + +- Jacques-Etienne Baudoux (BCIM) + +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-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px + :target: https://github.com/rousseldenis + :alt: rousseldenis + +Current `maintainer `__: + +|maintainer-rousseldenis| + +This module is part of the `OCA/sale-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/sale_transaction_form_link/__init__.py b/sale_transaction_form_link/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/sale_transaction_form_link/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_transaction_form_link/__manifest__.py b/sale_transaction_form_link/__manifest__.py new file mode 100644 index 00000000000..080d67d3908 --- /dev/null +++ b/sale_transaction_form_link/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Sale Transaction Form Link", + "summary": """ + Allows to display a link to payment transactions on Sale Order form view.""", + "version": "19.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/sale-workflow", + "maintainers": ["rousseldenis"], + "depends": [ + "payment", + "sale", + ], + "data": [ + "views/sale_order.xml", + ], + "demo": [ + "demo/payment_transaction.xml", + ], +} diff --git a/sale_transaction_form_link/demo/payment_transaction.xml b/sale_transaction_form_link/demo/payment_transaction.xml new file mode 100644 index 00000000000..36dc3806945 --- /dev/null +++ b/sale_transaction_form_link/demo/payment_transaction.xml @@ -0,0 +1,18 @@ + + + + + + 750.0 + + draft + + + + + diff --git a/sale_transaction_form_link/i18n/es.po b/sale_transaction_form_link/i18n/es.po new file mode 100644 index 00000000000..acbcdff5597 --- /dev/null +++ b/sale_transaction_form_link/i18n/es.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_transaction_form_link +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-17 00:04+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: sale_transaction_form_link +#: model:ir.model.fields,field_description:sale_transaction_form_link.field_sale_order__display_name +msgid "Display Name" +msgstr "Mostrar Nombre" + +#. module: sale_transaction_form_link +#: model:ir.model.fields,field_description:sale_transaction_form_link.field_sale_order__id +msgid "ID" +msgstr "ID" + +#. module: sale_transaction_form_link +#: model:ir.model.fields,field_description:sale_transaction_form_link.field_sale_order____last_update +msgid "Last Modified on" +msgstr "Última Modificación el" + +#. module: sale_transaction_form_link +#: model:ir.model.fields,field_description:sale_transaction_form_link.field_sale_order__payment_transaction_count +msgid "Number of payment transactions" +msgstr "Número de transacciones de pago" + +#. module: sale_transaction_form_link +#: model:ir.model,name:sale_transaction_form_link.model_sale_order +msgid "Sales Order" +msgstr "Orden de Ventas" + +#. module: sale_transaction_form_link +#: model_terms:ir.ui.view,arch_db:sale_transaction_form_link.sale_order_form_view +msgid "Transactions" +msgstr "Transacciones" diff --git a/sale_transaction_form_link/i18n/it.po b/sale_transaction_form_link/i18n/it.po new file mode 100644 index 00000000000..f73e0d5213c --- /dev/null +++ b/sale_transaction_form_link/i18n/it.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_transaction_form_link +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-10-03 11:06+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: sale_transaction_form_link +#: model:ir.model.fields,field_description:sale_transaction_form_link.field_sale_order__payment_transaction_count +msgid "Number of payment transactions" +msgstr "Numero di transazioni di pagamento" + +#. module: sale_transaction_form_link +#: model:ir.model,name:sale_transaction_form_link.model_sale_order +msgid "Sales Order" +msgstr "Ordine di vendita" + +#. module: sale_transaction_form_link +#: model_terms:ir.ui.view,arch_db:sale_transaction_form_link.sale_order_form_view +msgid "Transactions" +msgstr "Transazioni" diff --git a/sale_transaction_form_link/i18n/sale_transaction_form_link.pot b/sale_transaction_form_link/i18n/sale_transaction_form_link.pot new file mode 100644 index 00000000000..e2de045ff6b --- /dev/null +++ b/sale_transaction_form_link/i18n/sale_transaction_form_link.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * sale_transaction_form_link +# +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: sale_transaction_form_link +#: model:ir.model.fields,field_description:sale_transaction_form_link.field_sale_order__payment_transaction_count +msgid "Number of payment transactions" +msgstr "" + +#. module: sale_transaction_form_link +#: model:ir.model,name:sale_transaction_form_link.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_transaction_form_link +#: model_terms:ir.ui.view,arch_db:sale_transaction_form_link.sale_order_form_view +msgid "Transactions" +msgstr "" diff --git a/sale_transaction_form_link/models/__init__.py b/sale_transaction_form_link/models/__init__.py new file mode 100644 index 00000000000..6aacb753131 --- /dev/null +++ b/sale_transaction_form_link/models/__init__.py @@ -0,0 +1 @@ +from . import sale_order diff --git a/sale_transaction_form_link/models/sale_order.py b/sale_transaction_form_link/models/sale_order.py new file mode 100644 index 00000000000..aab9e5c92e7 --- /dev/null +++ b/sale_transaction_form_link/models/sale_order.py @@ -0,0 +1,36 @@ +# Copyright 2020 ACSONE SA/NV +# Copyright 2025 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + payment_transaction_count = fields.Integer( + string="Number of payment transactions", + compute="_compute_payment_transaction_count", + ) + + @api.depends("transaction_ids") + def _compute_payment_transaction_count(self): + for rec in self: + rec.payment_transaction_count = len(rec.transaction_ids) + + def action_view_transaction(self): + action = { + "type": "ir.actions.act_window", + "name": "Payment Transactions", + "res_model": "payment.transaction", + } + if self.payment_transaction_count == 1: + action.update({"res_id": self.transaction_ids.id, "view_mode": "form"}) + else: + action.update( + { + "view_mode": "list,form", + "domain": [("id", "in", self.transaction_ids.ids)], + } + ) + return action diff --git a/sale_transaction_form_link/pyproject.toml b/sale_transaction_form_link/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/sale_transaction_form_link/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/sale_transaction_form_link/readme/CONTRIBUTORS.md b/sale_transaction_form_link/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..78606ca0597 --- /dev/null +++ b/sale_transaction_form_link/readme/CONTRIBUTORS.md @@ -0,0 +1,6 @@ +- Denis Roussel \ + +- [Binhex](https://binhex.cloud): + - Zuzanna Elzbieta Szalaty Szalaty \ + +- Jacques-Etienne Baudoux (BCIM) \ diff --git a/sale_transaction_form_link/readme/DESCRIPTION.md b/sale_transaction_form_link/readme/DESCRIPTION.md new file mode 100644 index 00000000000..dd1fe03ec0d --- /dev/null +++ b/sale_transaction_form_link/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +- This module adds a button on Sale Order Form in order to see all the + payment transactions related to that Sale Order. + +![image](https://user-images.githubusercontent.com/19529533/129061695-62739c7a-2d35-4764-b922-d5ea6dc0102d.png) diff --git a/sale_transaction_form_link/readme/USAGE.md b/sale_transaction_form_link/readme/USAGE.md new file mode 100644 index 00000000000..bd55dee4f61 --- /dev/null +++ b/sale_transaction_form_link/readme/USAGE.md @@ -0,0 +1,3 @@ +- Go to Sales \> Orders \> Orders and pick one. +- On Sale Order form, you have a button to go to the payment transaction + if some exist. diff --git a/sale_transaction_form_link/static/description/icon.png b/sale_transaction_form_link/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/sale_transaction_form_link/static/description/icon.png differ diff --git a/sale_transaction_form_link/static/description/index.html b/sale_transaction_form_link/static/description/index.html new file mode 100644 index 00000000000..3befeb37fe0 --- /dev/null +++ b/sale_transaction_form_link/static/description/index.html @@ -0,0 +1,449 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + + +
+ + diff --git a/sale_transaction_form_link/tests/__init__.py b/sale_transaction_form_link/tests/__init__.py new file mode 100644 index 00000000000..6f699d0d8ba --- /dev/null +++ b/sale_transaction_form_link/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sale_order diff --git a/sale_transaction_form_link/tests/test_sale_order.py b/sale_transaction_form_link/tests/test_sale_order.py new file mode 100644 index 00000000000..f7a76d6afcb --- /dev/null +++ b/sale_transaction_form_link/tests/test_sale_order.py @@ -0,0 +1,100 @@ +# Copyright 2024 Binhex - Zuzanna Elzbieta Szalaty Szalaty. +# Copyright 2025 Jacques-Etienne Baudoux (BCIM) +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) +from odoo.addons.payment.tests.common import PaymentCommon + + +class TestSaleOrder(PaymentCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner_id = cls.env["res.partner"].create({"name": "Test Partner"}) + cls.sale_order = cls.env["sale.order"].create( + { + "partner_id": cls.partner_id.id, + } + ) + cls.provider = cls.env["payment.provider"].create( + { + "name": "Test", + "code": "none", + } + ) + + def test_compute_payment_transaction_count(self): + self.assertEqual(self.sale_order.payment_transaction_count, 0) + transaction1 = self.env["payment.transaction"].create( + { + "provider_id": self.provider.id, + "partner_id": self.partner_id.id, + "amount": 100, + "currency_id": self.env.company.currency_id.id, + "payment_method_id": self.payment_method.id, + } + ) + transaction2 = self.env["payment.transaction"].create( + { + "provider_id": self.provider.id, + "partner_id": self.partner_id.id, + "amount": 200, + "currency_id": self.env.company.currency_id.id, + "payment_method_id": self.payment_method.id, + } + ) + self.sale_order.transaction_ids = [transaction1.id, transaction2.id] + self.assertEqual(self.sale_order.payment_transaction_count, 2) + transaction1.unlink() + self.assertEqual(self.sale_order.payment_transaction_count, 1) + + def test_action_view_transaction(self): + action = self.sale_order.action_view_transaction() + self.assertEqual(action["type"], "ir.actions.act_window") + self.assertEqual(action["name"], "Payment Transactions") + self.assertEqual(action["res_model"], "payment.transaction") + self.assertEqual(action["view_mode"], "list,form") + self.assertEqual(action["domain"], [("id", "in", [])]) + + transaction = self.env["payment.transaction"].create( + { + "provider_id": self.provider.id, + "partner_id": self.partner_id.id, + "amount": 100, + "currency_id": self.env.company.currency_id.id, + "payment_method_id": self.payment_method.id, + } + ) + self.sale_order.transaction_ids = [transaction.id] + action = self.sale_order.action_view_transaction() + self.assertEqual(action["type"], "ir.actions.act_window") + self.assertEqual(action["name"], "Payment Transactions") + self.assertEqual(action["res_model"], "payment.transaction") + self.assertEqual(action["view_mode"], "form") + self.assertEqual(action["res_id"], transaction.id) + + transaction1 = self.env["payment.transaction"].create( + { + "provider_id": self.provider.id, + "partner_id": self.partner_id.id, + "amount": 100, + "currency_id": self.env.company.currency_id.id, + "payment_method_id": self.payment_method.id, + } + ) + transaction2 = self.env["payment.transaction"].create( + { + "provider_id": self.provider.id, + "partner_id": self.partner_id.id, + "amount": 200, + "currency_id": self.env.company.currency_id.id, + "payment_method_id": self.payment_method.id, + } + ) + self.sale_order.transaction_ids = [transaction1.id, transaction2.id] + action = self.sale_order.action_view_transaction() + self.assertEqual(action["type"], "ir.actions.act_window") + self.assertEqual(action["name"], "Payment Transactions") + self.assertEqual(action["res_model"], "payment.transaction") + self.assertEqual(action["view_mode"], "list,form") + self.assertEqual( + action["domain"], [("id", "in", [transaction1.id, transaction2.id])] + ) diff --git a/sale_transaction_form_link/views/sale_order.xml b/sale_transaction_form_link/views/sale_order.xml new file mode 100644 index 00000000000..911d87fa3bc --- /dev/null +++ b/sale_transaction_form_link/views/sale_order.xml @@ -0,0 +1,28 @@ + + + + + sale.order.form (in sale_transaction_form_link) + sale.order + + + + + + + +