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

[12.0][MIG] connector_jira #4

Merged
merged 22 commits into from
Aug 8, 2019
Merged

[12.0][MIG] connector_jira #4

merged 22 commits into from
Aug 8, 2019

Conversation

alexey-pelykh
Copy link
Contributor

No description provided.

@alexey-pelykh
Copy link
Contributor Author

@guewen @simahawk @grindtildeath this is a WIP, yet since I'm very new to this module, your help would be much appreciated

@alexey-pelykh alexey-pelykh changed the title [12.0][MIG] connector_jira [WIP][12.0][MIG] connector_jira Jul 20, 2019
@alexey-pelykh alexey-pelykh changed the title [WIP][12.0][MIG] connector_jira [12.0][MIG] connector_jira Jul 21, 2019
@alexey-pelykh alexey-pelykh mentioned this pull request Jul 21, 2019
5 tasks
@alexey-pelykh
Copy link
Contributor Author

All dependencies have been merged, so this one is super-ready to be reviewed and tested

Copy link
Contributor

@simahawk simahawk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eyeball code review only on last commit for v12: seems good

@alexey-pelykh
Copy link
Contributor Author

alexey-pelykh commented Aug 6, 2019

image
here's an issue this issue is related to dependency, nothing to do here

@alexey-pelykh
Copy link
Contributor Author

alexey-pelykh commented Aug 6, 2019

image
and another unclear behavior related to report_user_sync probably being empty

image

fixed

@alexey-pelykh
Copy link
Contributor Author

alexey-pelykh commented Aug 6, 2019

WARNING ? odoo.addons.queue_job.jobrunner.channels: unknown channel root.connector_jira.import, using root channel for job b3db1ffa-dd45-4162-b850-30ff889ba64a not sure what that means added to installation instruction

Copy link
Member

@guewen guewen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@alexey-pelykh
Copy link
Contributor Author

Good to merge I guess?

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@pedrobaeza pedrobaeza added this to the 12.0 milestone Aug 8, 2019
guewen and others added 15 commits August 8, 2019 20:10
Add project binding

Add export of projects

Add Jira project tasks model

Add external dependencies in manifest

Add security accesses

Add basic import of tasks

Task import are triggered by Jira webhooks. A batch import must be added
later to import the changes from missed hooks or for those not wanting
to use the webhooks.

Add a basic backend adapter

Batch import of project tasks

Remove markdown

The fields are not in markdown, but in a wiki syntax (proper to JIRA yet
be determined)

Link users and import tasks assignees

Import worklogs

Use an adapter for the project export

Import issue types

Filter type of issues to synchronize

And assign the worklog to the first parent we find that we synchronize.

If the type of the worklog's issue is synchronized, the worklog is
assigned on this issue. If the worklog's issue is a sub-task, and the
parent task of the sub-task is of a synchronized type, it link it to it.
If the task has an epic, and the epics are synchronized, it link it to
it. In last resort, the worklog will be linked with the project but with
no task.

Configure the name of the Epic Link field from API

Create webhooks in JIRA from Odoo

Choose template on project creation

Discard Epics from different projects

JIRA allow to choose an epic for any project. Setting the Epic as the
Odoo task would create inconsistencies between the project and the task.
We discard such an Epic, likely the task will be empty.

Delete worklogs deleted on JIRA (only with webhooks)

Delete tasks deleted on JIRA (only with webhooks)

Add JIRA issue type in tasks

Add JIRA Issue Key

Add core business project types

Improve display of JIRA backend

Use a dedicated button to activate the Epic Link.

Link the Epic in a dedicated field

Add JIRA Parent for subtasks

Show JIRA key in name

Create project from shared project

Check JIRA project keys

Remove the button to 'one-click-export' a project

It can't be working because we have other fields to configure on the
binding.

Add help on issue type synchronizations

 Accept tasks without parent

Do not use id builtin
 add `jira_account_analytic_line` object
Replace openerp namespace by odoo namespace

Change to new Binder's API

Migrate connector_jira to new 10.0 API

Make addons uninstallable

Apply 2to3 for python3

Migrate to new Component API

Add setup guide in readme

Migrate to v11 and Py3

Allow to delete a backend if we have issue types
Fix project listener name typo

Add links to JIRA issue on a.a.l

Fix connector tab naming
text_field as attribute could not by validated by RNG, options is
always valid

Add base to support both export and link with projects

Now linking a project with JIRA must be done through a wizard instead
of the binding view. It must be either export (create the project on
jira) or link (link with an existing project on jira).

We keep this choice in the binding so we never export data to JIRA
when we chose the link only.
Map projects by external_id + set of jira orgs

Project bindings now can be assigned to one or more jira organizations.
The binding for the project accept an additional argument for
organizations. A task will be linked with the project having the exact
same set of organizations that it has, or fallback to a project without
organization.

A constraint ensures that you cannot have several projects with the same
set of organizations or 2 projects without organization.

The link wizard has a new step to select the organization.

The REST API for Serviced Desk is a different one.

The former code was based on pycontribs/jira#388
which is closed and unmaintained. We only need to read the organizations
from the servicedesk REST API and the local code is minimal.

We can now use the normal jira library.
A normal user must be able to use the jira rest client under the hood.

Update documentation

Store original jira issues on analytic lines

Instead of the issue they are linked to in Odoo.
With the mechanism in place, if we don't import the task or bug issue
types and we synchronize the epics, the worklogs will be attached to the
epics of their tasks (of subtasks to tasks). The fields were showing the
values of the Epic (or task for subtask), though it makes much more
sense to keep the keys and URLs of the original issue and epic on the
analytic lines. We still have the link to the task if we want to get the
URL for the task they are currently linked to.

Fix project binding unique constraint

We should be able to have 2 bindings without external_id (not yet
exported)

Add wizard to link a task to JIRA

Refactorize multistep wizards with a mixin

Handle jira bindings in tasks merge wizard

Import name of Epics instead of summary

The Epic issues have a special (custom) field for their name.
In fact they use both, the custom field AND the summary field.
But I guess they are better identified by their epic name than
their summary.

Extract multi_step_wizard as an addon

Set a timeout on requests to JIRA

Fix typo in readme

Fix backend selection on wizard to link a task

The computed field was not called, due to the model being a
TransientModel, replace it by default values.

Add is_master on jira project bindings

Allow to have one project binding per project type

The unicity constraint (backend_id, odoo_id) on jira.backend.backend is
relaxed: it now allows one binding of each type.
The reason for this is:

* supporting several projects of different types is a requirements (eg.
  1 service desk and 1 software)
* but if we implement new features like "if I create a task it is
  pushed to Jira", with different projects we would not know where to
  push them

Using this constraint, we'll be able to focus new export features by
project type.

Move jira_key from project to jira project binding

As we can have more than one project binding, we cannot store a single
jira key. In case we have more than one jira key for a project, we
compute a compound key joined by commas.

Add method to handle jira API / connection errors

Add migration for 11.0.1.1.0

Fix error when several odoo users match

When we are importing a worklog for a user not yet linked and we found
several candidate users in odoo, they will both be linked with the same
jira user and make the unicity constraint fail.

Properly raise an error in this case.

Fix project_type as string

Add fallback project for worklogs

A new optional field on the backend allows to choose a fallback project
for the worklogs. When a worklog doesn't match any project linked with
Jira, they will be created there, allowing to find the misconfigurations
and fix them.

Add action to reimport worklogs from Jira

This is meant mainly to be used when a worklog has been imported in the
fallback project and we need to re-affect them to the correct project
after we linked it.

Add related action to open jira with import issues

The 'related' button on jobs which import issues or worklog will now
open jira directly on the issue.

Skip import of tasks/worklogs before batch dates

Jira may send webhooks for old records, for instance worklogs from 6
month ago because their task has been changed. This change ensures
that we never import any record which has a last update date before the
last date of batch import.

The job methods now return the result of Importer.run() so the result is
shown on the jobs in the UI.

Extract import of dependencies

Allowing to override partially the dependencies to import

Fix import of subtasks

When importing the parent of a subtask, the record in the 'parent' field
(the task data) is incomplete, it contains only a few fields. Providing
only the id to the dependency Importer will force it to read the whole
record from Jira.

Prevent duplicates with inactive projects

The constraint did not look for inactive projects, which
makes the import fail later because it finds several projects
for the same task.

Handle 404 errors when importing records

When a record does not exist on Jira:

* the job is done instead of failed
* a result on the job tells about the missing record
* the binding is deleted on Odoo
* for worklogs, the analytic line is deleted as well

Change xmlid for model_account_analytic_line

account is not necessarily installed, while analytic is installed by the
project module in any case

Partial revert of 2fa7d39

Commit title was: Skip import of tasks/worklogs before batch dates

The process is the following:
* Read T from backend, T is the is the last time we ran the import
* Create a batch job to import tasks/worklogs from T to now() and update
the backend with now()

The batch job is run asynchronously, it generates one job per task or
worklog to import between T and now(). When the jobs are executed, the
last batch date has already been updated to now(), so the jobs would
never import any record.

Fix error when force_reimport called on several records

Prevent changing task's project on binding

When the task Mapper binds a task to a task already existing in Odoo,
we must not change the project_id of the task. This is not possible as
long as we have invoiced timesheet lines, even if the id is the same
than the current one.

Add base for tests and a test for oauth

Add test for check of connection

With a fix in the method: getting the client only wasn't triggering any
error, calling 'myself' raises a 401 when we are not authenticated.

Add documentation for tests

Add travis configuration

Add tests on issue types and tasks

Add first test for analytic account lines

Make pylint-odoo happy

Add a script to initiate the Oauth dance
Co-Authored-By: guewen <guewen.baconnier@camptocamp.com>
When another user is already linked with the same jira user and matches.
Without this check, the transaction fails with a unique constraint
error.

Do not change project_id on tasks updates

When a task has invoiced timesheet lines, writing on 'project_id', even
if the id is the same, would fail because of a constraint preventing to
write project_id on timesheet lines.

Refactorize aal batch importer with 'updating since' jira method

This Jira method returns the list of ids updated since a timestamp, and
the youngest timestamp, which means we can store this timestamp and
reuse it the next time we ask the modified worklogs: this way we should
never miss any update.

To support this, a type of field which support milliseconds in datetime
is required, otherwise lose this precision that Jira gives us.

As of today, the "updated since" method exists on for worklogs on the
Jira webservice, so the rest of the batch import still have to use the
JQL filters (with minute-precision only).

Use Datetime as main format for MilliDatetime field

Store jira's 'updated_at' field to compare with binding

We can compare the millisecond dates on both sides to see if any changes
has been done on Jira and avoid useless writes.  Previously, we were
using the 'sync_date' field, which works too but will make more sync
than necessary (because the sync happens after the last jira's
updated_at value).

Fortuitously, the updated_at is also very useful for debugging purposes.

Add batch deleter for worklogs

Force reimport of worklogs as admin

Add tests for jira.backend.timestamp

Add jira.backend tests

Fix JiraTransactionCase → JiraSavepointCase 👀

Add tests for batch importer of tasks and worklogs

Add tests for worklogs deletes

Fix lint
Co-Authored-By: guewen <guewen.baconnier@camptocamp.com>
Apply suggestions from @simahawk in code review

Add scheduled action for importing deleted worklogs

Fix fetch pagination of organizations

The pagination specs of the servicedesk API are not the same than the
Jira API (respectively isLastPage vs lastPage). So the lib's
_fetch_pages does not fetch all the pages.

Optimize the requests: we get all the data at the initial call, so
the records are passed directly to "import_record" which will not do
another request.
guewen and others added 7 commits August 8, 2019 20:10
It seems that when updating other addons, even if we don't update
connector_jira, it may already create the columns, then when we update
connector_jira, it tries to create the columns when they already exist.
Check before.

Use the rendered task description as HTML

The Jira REST API returns a rendered version of the description instead
of the markup when we pass the 'expand=renderedFields' parameter.

Update vrcpy cassettes as we read expanded issues

With "expand=renderedFields"
Imported task on inactive project set task inactive too
Make epic field lookup fault tolerant

Tempo: sync status, add tests
Read the new design notes section in the readme for details.
@pedrobaeza
Copy link
Member

/ocabot merge

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Rebased to 12.0-ocabot-merge-pr-4-by-pedrobaeza-bump-no, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 12e8563 into OCA:12.0 Aug 8, 2019
OCA-git-bot added a commit that referenced this pull request Aug 8, 2019
Signed-off-by pedrobaeza
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 79e2276. Thanks a lot for contributing to OCA. ❤️

PS: Don't worry if GitHub says there are unmerged commits: it is due to a rebase before merge. All commits of this PR have been merged into 12.0.

@alexey-pelykh alexey-pelykh deleted the 12.0-mig-connector_jira branch August 8, 2019 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.