-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP][MIG] connector_jira_servicedesk: Migration to 17.0
- Loading branch information
Showing
33 changed files
with
271 additions
and
304 deletions.
There are no files selected for viewing
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,3 @@ | ||
from . import components | ||
from . import models | ||
from . import wizards |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from . import jira_analytic_line_importer | ||
from . import jira_organization_adapter | ||
from . import jira_organization_batch_importer | ||
from . import jira_organization_from_task | ||
from . import jira_organization_mapper | ||
from . import jira_project_binder | ||
from . import jira_project_task_importer | ||
from . import jira_task_project_matcher |
13 changes: 13 additions & 0 deletions
13
connector_jira_servicedesk/components/jira_analytic_line_importer.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,13 @@ | ||
# Copyright 2019-2021 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo.addons.component.core import Component | ||
|
||
|
||
class JiraAnalyticLineImporter(Component): | ||
_inherit = "jira.analytic.line.importer" | ||
|
||
@property | ||
def _issue_fields_to_read(self): | ||
org_fname = self.backend_record.organization_field_name | ||
return super()._issue_fields_to_read + ([org_fname] if org_fname else []) |
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
17 changes: 17 additions & 0 deletions
17
connector_jira_servicedesk/components/jira_organization_from_task.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,17 @@ | ||
# Copyright 2016-Today Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo.addons.component.core import Component | ||
|
||
|
||
class JiraOrganizationsFromTask(Component): | ||
_name = "jira.organization.from.task" | ||
_inherit = ["jira.base"] | ||
_usage = "organization.from.task" | ||
|
||
def get_jira_org_ids(self, jira_task_data): | ||
if fields := jira_task_data.get("fields", {}): | ||
if org_fname := self.backend_record.organization_field_name: | ||
if recs := fields.get(org_fname): | ||
return [r["id"] for r in recs] | ||
return [] |
17 changes: 17 additions & 0 deletions
17
connector_jira_servicedesk/components/jira_organization_mapper.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,17 @@ | ||
# Copyright 2016-2019 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo.addons.component.core import Component | ||
from odoo.addons.connector.components.mapper import mapping | ||
|
||
|
||
class OrganizationMapper(Component): | ||
_name = "jira.organization.mapper" | ||
_inherit = ["jira.import.mapper"] | ||
_apply_on = "jira.organization" | ||
|
||
direct = [("name", "name")] | ||
|
||
@mapping | ||
def backend_id(self, record): | ||
return {"backend_id": self.backend_record.id} |
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
17 changes: 17 additions & 0 deletions
17
connector_jira_servicedesk/components/jira_project_task_importer.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,17 @@ | ||
# Copyright 2016-Today Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo.addons.component.core import Component | ||
|
||
|
||
class JiraProjectTaskImporter(Component): | ||
_inherit = "jira.project.task.importer" | ||
|
||
def _import_dependencies(self): | ||
# OVERRIDE: import organizations | ||
res = super()._import_dependencies() | ||
for jorg_id in self.component(usage="organization.from.task").get_jira_org_ids( | ||
self.external_record | ||
): | ||
self._import_dependency(jorg_id, "jira.organization") | ||
return res |
20 changes: 20 additions & 0 deletions
20
connector_jira_servicedesk/components/jira_task_project_matcher.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,20 @@ | ||
# Copyright 2016-Today Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo.addons.component.core import Component | ||
|
||
|
||
class JiraTaskProjectMatcher(Component): | ||
_inherit = "jira.task.project.matcher" | ||
|
||
def find_project_binding(self, jira_task_data, unwrap=False): | ||
component = self.component(usage="organization.from.task") | ||
binder = self.binder_for("jira.organization") | ||
org_ids = set() | ||
for j_org_id in component.get_jira_org_ids(jira_task_data): | ||
org_ids.update(binder.to_internal(j_org_id).ids) | ||
return self.binder_for("jira.project.project").to_internal( | ||
jira_task_data["fields"]["project"]["id"], | ||
unwrap=unwrap, | ||
organizations=self.env["jira.organization"].browse(org_ids), | ||
) |
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,5 +1,6 @@ | ||
from . import account_analytic_line | ||
from . import jira_account_analytic_line | ||
from . import jira_backend | ||
from . import project_project | ||
from . import jira_organization | ||
from . import project_task | ||
from . import jira_project_base_mixin | ||
from . import jira_project_project |
22 changes: 22 additions & 0 deletions
22
connector_jira_servicedesk/models/account_analytic_line.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,22 @@ | ||
# Copyright 2020-2021 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import api, fields, models | ||
|
||
|
||
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", | ||
) | ||
|
||
@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: | ||
bind = record.jira_bind_ids[:1] | ||
record.jira_servicedesk_issue_url = bind.jira_servicedesk_issue_url or "" |
2 changes: 0 additions & 2 deletions
2
connector_jira_servicedesk/models/account_analytic_line/__init__.py
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
connector_jira_servicedesk/models/account_analytic_line/common.py
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
connector_jira_servicedesk/models/account_analytic_line/importer.py
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
connector_jira_servicedesk/models/jira_account_analytic_line.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,22 @@ | ||
# Copyright 2020-2021 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 service desk issue Link", | ||
compute="_compute_jira_servicedesk_issue_url", | ||
) | ||
|
||
@api.depends("jira_issue_key", "project_id.jira_bind_ids") | ||
def _compute_jira_servicedesk_issue_url(self): | ||
"""Compute the external URL to JIRA service desk.""" | ||
for record in self: | ||
url = "" | ||
if jira_key := record.jira_issue_key: | ||
if jira_project := record.project_id.jira_bind_ids[:1]: | ||
url = jira_project.make_servicedesk_issue_url(jira_key) | ||
record.jira_servicedesk_issue_url = url |
Oops, something went wrong.