diff --git a/helpdesk_mgmt/data/helpdesk_data.xml b/helpdesk_mgmt/data/helpdesk_data.xml
index 24d3260e0a..9ba83ca7fa 100644
--- a/helpdesk_mgmt/data/helpdesk_data.xml
+++ b/helpdesk_mgmt/data/helpdesk_data.xml
@@ -211,13 +211,5 @@
Other
-
-
-
-
-
-
-
-
diff --git a/helpdesk_project/__init__.py b/helpdesk_project/__init__.py
index e69de29bb2..7f0969edc6 100644
--- a/helpdesk_project/__init__.py
+++ b/helpdesk_project/__init__.py
@@ -0,0 +1 @@
+from . import models
diff --git a/helpdesk_project/__manifest__.py b/helpdesk_project/__manifest__.py
index 76fbc55cbe..8ca2680eef 100644
--- a/helpdesk_project/__manifest__.py
+++ b/helpdesk_project/__manifest__.py
@@ -15,8 +15,11 @@
"PESOL ,"
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/helpdesk",
- "depends": ["helpdesk_mgmt"],
- "data": [],
+ "depends": ["project", "helpdesk_mgmt"],
+ "data": [
+ "views/helpdesk_project_task_views.xml",
+ "views/helpdesk_project_ticket_views.xml",
+ ],
"demo": [],
"development_status": "Alpha",
"application": True,
diff --git a/helpdesk_project/models/__init__.py b/helpdesk_project/models/__init__.py
new file mode 100644
index 0000000000..61b22a593a
--- /dev/null
+++ b/helpdesk_project/models/__init__.py
@@ -0,0 +1,2 @@
+from . import helpdesk_project_ticket
+from . import helpdesk_project_task
diff --git a/helpdesk_project/models/helpdesk_project_task.py b/helpdesk_project/models/helpdesk_project_task.py
new file mode 100644
index 0000000000..ff2a2aaf8d
--- /dev/null
+++ b/helpdesk_project/models/helpdesk_project_task.py
@@ -0,0 +1,34 @@
+from odoo import models, api, fields, _
+
+class ProjectTask(models.Model):
+ _inherit = 'project.task'
+
+ ticket_ids = fields.One2many(
+ comodel_name='helpdesk.ticket',
+ inverse_name='task_id',
+ string='Tickets')
+
+ ticket_count = fields.Integer(
+ compute='_compute_ticket_count',
+ string="Number of Tickets")
+
+ @api.depends('ticket_ids')
+ def _compute_ticket_count(self):
+ for task in self:
+ task.ticket_count = len(task.ticket_ids)
+
+ def task_action_view_tickets(self):
+ action = self.env.ref("helpdesk_project.task_action_ticket_new").read()[0]
+ action['context'] = {
+ 'default_task_id': self.id,
+ 'default_project_id': self.project_id and self.project_id.id,
+ }
+ return action
+
+ def action_new_ticket(self):
+ action = self.env.ref("helpdesk_project.task_action_ticket_new").read()[0]
+ action['context'] = {
+ 'default_task_id': self.id,
+ 'default_project_id': self.project_id and self.project_id.id,
+ }
+ return action
diff --git a/helpdesk_project/models/helpdesk_project_ticket.py b/helpdesk_project/models/helpdesk_project_ticket.py
new file mode 100644
index 0000000000..9931ebc12b
--- /dev/null
+++ b/helpdesk_project/models/helpdesk_project_ticket.py
@@ -0,0 +1,30 @@
+from odoo import models, api, fields, _
+
+class HelpdeskTicket(models.Model):
+ _inherit = 'helpdesk.ticket'
+
+ project_id = fields.Many2one(
+ comodel_name='project.project',
+ string='Project')
+ task_id = fields.Many2one(
+ comodel_name='project.task',
+ string='Task')
+
+ # Si busco la tarea sin indicar el proyecto completar el campo del proyecto
+ # (onchange en tarea que complete el projecto)
+ @api.onchange('task_id')
+ def _onchange_task_id(self):
+ if self.task_id and self.task_id.project_id:
+ self.project_id = self.task_id.project_id
+ else:
+ self.project_id = False
+
+ # si busco primero el proyecto solo permitir seleccionar tareas de ese proyecto
+ # (onchange a project que devuelva un domain)
+ @api.onchange('project_id')
+ def _onchange_project_id(self):
+ if self.project_id:
+ domain = {'task_id': [('project_id', '=', self.project_id.id)]}
+ else:
+ domain = {}
+ return {'domain': domain}
diff --git a/helpdesk_project/views/helpdesk_project_task_views.xml b/helpdesk_project/views/helpdesk_project_task_views.xml
new file mode 100644
index 0000000000..463ef7d49e
--- /dev/null
+++ b/helpdesk_project/views/helpdesk_project_task_views.xml
@@ -0,0 +1,37 @@
+
+
+
+ view.helpdesk.project.task.form
+ project.task
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Ticket
+ helpdesk.ticket
+ form, tree
+ [('task_id', '=', active_id)]
+
+ {'search_default_task_id': active_id,
+ 'default_task_id': active_id}
+
+
+
diff --git a/helpdesk_project/views/helpdesk_project_ticket_views.xml b/helpdesk_project/views/helpdesk_project_ticket_views.xml
new file mode 100644
index 0000000000..96215f126b
--- /dev/null
+++ b/helpdesk_project/views/helpdesk_project_ticket_views.xml
@@ -0,0 +1,18 @@
+
+
+
+ view.helpdesk.project.ticket.form
+ helpdesk.ticket
+
+
+
+
+
+
+
+
+
+
+
+
+