Skip to content

Commit

Permalink
user mapping work
Browse files Browse the repository at this point in the history
  • Loading branch information
gurneyalex committed Feb 16, 2024
1 parent 3efa69b commit ac04676
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions connector_jira/models/account_analytic_line/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def duration(self, record):
@mapping
def author(self, record):
jira_author = record["author"]
jira_author_key = jira_author["key"] # accountId ?
jira_author_key = jira_author["accountId"]
binder = self.binder_for("jira.res.users")
user = binder.to_internal(jira_author_key, unwrap=True)
if not user:
Expand Down Expand Up @@ -358,7 +358,7 @@ def _import(self, binding, **kwargs):

def _import_dependency_assignee(self):
jira_assignee = self.external_record["author"]
jira_key = jira_assignee.get("key") # accountId ?
jira_key = jira_assignee.get("accountId")
self._import_dependency(jira_key, "jira.res.users", record=jira_assignee)

def _import_dependencies(self):
Expand Down
4 changes: 2 additions & 2 deletions connector_jira/models/jira_backend/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,9 @@ def import_res_users(self):
return True

def get_user_resolution_order(self):
"""User resolution should happen by login first as it's unique, while
"""User resolution should happen by accountId first as it's unique, while
resolving by email is likely to give false positives"""
return ["login", "email"]
return ["accountId", "login", "email"]

def import_issue_type(self):
self.env["jira.issue.type"].import_batch(self)
Expand Down
8 changes: 4 additions & 4 deletions connector_jira/models/project_task/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def assignee(self, record):
assignee = record["fields"].get("assignee")
if not assignee:
return {"user_ids": False}
jira_key = assignee["key"] # accountId ?
jira_key = assignee["accountId"]
binder = self.binder_for("jira.res.users")
user = binder.to_internal(jira_key, unwrap=True)
if not user:
email = assignee["emailAddress"]
email = assignee.get("emailAddress")
raise MappingError(
_(
'No user found with login "%(jira_key)s" or email "%(email)s".'
'No user found with accountId "%(jira_key)s" or email "%(email)s".'
"You must create a user or link it manually if the "
"login/email differs.",
jira_key=jira_key,
Expand Down Expand Up @@ -232,7 +232,7 @@ def _import(self, binding, **kwargs):

def _import_dependency_assignee(self):
jira_assignee = self.external_record["fields"].get("assignee") or {}
jira_key = jira_assignee.get("key") # accountId ?
jira_key = jira_assignee.get("accountId")
self._import_dependency(jira_key, "jira.res.users", record=jira_assignee)

def _import_dependency_issue_type(self):
Expand Down
2 changes: 1 addition & 1 deletion connector_jira/models/res_users/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _import(self, binding):
if not user:
email = record["emailAddress"]
user = self.env["res.users"].search(
["|", ("login", "=", jira_key), ("email", "=", email)],
[("email", "=", email)],
)
if len(user) > 1:
raise JobError(
Expand Down
2 changes: 1 addition & 1 deletion connector_jira_tempo/models/jira_backend/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def _sync_tempo_timesheets_approval_status(self, period_start):
for entry in approvals:
user_data = entry["user"]
try:
user = user_binder.to_internal(user_data["key"], unwrap=True)
user = user_binder.to_internal(user_data["accountId"], unwrap=True)
except ValueError:
_logger.error("User %(key)s not found" % user_data)
continue
Expand Down

0 comments on commit ac04676

Please sign in to comment.