Skip to content

Commit

Permalink
[IMP] helpdesk_mgmt_project: Set by default the company as the projec…
Browse files Browse the repository at this point in the history
…t one in tickets
  • Loading branch information
aronabencherif authored and vincent-hatakeyama committed Apr 16, 2024
1 parent 348799a commit 9e8ca3b
Show file tree
Hide file tree
Showing 8 changed files with 748 additions and 420 deletions.
7 changes: 5 additions & 2 deletions helpdesk_mgmt_project/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Helpdesk Project
================

..
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
Expand All @@ -29,7 +29,8 @@ Helpdesk Project
|badge1| |badge2| |badge3| |badge4| |badge5|

This module adds Project in Helpdesk.
We add to the project form view a ticket counter that redirects you to the helpdesk
We add to the project form view a ticket counter that redirects you to the helpdesk.
We reiterated on tickets the behavior already in place on tasks in Odoo.

**Table of contents**

Expand Down Expand Up @@ -81,6 +82,8 @@ Contributors

* Rafa Morant

* XCG Consulting, part of `Orbeet <https://orbeet.io>`_

Maintainers
~~~~~~~~~~~

Expand Down
5 changes: 1 addition & 4 deletions helpdesk_mgmt_project/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
from . import helpdesk_ticket
from . import helpdesk_ticket_team
from . import project
from . import project_task
from . import helpdesk_ticket, helpdesk_ticket_team, project, project_task
31 changes: 30 additions & 1 deletion helpdesk_mgmt_project/models/helpdesk_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ class HelpdeskTicket(models.Model):

_inherit = "helpdesk.ticket"

project_id = fields.Many2one(string="Project", comodel_name="project.project")
project_id = fields.Many2one(
"project.project", string="Project", tracking=True, check_company=True
)
task_id = fields.Many2one(
string="Task",
comodel_name="project.task",
Expand All @@ -14,6 +16,33 @@ class HelpdeskTicket(models.Model):
store=True,
)

@api.model
def _default_company_id(self):
if self._context.get("default_project_id"):
return (
self.env["project.project"]
.browse(self._context["default_project_id"])
.company_id
)
return self.env.company

# Override field
company_id = fields.Many2one(
"res.company",
string="Company",
compute="_compute_company_id",
store=True,
readonly=False,
required=True,
copy=True,
default=_default_company_id,
)

@api.depends("project_id.company_id")
def _compute_company_id(self):
for ticket in self.filtered(lambda ticket: ticket.project_id):
ticket.company_id = ticket.project_id.company_id

@api.depends("project_id")
def _compute_task_id(self):
for record in self:
Expand Down
2 changes: 2 additions & 0 deletions helpdesk_mgmt_project/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
* `ALBA Software <https://www.albasoft.com>`_:

* Rafa Morant

* XCG Consulting, part of `Orbeet <https://orbeet.io/>`_
3 changes: 2 additions & 1 deletion helpdesk_mgmt_project/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
This module adds Project in Helpdesk.
We add to the project form view a ticket counter that redirects you to the helpdesk
We add to the project form view a ticket counter that redirects you to the helpdesk.
We reiterated on tickets the behavior already in place on tasks in Odoo.
Loading

0 comments on commit 9e8ca3b

Please sign in to comment.