-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connector_jira_servicedesk: Add servicedesk_issue_url
- Loading branch information
1 parent
8394bcf
commit bc4ff92
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
connector_jira_servicedesk/models/account_analytic_line/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import common | ||
from . import importer |
47 changes: 47 additions & 0 deletions
47
connector_jira_servicedesk/models/account_analytic_line/common.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright 2020 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import api, fields, models | ||
|
||
|
||
class JiraAccountAnalyticLine(models.Model): | ||
_inherit = 'jira.account.analytic.line' | ||
|
||
jira_servicedesk_issue_url = fields.Char( | ||
string='Original JIRA issue Link', | ||
compute='_compute_jira_servicedesk_issue_url', | ||
) | ||
|
||
@api.depends('jira_issue_key') | ||
def _compute_jira_servicedesk_issue_url(self): | ||
"""Compute the external URL to JIRA service desk.""" | ||
for record in self: | ||
jira_project = fields.first(self.project_id.jira_bind_ids) | ||
if jira_project and record.jira_issue_key: | ||
record.jira_servicedesk_issue_url = jira_project.\ | ||
make_servicedesk_issue_url( | ||
record.jira_issue_key | ||
) | ||
|
||
|
||
class AccountAnalyticLine(models.Model): | ||
_inherit = 'account.analytic.line' | ||
|
||
jira_servicedesk_issue_url = fields.Char( | ||
string='Original JIRA service desk issue Link', | ||
compute='_compute_jira_servicedesk_issue_url', | ||
readonly=True, | ||
) | ||
|
||
@api.depends( | ||
'jira_bind_ids.jira_servicedesk_issue_url', | ||
) | ||
def _compute_jira_servicedesk_issue_url(self): | ||
"""Compute the service desk references to JIRA. | ||
We assume that we have only one external record for a line | ||
""" | ||
for record in self: | ||
if not record.jira_bind_ids: | ||
continue | ||
main_binding = record.jira_bind_ids[0] | ||
record.jira_servicedesk_issue_url = main_binding.jira_servicedesk_issue_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters