Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0][MIG] connector jira servicedesk #53

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions connector_jira_servicedesk/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
JIRA Connector - Service Desk Extension
=======================================

Setup
-----

A new button is added on the JIRA backend, to import the organizations
of JIRA. Before, be sure to use the button "Configure Organization Link"
in the "Advanced Configuration" tab.


Features
^^^^^^^^

Organizations
-------------

On Service Desk, you can share projects with Organizations.
You may want to use different Odoo projects according to the
organizations. This is what this extension allows.

Example:

* You have one Service Desk project named "Earth Project" with key EARTH
* On JIRA SD You share this project with organizations Themis and Rhea
* However on Odoo, you want to track the hours differently for Themis and Rhea

Steps on Odoo:

* Create a Themis project, use the "Link with JIRA" action with the key EARTH
* When you hit Next, the organization(s) you want to link must be set
* Repeat with another project for Rhea

If the project binding for the synchronization already exists, you can still edit it in the settings of the project and change the organizations.

When a task or worklog is imported, it will search for a project having
exactly the same set of organizations than the one of the task. If no
project with the same set is found and you have a project configured
without organization, the task will be linked to it.

This means that, on Odoo, you can have shared project altogether with dedicated
ones, while you only have one project on JIRA.

* Tasks with org "Themis" will be attached to this project
* Tasks with org "Rhea" will be attached to this project
* Tasks with orgs "Themis" and "Rhea" will be attached to another project "Themis and Rhea"
* The rest of the tasks will be attached to a fourth project (configured without organizations)
1 change: 1 addition & 0 deletions connector_jira_servicedesk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions connector_jira_servicedesk/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

{
"name": "JIRA Connector - Service Desk Extension",
"version": "13.0.1.0.0",
"author": "Camptocamp,Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Connector",
"depends": ["connector_jira"],
"website": "https://github.com/camptocamp/connector-jira",
"data": [
"views/jira_backend_views.xml",
"views/project_project_views.xml",
"views/project_link_jira_views.xml",
"security/ir.model.access.csv",
],
"installable": True,
}
161 changes: 161 additions & 0 deletions connector_jira_servicedesk/i18n/connector_jira_servicedesk.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * connector_jira_servicedesk
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: connector_jira_servicedesk
#: model:ir.ui.view,arch_db:connector_jira_servicedesk.view_jira_backend_form
msgid "Activate the synchronization of the Organization field.\n"
" Only on JIRA ServiceDesk. The field contains the name of\n"
" the JIRA custom field that contains the Organization."
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.ui.view,arch_db:connector_jira_servicedesk.view_jira_backend_form
msgid "Configure Organization"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_organization_create_uid
msgid "Created by"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_organization_create_date
msgid "Created on"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_organization_display_name
msgid "Display Name"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_organization_id
msgid "ID"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,help:connector_jira_servicedesk.field_jira_project_base_mixin_organization_ids
#: model:ir.model.fields,help:connector_jira_servicedesk.field_jira_project_project_organization_ids
#: model:ir.model.fields,help:connector_jira_servicedesk.field_project_link_jira_organization_ids
msgid "If organizations are set, a task will be added to the project only if the project AND the organization match with the selection."
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.ui.view,arch_db:connector_jira_servicedesk.view_jira_backend_form
msgid "Import Organizations"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model,name:connector_jira_servicedesk.model_jira_backend
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_organization_backend_id
msgid "Jira Backend"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model,name:connector_jira_servicedesk.model_jira_organization
#: model:ir.ui.view,arch_db:connector_jira_servicedesk.view_jira_backend_form
msgid "Jira Organization"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model,name:connector_jira_servicedesk.model_jira_project_project
msgid "Jira Projects"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_organization___last_update
msgid "Last Modified on"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_organization_write_uid
msgid "Last Updated by"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_organization_write_date
msgid "Last Updated on"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model,name:connector_jira_servicedesk.model_project_link_jira
msgid "Link Project with JIRA"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_organization_name
msgid "Name"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_backend_organization_field_name
msgid "Organization Field"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_project_base_mixin_organization_ids
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_project_project_organization_ids
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_project_link_jira_organization_ids
msgid "Organization(s) on Jira"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_backend_organization_ids
#: model:ir.ui.view,arch_db:connector_jira_servicedesk.view_jira_backend_form
msgid "Organizations"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,field_description:connector_jira_servicedesk.field_jira_organization_project_ids
msgid "Project"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.ui.view,arch_db:connector_jira_servicedesk.view_jira_backend_form
msgid "Run"
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model.fields,help:connector_jira_servicedesk.field_jira_backend_organization_field_name
msgid "The 'Organization' field on JIRA is a custom field. The name of the field is something like 'customfield_10002'. "
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.ui.view,arch_db:connector_jira_servicedesk.project_link_jira_form
msgid "The organizations you choose will define how the tasks and worklogs are attached to the project.\n"
" If a task is assigned to an organization, it will be assigned\n"
" to an Odoo project linked to the JIRA project only if the\n"
" organization match. If no project with an organization exists,\n"
" the task will be assigned to a linked project without organization.\n"
" If no such project exists in Odoo, the task is ignored."
msgstr ""

#. module: connector_jira_servicedesk
#: code:addons/connector_jira_servicedesk/models/project_project/common.py:58
#, python-format
msgid "The project %s is already linked with the same JIRA project without organization."
msgstr ""

#. module: connector_jira_servicedesk
#: code:addons/connector_jira_servicedesk/models/project_project/common.py:63
#, python-format
msgid "The project %s is already linked with this JIRA project and similar organizations."
msgstr ""

#. module: connector_jira_servicedesk
#: model:ir.model,name:connector_jira_servicedesk.model_jira_project_base_mixin
msgid "jira.project.base.mixin"
msgstr ""

5 changes: 5 additions & 0 deletions connector_jira_servicedesk/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import account_analytic_line
from . import jira_backend
from . import project_project
from . import jira_organization
from . import project_task
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import common
from . import importer
47 changes: 47 additions & 0 deletions connector_jira_servicedesk/models/account_analytic_line/common.py
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo.addons.component.core import Component


class AnalyticLineImporter(Component):
_inherit = "jira.analytic.line.importer"

@property
def _issue_fields_to_read(self):
issue_fields = super()._issue_fields_to_read
organization_field_name = self.backend_record.organization_field_name
if not organization_field_name:
return issue_fields
return issue_fields + [organization_field_name]
1 change: 1 addition & 0 deletions connector_jira_servicedesk/models/jira_backend/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import common
48 changes: 48 additions & 0 deletions connector_jira_servicedesk/models/jira_backend/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2016-2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import api, fields, models


class JiraBackend(models.Model):
_inherit = "jira.backend"

organization_ids = fields.One2many(
comodel_name="jira.organization",
inverse_name="backend_id",
string="Organizations",
readonly=True,
)

organization_field_name = fields.Char(
string="Organization Field",
help="The 'Organization' field on JIRA is a custom field. "
"The name of the field is something like 'customfield_10002'. ",
)

@api.model
def _selection_project_template(self):
selection = super()._selection_project_template()
selection += [
("Basic", "Basic (Service Desk)"),
("IT Service Desk", "IT Service Desk (Service Desk)"),
("Customer service", "Customer Service (Service Desk)"),
]
return selection

def import_organization(self):
self.env["jira.organization"].import_batch(self)
return True

def activate_organization(self):
"""Get organization field name from JIRA web-service"""
self.ensure_one()
org_field = "com.atlassian.servicedesk:sd-customer-organizations"
with self.work_on("jira.backend") as work:
adapter = work.component(usage="backend.adapter")
jira_fields = adapter.list_fields()
for field in jira_fields:
custom_ref = field.get("schema", {}).get("custom")
if custom_ref == org_field:
self.organization_field_name = field["id"]
break
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import common
from . import importer
from . import adapter
Loading