Skip to content

Commit

Permalink
[MIG] connector_jira: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SilvioC2C committed Jun 25, 2024
1 parent b4ffc83 commit affb16d
Show file tree
Hide file tree
Showing 23 changed files with 173 additions and 260 deletions.
15 changes: 10 additions & 5 deletions connector_jira/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@

{
"name": "JIRA Connector",
"version": "15.0.2.0.0",
"version": "17.0.1.0.0",
"author": "Camptocamp,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Connector",
"depends": [
"connector",
# Odoo community
"project",
"hr_timesheet",
"queue_job",
"web",
"web_widget_url_advanced",
# OCA/connector
"connector",
# OCA/queue
"queue_job",
# OCA/server-ux
"multi_step_wizard",
# OCA/web
"web_widget_url_advanced",
],
"external_dependencies": {
"python": [
Expand All @@ -24,7 +29,7 @@
"requests-toolbelt>=0.9.1",
"requests-jwt>=0.6.0",
"PyJWT>=1.7.1,<2.9.0",
"cryptography<37",
"cryptography>=38,<39", # Compatibility w/ Odoo 17.0 requirements
"atlassian_jwt>=3.0.0",
],
},
Expand Down
6 changes: 1 addition & 5 deletions connector_jira/components/binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ class JiraModelBinder(Component):

_name = "jira.model.binder"
_inherit = ["base.binder", "jira.base"]

_apply_on = [
"jira.issue.type",
]

_apply_on = ["jira.issue.type"]
_odoo_field = "id"

def to_internal(self, external_id, unwrap=False):
Expand Down
24 changes: 0 additions & 24 deletions connector_jira/migrations/15.0.1.0.0/pre-migrate.py

This file was deleted.

32 changes: 0 additions & 32 deletions connector_jira/migrations/15.0.2.0.0/pre-migrate.py

This file was deleted.

55 changes: 30 additions & 25 deletions connector_jira/models/account_analytic_line/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,21 @@ class JiraAccountAnalyticLine(models.Model):
# for instance, we do not import "Tasks" but we import "Epics",
# the analytic line for a "Task" will be linked to an "Epic" on
# Odoo, but we still want to know the original task here
jira_issue_key = fields.Char(
string="Original Task Key",
readonly=True,
)
jira_issue_key = fields.Char(string="Original Task Key")
jira_issue_type_id = fields.Many2one(
comodel_name="jira.issue.type",
string="Original Issue Type",
readonly=True,
)
jira_issue_url = fields.Char(
string="Original JIRA issue Link",
compute="_compute_jira_issue_url",
store=True,
)
jira_epic_issue_key = fields.Char(
string="Original Epic Key",
readonly=True,
)
jira_epic_issue_key = fields.Char(string="Original Epic Key")
jira_epic_issue_url = fields.Char(
string="Original JIRA Epic Link",
compute="_compute_jira_issue_url",
store=True,
)

_sql_constraints = [
Expand All @@ -97,12 +92,9 @@ def _is_linked(self):
def _compute_jira_issue_url(self):
"""Compute the external URL to JIRA."""
for record in self:
record.jira_issue_url = self.backend_id.make_issue_url(
record.jira_issue_key
)
record.jira_epic_issue_url = self.backend_id.make_issue_url(
record.jira_epic_issue_key
)
urlmaker = record.backend_id.make_issue_url
record.jira_issue_url = urlmaker(record.jira_issue_key)
record.jira_epic_issue_url = urlmaker(record.jira_epic_issue_key)

@api.model
def import_record(self, backend, issue_id, worklog_id, force=False):
Expand Down Expand Up @@ -141,6 +133,7 @@ class AccountAnalyticLine(models.Model):
string="Original JIRA issue Link",
compute="_compute_jira_references",
compute_sudo=True,
store=True,
)
jira_epic_issue_key = fields.Char(
compute="_compute_jira_references",
Expand All @@ -151,6 +144,7 @@ class AccountAnalyticLine(models.Model):
string="Original JIRA Epic Link",
compute="_compute_jira_references",
compute_sudo=True,
store=True,
)

jira_issue_type_id = fields.Many2one(
Expand All @@ -161,27 +155,37 @@ class AccountAnalyticLine(models.Model):
)

@api.depends(
"jira_bind_ids",
"jira_bind_ids.jira_issue_key",
"jira_bind_ids.jira_issue_url",
"jira_bind_ids.jira_issue_type_id",
"jira_bind_ids.jira_epic_issue_key",
"jira_bind_ids.jira_epic_issue_url",
)
def _compute_jira_references(self):
"""Compute the various 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:
record.jira_issue_url = False
record.jira_epic_issue_key = False
record.jira_epic_issue_url = False
continue
with_bind = self.filtered("jira_bind_ids")
for record in with_bind:
main_binding = record.jira_bind_ids[0]
record.jira_issue_key = main_binding.jira_issue_key
record.jira_issue_url = main_binding.jira_issue_url
record.jira_issue_type_id = main_binding.jira_issue_type_id
record.jira_epic_issue_key = main_binding.jira_epic_issue_key
record.jira_epic_issue_url = main_binding.jira_epic_issue_url
no_bind = self - with_bind
if no_bind:
no_bind.update(
{
"jira_issue_key": "",
"jira_issue_url": "",
"jira_issue_type_id": False,
"jira_epic_issue_key": "",
"jira_epic_issue_url": "",
}
)

@api.model
def _get_connector_jira_fields(self):
Expand Down Expand Up @@ -241,10 +245,11 @@ def _connector_jira_unlink_validate(self):
_("Timesheet linked to JIRA Worklog can not be deleted!")
)

@api.model
def create(self, vals):
self._connector_jira_create_validate(vals)
return super().create(vals)
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
self._connector_jira_create_validate(vals)
return super().create(vals_list)

def write(self, vals):
self._connector_jira_write_validate(vals)
Expand Down
22 changes: 14 additions & 8 deletions connector_jira/models/account_analytic_line/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,25 @@ def _recurse_import_task(self):
def _create_data(self, map_record, **kwargs):
return super()._create_data(
map_record,
task_binding=self.task_binding,
project_binding=self.project_binding,
fallback_project=self.fallback_project,
linked_issue=self.external_issue,
**dict(
kwargs or [],
task_binding=self.task_binding,
project_binding=self.project_binding,
fallback_project=self.fallback_project,
linked_issue=self.external_issue,
),
)

def _update_data(self, map_record, **kwargs):
return super()._update_data(
map_record,
task_binding=self.task_binding,
project_binding=self.project_binding,
fallback_project=self.fallback_project,
linked_issue=self.external_issue,
**dict(
kwargs or [],
task_binding=self.task_binding,
project_binding=self.project_binding,
fallback_project=self.fallback_project,
linked_issue=self.external_issue,
),
)

def run(self, external_id, force=False, record=None, **kwargs):
Expand Down
15 changes: 4 additions & 11 deletions connector_jira/models/jira_backend/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class JiraBackend(models.Model):

uri = fields.Char(
string="Jira URI",
readonly=True,
help="the value is provided when the app is installed on Jira Cloud.",
)
name = fields.Char(
Expand All @@ -79,9 +78,7 @@ class JiraBackend(models.Model):
help="URL to use when registering the backend as an app on the marketplace",
compute="_compute_app_descriptor_url",
)
display_url = fields.Char(
help="Url used for the Jira app in messages", readonly=True
)
display_url = fields.Char(help="Url used for the Jira app in messages")
application_key = fields.Char(
compute="_compute_application_key",
store=True,
Expand Down Expand Up @@ -130,20 +127,18 @@ class JiraBackend(models.Model):
],
default="setup",
required=True,
readonly=True,
help="State of the Backend.\n"
"Setup: in this state you can register the backend on "
"https://marketplace.atlassian.com/ as an app, using the app descriptor url.\n"
"Running: when you have installed the backend on a Jira cloud instance "
"(transition is automatic).",
)
private_key = fields.Char(
readonly=True,
groups="connector.group_connector_manager",
help="The shared secret for JWT, provided at app installation",
)
public_key = fields.Text(
readonly=True, help="The Client Key for JWT, provided at app installation"
help="The Client Key for JWT, provided at app installation"
)

verify_ssl = fields.Boolean(default=True, string="Verify SSL?")
Expand Down Expand Up @@ -182,7 +177,6 @@ class JiraBackend(models.Model):
comodel_name="jira.issue.type",
inverse_name="backend_id",
string="Issue Types",
readonly=True,
)

epic_link_field_name = fields.Char(
Expand All @@ -201,11 +195,10 @@ class JiraBackend(models.Model):
)

# TODO: use something better to show this info
# For instance, we could use web_notify to simply show a system msg.
report_user_sync = fields.Html(readonly=True)
# For instance, we could use web_notify to simply show a system msg.
report_user_sync = fields.Html()

@api.model_create_multi
@api.returns("self", lambda value: value.id)
def create(self, vals_list):
records = super().create(vals_list)
records._compute_application_key()
Expand Down
2 changes: 1 addition & 1 deletion connector_jira/models/jira_binding/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class JiraBinding(models.AbstractModel):
ondelete="restrict",
)
jira_updated_at = MilliDatetime()
external_id = fields.Char(string="ID on Jira", index=True)
external_id = fields.Char(string="ID on Jira", index="trigram")

_sql_constraints = [
(
Expand Down
4 changes: 2 additions & 2 deletions connector_jira/models/jira_issue_type/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class JiraIssueType(models.Model):
_inherit = "jira.binding"
_description = "Jira Issue Type"

name = fields.Char(required=True, readonly=True)
description = fields.Char(readonly=True)
name = fields.Char(required=True)
description = fields.Char()
backend_id = fields.Many2one(ondelete="cascade")

def is_sync_for_project(self, project_binding):
Expand Down
Loading

0 comments on commit affb16d

Please sign in to comment.