diff --git a/helpdesk_mgmt_sale/README.rst b/helpdesk_mgmt_sale/README.rst new file mode 100644 index 0000000000..1add284fbe --- /dev/null +++ b/helpdesk_mgmt_sale/README.rst @@ -0,0 +1,94 @@ +=================== +Helpdesk Sale Order +=================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9058b48ff43b86b6c8dd426fccf2d6ccf02d75989c508e82bee02b5bfe550bcf + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |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%2Fhelpdesk-lightgray.png?logo=github + :target: https://github.com/OCA/helpdesk/tree/17.0/helpdesk_mgmt_sale + :alt: OCA/helpdesk +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/helpdesk-17-0/helpdesk-17-0-helpdesk_mgmt_sale + :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/helpdesk&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the Helpdesk functionality in Odoo to allow an +integration between Helpdesk tickets and sales orders. A ticket can have +several sales orders associated with it, which in turn will have the +ticket associated with it, allowing tickets and sales to be related. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To associate orders to Helpdesk tickets: + +1. Create or modify a Helpdesk ticket. +2. In the ticket view, you will find a **Sales Order** Smartbutton which + will show the number of orders associated to the ticket. +3. Clicking on the Smartbutton will open a view with all the sales + orders related to the current ticket. +4. To create an order associated to the ticket click on the **Create** + button. + +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 +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Pilar Vargas + +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. + +This module is part of the `OCA/helpdesk `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/helpdesk_mgmt_sale/__init__.py b/helpdesk_mgmt_sale/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/helpdesk_mgmt_sale/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/helpdesk_mgmt_sale/__manifest__.py b/helpdesk_mgmt_sale/__manifest__.py new file mode 100644 index 0000000000..eff6b8c4a5 --- /dev/null +++ b/helpdesk_mgmt_sale/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 Tecnativa - Pilar Vargas +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + "name": "Helpdesk Sale Order", + "summary": "Add the option to select project in the sale orders.", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "category": "Sales Management", + "author": "Tecnativa," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/helpdesk", + "depends": ["helpdesk_mgmt", "sale"], + "data": [ + "views/helpdesk_ticket_views.xml", + "views/sale_order_views.xml", + ], + "development_status": "Production/Stable", + "auto_install": True, +} diff --git a/helpdesk_mgmt_sale/i18n/es.po b/helpdesk_mgmt_sale/i18n/es.po new file mode 100644 index 0000000000..98ceb79687 --- /dev/null +++ b/helpdesk_mgmt_sale/i18n/es.po @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * helpdesk_mgmt_sale +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-09-23 10:06+0000\n" +"Last-Translator: Pilar Vargas \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 5.6.2\n" + +#. module: helpdesk_mgmt_sale +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_sale.view_order_form +msgid "Helpdesk" +msgstr "Servicio de asistencia" + +#. module: helpdesk_mgmt_sale +#: model:ir.model,name:helpdesk_mgmt_sale.model_helpdesk_ticket +msgid "Helpdesk Ticket" +msgstr "Solicitud de servicio de asistencia" + +#. module: helpdesk_mgmt_sale +#: model:ir.model.fields,field_description:helpdesk_mgmt_sale.field_helpdesk_ticket__sale_order_ids +msgid "Sale Order" +msgstr "Pedido de venta" + +#. module: helpdesk_mgmt_sale +#: model:ir.model.fields,field_description:helpdesk_mgmt_sale.field_helpdesk_ticket__so_count +msgid "Sale Order Count" +msgstr "NÂș de pedidos de venta" + +#. module: helpdesk_mgmt_sale +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_sale.ticket_view_form +msgid "Sale Orders" +msgstr "Pedidos" + +#. module: helpdesk_mgmt_sale +#: model:ir.model,name:helpdesk_mgmt_sale.model_sale_order +msgid "Sales Order" +msgstr "Pedidos" + +#. module: helpdesk_mgmt_sale +#: model:ir.model.fields,field_description:helpdesk_mgmt_sale.field_sale_order__ticket_ids +msgid "Ticket" +msgstr "Solicitud" + +#. module: helpdesk_mgmt_sale +#: model:ir.actions.act_window,name:helpdesk_mgmt_sale.action_helpdesk_ticket +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_sale.view_order_form +msgid "Tickets" +msgstr "" + +#. module: helpdesk_mgmt_sale +#: model:ir.model.fields,field_description:helpdesk_mgmt_sale.field_sale_order__ticket_count +msgid "Tickets Count" +msgstr "" diff --git a/helpdesk_mgmt_sale/i18n/helpdesk_mgmt_sale.pot b/helpdesk_mgmt_sale/i18n/helpdesk_mgmt_sale.pot new file mode 100644 index 0000000000..9a4c4b5e3a --- /dev/null +++ b/helpdesk_mgmt_sale/i18n/helpdesk_mgmt_sale.pot @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * helpdesk_mgmt_sale +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.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: helpdesk_mgmt_sale +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_sale.view_order_form +msgid "Helpdesk" +msgstr "" + +#. module: helpdesk_mgmt_sale +#: model:ir.model,name:helpdesk_mgmt_sale.model_helpdesk_ticket +msgid "Helpdesk Ticket" +msgstr "" + +#. module: helpdesk_mgmt_sale +#: model:ir.model.fields,field_description:helpdesk_mgmt_sale.field_helpdesk_ticket__sale_order_ids +msgid "Sale Order" +msgstr "" + +#. module: helpdesk_mgmt_sale +#: model:ir.model.fields,field_description:helpdesk_mgmt_sale.field_helpdesk_ticket__so_count +msgid "Sale Order Count" +msgstr "" + +#. module: helpdesk_mgmt_sale +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_sale.ticket_view_form +msgid "Sale Orders" +msgstr "" + +#. module: helpdesk_mgmt_sale +#: model:ir.model,name:helpdesk_mgmt_sale.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: helpdesk_mgmt_sale +#: model:ir.model.fields,field_description:helpdesk_mgmt_sale.field_sale_order__ticket_ids +msgid "Ticket" +msgstr "" + +#. module: helpdesk_mgmt_sale +#: model:ir.actions.act_window,name:helpdesk_mgmt_sale.action_helpdesk_ticket +#: model_terms:ir.ui.view,arch_db:helpdesk_mgmt_sale.view_order_form +msgid "Tickets" +msgstr "" + +#. module: helpdesk_mgmt_sale +#: model:ir.model.fields,field_description:helpdesk_mgmt_sale.field_sale_order__ticket_count +msgid "Tickets Count" +msgstr "" diff --git a/helpdesk_mgmt_sale/models/__init__.py b/helpdesk_mgmt_sale/models/__init__.py new file mode 100644 index 0000000000..18f415b1c0 --- /dev/null +++ b/helpdesk_mgmt_sale/models/__init__.py @@ -0,0 +1,2 @@ +from . import helpdesk_ticket +from . import sale_order diff --git a/helpdesk_mgmt_sale/models/helpdesk_ticket.py b/helpdesk_mgmt_sale/models/helpdesk_ticket.py new file mode 100644 index 0000000000..c7d7a58017 --- /dev/null +++ b/helpdesk_mgmt_sale/models/helpdesk_ticket.py @@ -0,0 +1,25 @@ +from odoo import api, fields, models + + +class HelpdeskTicket(models.Model): + _inherit = "helpdesk.ticket" + + sale_order_ids = fields.Many2many("sale.order") + so_count = fields.Integer( + string="Sale Order Count", compute="_compute_so_count", store=True + ) + + @api.depends("sale_order_ids") + def _compute_so_count(self): + for ticket in self: + ticket.so_count = len(ticket.sale_order_ids) + + def action_view_sale_orders(self): + """Returns action to view sale orders related to this ticket.""" + action = self.env["ir.actions.actions"]._for_xml_id("sale.action_orders") + action["domain"] = [("ticket_ids", "in", [self.id])] + action["context"] = { + "default_ticket_ids": [(4, [self.id])], + "default_partner_id": self.partner_id.id, + } + return action diff --git a/helpdesk_mgmt_sale/models/sale_order.py b/helpdesk_mgmt_sale/models/sale_order.py new file mode 100644 index 0000000000..b1e89a4605 --- /dev/null +++ b/helpdesk_mgmt_sale/models/sale_order.py @@ -0,0 +1,15 @@ +from odoo import api, fields, models + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + ticket_ids = fields.Many2many("helpdesk.ticket") + ticket_count = fields.Integer( + string="Tickets Count", compute="_compute_ticket_count", store=True + ) + + @api.depends("ticket_ids") + def _compute_ticket_count(self): + for order in self: + order.ticket_count = len(order.ticket_ids) diff --git a/helpdesk_mgmt_sale/pyproject.toml b/helpdesk_mgmt_sale/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/helpdesk_mgmt_sale/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/helpdesk_mgmt_sale/readme/CONTRIBUTORS.md b/helpdesk_mgmt_sale/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..df940da7c6 --- /dev/null +++ b/helpdesk_mgmt_sale/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Tecnativa](https://www.tecnativa.com): + - Pilar Vargas diff --git a/helpdesk_mgmt_sale/readme/DESCRIPTION.md b/helpdesk_mgmt_sale/readme/DESCRIPTION.md new file mode 100644 index 0000000000..c5cdd99ad8 --- /dev/null +++ b/helpdesk_mgmt_sale/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This module extends the Helpdesk functionality in Odoo to allow an +integration between Helpdesk tickets and sales orders. A ticket can have +several sales orders associated with it, which in turn will have the +ticket associated with it, allowing tickets and sales to be related. diff --git a/helpdesk_mgmt_sale/readme/USAGE.md b/helpdesk_mgmt_sale/readme/USAGE.md new file mode 100644 index 0000000000..af3580e3e4 --- /dev/null +++ b/helpdesk_mgmt_sale/readme/USAGE.md @@ -0,0 +1,9 @@ +To associate orders to Helpdesk tickets: + +1. Create or modify a Helpdesk ticket. +2. In the ticket view, you will find a **Sales Order** Smartbutton + which will show the number of orders associated to the ticket. +3. Clicking on the Smartbutton will open a view with all the sales + orders related to the current ticket. +4. To create an order associated to the ticket click on the **Create** + button. diff --git a/helpdesk_mgmt_sale/static/description/icon.png b/helpdesk_mgmt_sale/static/description/icon.png new file mode 100644 index 0000000000..f3748245b1 Binary files /dev/null and b/helpdesk_mgmt_sale/static/description/icon.png differ diff --git a/helpdesk_mgmt_sale/static/description/icon.svg b/helpdesk_mgmt_sale/static/description/icon.svg new file mode 100644 index 0000000000..911d657702 --- /dev/null +++ b/helpdesk_mgmt_sale/static/description/icon.svg @@ -0,0 +1,267 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/helpdesk_mgmt_sale/static/description/index.html b/helpdesk_mgmt_sale/static/description/index.html new file mode 100644 index 0000000000..21bd1cf9bf --- /dev/null +++ b/helpdesk_mgmt_sale/static/description/index.html @@ -0,0 +1,443 @@ + + + + + +Helpdesk Sale Order + + + +
+

Helpdesk Sale Order

+ + +

Production/Stable License: AGPL-3 OCA/helpdesk Translate me on Weblate Try me on Runboat

+

This module extends the Helpdesk functionality in Odoo to allow an +integration between Helpdesk tickets and sales orders. A ticket can have +several sales orders associated with it, which in turn will have the +ticket associated with it, allowing tickets and sales to be related.

+

Table of contents

+ +
+

Usage

+

To associate orders to Helpdesk tickets:

+
    +
  1. Create or modify a Helpdesk ticket.
  2. +
  3. In the ticket view, you will find a Sales Order Smartbutton which +will show the number of orders associated to the ticket.
  4. +
  5. Clicking on the Smartbutton will open a view with all the sales +orders related to the current ticket.
  6. +
  7. To create an order associated to the ticket click on the Create +button.
  8. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

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.

+

This module is part of the OCA/helpdesk project on GitHub.

+

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

+
+
+
+ + diff --git a/helpdesk_mgmt_sale/tests/__init__.py b/helpdesk_mgmt_sale/tests/__init__.py new file mode 100644 index 0000000000..5b420011e0 --- /dev/null +++ b/helpdesk_mgmt_sale/tests/__init__.py @@ -0,0 +1 @@ +from . import test_helpdesk_ticket diff --git a/helpdesk_mgmt_sale/tests/test_helpdesk_ticket.py b/helpdesk_mgmt_sale/tests/test_helpdesk_ticket.py new file mode 100644 index 0000000000..1a142276f1 --- /dev/null +++ b/helpdesk_mgmt_sale/tests/test_helpdesk_ticket.py @@ -0,0 +1,55 @@ +# Copyright (C) 2024 Tecnativa - Pilar Vargas +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.addons.base.tests.common import BaseCommon + + +class TestHelpdeskTicketSale(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.partner = cls.env["res.partner"].create( + {"name": "Test Partner", "email": "testpartner@example.com"} + ) + cls.ticket = cls.env["helpdesk.ticket"].create( + { + "name": "Test Helpdesk Ticket", + "partner_id": cls.partner.id, + "description": "Test Helpdesk Ticket", + } + ) + cls.sale_order_1 = cls.env["sale.order"].create( + { + "partner_id": cls.partner.id, + "ticket_ids": [(6, 0, [cls.ticket.id])], + } + ) + cls.sale_order_2 = cls.env["sale.order"].create( + { + "partner_id": cls.partner.id, + "ticket_ids": [(6, 0, [cls.ticket.id])], + } + ) + + def test_sale_orders_associated_with_ticket(self): + # Verify that a Helpdesk ticket has multiple sales orders associated with it. + self.assertEqual(len(self.ticket.sale_order_ids), 2) + self.assertIn(self.sale_order_1, self.ticket.sale_order_ids) + self.assertIn(self.sale_order_2, self.ticket.sale_order_ids) + + def test_partner_association_in_sale_order(self): + # Verify that a sales order is associated with the correct ticket partner. + self.assertEqual(self.sale_order_1.partner_id, self.partner) + self.assertEqual(self.sale_order_2.partner_id, self.partner) + + def test_smartbutton_sale_order_count(self): + # Check the sales order counter in the smartbutton of the ticket. + self.ticket._compute_so_count() + self.assertEqual(self.ticket.so_count, 2) + + def test_action_view_sale_orders(self): + # Verify that the smartbutton action displays the associated orders correctly. + action = self.ticket.action_view_sale_orders() + self.assertEqual(action["domain"], [("ticket_ids", "in", [self.ticket.id])]) + self.assertEqual( + action["context"]["default_ticket_ids"], [(4, [self.ticket.id])] + ) diff --git a/helpdesk_mgmt_sale/views/helpdesk_ticket_views.xml b/helpdesk_mgmt_sale/views/helpdesk_ticket_views.xml new file mode 100644 index 0000000000..16455a4745 --- /dev/null +++ b/helpdesk_mgmt_sale/views/helpdesk_ticket_views.xml @@ -0,0 +1,29 @@ + + + + + helpdesk.ticket + + + + + + + + + Tickets + helpdesk.ticket + tree,form + [('sale_order_ids', 'in', active_id)] + {'default_sale_order_ids': [(4, active_id)]} + + diff --git a/helpdesk_mgmt_sale/views/sale_order_views.xml b/helpdesk_mgmt_sale/views/sale_order_views.xml new file mode 100644 index 0000000000..f254ae8090 --- /dev/null +++ b/helpdesk_mgmt_sale/views/sale_order_views.xml @@ -0,0 +1,32 @@ + + + + + sale.order + + + + + + + + + + + + +