Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Available addons
addon | version | maintainers | summary
--- | --- | --- | ---
[helpdesk_mgmt](helpdesk_mgmt/) | 19.0.1.1.0 | | Helpdesk
[helpdesk_product](helpdesk_product/) | 19.0.1.0.0 | | Add the option to select product in the tickets.
[helpdesk_product](helpdesk_product/) | 19.0.1.1.0 | | Add the option to select product in the tickets.
[helpdesk_type](helpdesk_type/) | 19.0.1.0.0 | <a href='https://github.com/nelsonramirezs'><img src='https://github.com/nelsonramirezs.png' width='32' height='32' style='border-radius:50%;' alt='nelsonramirezs'/></a> <a href='https://github.com/max3903'><img src='https://github.com/max3903.png' width='32' height='32' style='border-radius:50%;' alt='max3903'/></a> | Add a type to your tickets

[//]: # (end addons)
Expand Down
9 changes: 7 additions & 2 deletions helpdesk_product/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Helpdesk Product
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:50b627b43f4db5e3056ce7640b144b1608c52a100c6a0505ba0f4a1f9cd64144
!! source digest: sha256:871dc4aaee4934cf5c8c6d2689ad675d01f2799c9bb6154efda0102cd81231c3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -32,7 +32,8 @@ Helpdesk Product

|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds the option to select product in the helpdesk tickets.
This module adds the option to select product in the helpdesk tickets
and view tickets related to products.

**Table of contents**

Expand Down Expand Up @@ -64,6 +65,10 @@ Contributors

- Maria Buscallà <maria.buscalla@forgeflow.com>

- `Tecnativa <https://www.tecnativa.com>`__:

- David Bañón Gil

Maintainers
-----------

Expand Down
2 changes: 1 addition & 1 deletion helpdesk_product/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Helpdesk Product",
"summary": "Add the option to select product in the tickets.",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"version": "19.0.1.0.0",
"version": "19.0.1.1.0",
"license": "AGPL-3",
"category": "After-Sales",
"website": "https://github.com/OCA/helpdesk",
Expand Down
20 changes: 20 additions & 0 deletions helpdesk_product/i18n/helpdesk_product.pot
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ msgstr ""

#. module: helpdesk_product
#: model:ir.model.fields,field_description:helpdesk_product.field_helpdesk_ticket__display_name
#: model:ir.model.fields,field_description:helpdesk_product.field_product_product__display_name
#: model:ir.model.fields,field_description:helpdesk_product.field_product_template__display_name
msgid "Display Name"
msgstr ""
Expand All @@ -42,11 +43,20 @@ msgstr ""

#. module: helpdesk_product
#: model:ir.model,name:helpdesk_product.model_helpdesk_ticket
#: model:ir.model.fields,field_description:helpdesk_product.field_product_product__helpdesk_ticket_ids
#: model:ir.model.fields,field_description:helpdesk_product.field_product_template__helpdesk_ticket_ids
msgid "Helpdesk Ticket"
msgstr ""

#. module: helpdesk_product
#: model:ir.model.fields,field_description:helpdesk_product.field_product_product__helpdesk_ticket_count
#: model:ir.model.fields,field_description:helpdesk_product.field_product_template__helpdesk_ticket_count
msgid "Helpdesk Ticket Count"
msgstr ""

#. module: helpdesk_product
#: model:ir.model.fields,field_description:helpdesk_product.field_helpdesk_ticket__id
#: model:ir.model.fields,field_description:helpdesk_product.field_product_product__id
#: model:ir.model.fields,field_description:helpdesk_product.field_product_template__id
msgid "ID"
msgstr ""
Expand All @@ -63,12 +73,22 @@ msgstr ""
msgid "Product Related"
msgstr ""

#. module: helpdesk_product
#: model:ir.model,name:helpdesk_product.model_product_product
msgid "Product Variant"
msgstr ""

#. module: helpdesk_product
#: model:ir.actions.act_window,name:helpdesk_product.product_template_action_helpdesk
#: model:ir.ui.menu,name:helpdesk_product.action_menu_view_products
msgid "Products"
msgstr ""

#. module: helpdesk_product
#: model_terms:ir.ui.view,arch_db:helpdesk_product.product_view_template
msgid "Tickets"
msgstr ""

#. module: helpdesk_product
#: model_terms:ir.actions.act_window,help:helpdesk_product.product_template_action_helpdesk
msgid ""
Expand Down
6 changes: 5 additions & 1 deletion helpdesk_product/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
class HelpdeskTicket(models.Model):
_inherit = "helpdesk.ticket"

product_id = fields.Many2one(string="Product", comodel_name="product.product")
product_id = fields.Many2one(
string="Product",
comodel_name="product.product",
domain=[("ticket_active", "=", True)],
)
59 changes: 55 additions & 4 deletions helpdesk_product/models/product.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,60 @@
from odoo import fields, models
from odoo import api, fields, models


class Product(models.Model):
class ProductTemplate(models.Model):
_inherit = "product.template"

ticket_active = fields.Boolean(
"Available for Helpdesk Tickets", default=True, required=True
ticket_active = fields.Boolean("Available for Helpdesk Tickets", default=True)
helpdesk_ticket_ids = fields.One2many(
related="product_variant_ids.helpdesk_ticket_ids"
)
helpdesk_ticket_count = fields.Integer(compute="_compute_helpdesk_ticket_count")

@api.depends("helpdesk_ticket_ids")
def _compute_helpdesk_ticket_count(self):
for template in self:
template.helpdesk_ticket_count = len(template.helpdesk_ticket_ids)

def action_view_helpdesk_tickets(self, product=None):
product = product or self
product.ensure_one()
action = self.env["ir.actions.actions"]._for_xml_id(
"helpdesk_mgmt.helpdesk_ticket_action"
)
if product.helpdesk_ticket_count <= 1:
ticket = product.helpdesk_ticket_ids
product_id = False
if product.is_product_variant or len(product.product_variant_ids) == 1:
product_id = product.product_variant_id.id
action.update(
{
"res_id": ticket.id,
"views": [(False, "form")],
"context": {"default_product_id": product_id},
}
)
else:
action.update(
{
"domain": [("id", "in", product.helpdesk_ticket_ids.ids)],
}
)
return action


class ProductProduct(models.Model):
_inherit = "product.product"

helpdesk_ticket_ids = fields.One2many(
comodel_name="helpdesk.ticket", inverse_name="product_id"
)
helpdesk_ticket_count = fields.Integer(compute="_compute_helpdesk_ticket_count")

@api.depends("helpdesk_ticket_ids")
def _compute_helpdesk_ticket_count(self):
for template in self:
template.helpdesk_ticket_count = len(template.helpdesk_ticket_ids)

def action_view_helpdesk_tickets(self):
self.ensure_one()
return self.product_tmpl_id.action_view_helpdesk_tickets(product=self)
2 changes: 2 additions & 0 deletions helpdesk_product/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
- [ForgeFlow](https://www.forgeflow.com):
- Maria Buscallà \<<maria.buscalla@forgeflow.com>\>
- [Tecnativa](https://www.tecnativa.com):
- David Bañón Gil
2 changes: 1 addition & 1 deletion helpdesk_product/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
This module adds the option to select product in the helpdesk tickets.
This module adds the option to select product in the helpdesk tickets and view tickets related to products.
9 changes: 7 additions & 2 deletions helpdesk_product/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,11 @@ <h1>Helpdesk Product</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:50b627b43f4db5e3056ce7640b144b1608c52a100c6a0505ba0f4a1f9cd64144
!! source digest: sha256:871dc4aaee4934cf5c8c6d2689ad675d01f2799c9bb6154efda0102cd81231c3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/helpdesk/tree/19.0/helpdesk_product"><img alt="OCA/helpdesk" src="https://img.shields.io/badge/github-OCA%2Fhelpdesk-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/helpdesk-19-0/helpdesk-19-0-helpdesk_product"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/helpdesk&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds the option to select product in the helpdesk tickets.</p>
<p>This module adds the option to select product in the helpdesk tickets
and view tickets related to products.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
Expand Down Expand Up @@ -411,6 +412,10 @@ <h3><a class="toc-backref" href="#toc-entry-4">Contributors</a></h3>
<li>Maria Buscallà &lt;<a class="reference external" href="mailto:maria.buscalla&#64;forgeflow.com">maria.buscalla&#64;forgeflow.com</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>David Bañón Gil</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
15 changes: 15 additions & 0 deletions helpdesk_product/views/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
<label for="ticket_active" string="Helpdesk" />
</span>
</div>
<div name="button_box" position="inside">
<button
name="action_view_helpdesk_tickets"
type="object"
class="oe_stat_button"
invisible="not ticket_active and not helpdesk_ticket_count"
icon="fa-life-ring"
>
<field
string="Tickets"
name="helpdesk_ticket_count"
widget="statinfo"
/>
</button>
</div>
</field>
</record>

Expand Down
Loading