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 e477bd2
Show file tree
Hide file tree
Showing 23 changed files with 143 additions and 225 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.

20 changes: 7 additions & 13 deletions connector_jira/models/account_analytic_line/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,16 @@ 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",
)
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",
Expand Down Expand Up @@ -241,10 +234,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
42 changes: 18 additions & 24 deletions connector_jira/models/project_project/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class JiraProjectBaseFields(models.AbstractModel):
jira_key = fields.Char(
string="JIRA Key",
required=True,
size=10,
) # limit on JIRA
size=10, # limit on JIRA
)
sync_issue_type_ids = fields.Many2many(
comodel_name="jira.issue.type",
string="Issue Levels to Synchronize",
Expand Down Expand Up @@ -99,13 +99,10 @@ def _selection_project_type(self):
def _add_sql_constraints(self):
# we replace the sql constraint by a python one
# to include the organizations
for key, definition, _msg in self._sql_constraints:
for key, definition, __ in self._sql_constraints:
conname = f"{self._table}_{key}"
if key == "jira_binding_uniq":
has_definition = tools.constraint_definition(
self.env.cr, self._table, conname
)
if has_definition:
if tools.constraint_definition(self.env.cr, self._table, conname):
tools.drop_constraint(self.env.cr, self._table, conname)
else:
tools.add_constraint(self.env.cr, self._table, conname, definition)
Expand Down Expand Up @@ -201,11 +198,11 @@ def _is_linked(self):
return True
return False

@api.model
def create(self, values):
record = super().create(values)
record._ensure_jira_key()
return record
@api.model_create_multi
def create(self, vals_list):
records = super().create(vals_list)
records._ensure_jira_key()
return records

def write(self, values):
if "project_template" in values:
Expand Down Expand Up @@ -251,14 +248,12 @@ def _compute_jira_key(self):
keys = project.mapped("jira_bind_ids.jira_key")
project.jira_key = ", ".join(keys)

def name_get(self):
names = []
for project in self:
project_id, name = super(ProjectProject, project).name_get()[0]
if project.jira_key:
name = f"[{project.jira_key}] {name}"
names.append((project_id, name))
return names
# pylint: disable=W8110
@api.depends("jira_key")
def _compute_display_name(self):
super()._compute_display_name()
for project in self.filtered("jira_key"):
project.display_name = f"[{project.jira_key}] {project.display_name}"

@api.model
def name_search(self, name="", args=None, operator="ilike", limit=100):
Expand All @@ -272,14 +267,13 @@ def name_search(self, name="", args=None, operator="ilike", limit=100):
]
if operator in expression.NEGATIVE_TERM_OPERATORS:
domain = ["&", "!"] + domain[1:]
return self.search(
domain + (args or []),
limit=limit,
).name_get()
projects = self.search(domain + (args or []), limit=limit)
return [(p.id, p.display_name) for p in projects.sudo()]

def create_and_link_jira(self):
action_link = self.env.ref("connector_jira.open_project_link_jira")
action = action_link.read()[0]
# TODO: remove dependency on ``active_id[s]/model``
action["context"] = dict(
self.env.context,
active_id=self.id,
Expand Down
1 change: 1 addition & 0 deletions connector_jira/models/project_project/project_link_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ProjectLinkJira(models.TransientModel):

@api.model
def _default_project_id(self):
# TODO: remove dependency on ``active_id[s]/model``
return self.env.context.get("active_id")

@api.model
Expand Down
Loading

0 comments on commit e477bd2

Please sign in to comment.