Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] helpdesk_mgmt_project: Set by default the company as the project one in tickets #548

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
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
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
32 changes: 31 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,34 @@ 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:
if 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
Loading