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

[10.0] [WIP] porting redmine connector #19

Open
wants to merge 14 commits into
base: 10.0
Choose a base branch
from

Conversation

eLBati
Copy link
Member

@eLBati eLBati commented Apr 23, 2018

No description provided.

dufresnedavid and others added 11 commits April 23, 2018 11:06
Add README file

Add contributor

Add translation, complete the README file, add logo and add dependency

Rename to connector_redmine and resize logo

Remove dependency from .travis.yml

Refactor the connector using connector units properly

Fix PEP8

Add OCA as maintainer

Move sections in README.rst

Add method to search Readmine user from Redmine Adapter

Add the possibility to pass options to Redmine Synchronizers and jobs

Remove redundant line

Change str for usrt and remove unused methods

Add comment

Add the timesheet binding and add unit tests

Fix authors and replace decorator for the binder

Change logo

Fix .travis.yml, README.rst and class description
Fix README.rst

Add OCA as maintainer

Allow importing Redmine time entries directly from an employee timesheet

Fix exception and add comment

Add missing if statement

Replace redondant super statement in method

Move the timesheet binding to module connector_redmine

Add sql constraint on analytic account code

Fix dependencies and methods

Add missing translations

Fix method to import timesheets manually

Fix error in synchronizer

Fix programming issues

Fix strings and add logo
In vanilla Odoo, the timesheet is not clever. Whenever the user adds a new entry or changes a value in the widget, all previous lines are unlinked and new lines are created for all previous existing lines

Remove read access to the Redmine connector for standard users

Fix method to import timesheets

An employee should be able to import his own timesheets but not have access to the connector

For that reason, we call SUPERUSER_ID but we check that the employee has write access to the requested timesheets.

Change default timesheet line name imported from redmine

Fix description of timesheets

Add explicit mapping of field general_account_id

Fix error message

Prevent module connector from breaking tests in connector Redmine

Add mapping of product, product_uom and amount
When the timesheet is saved, if the unit_amount is 0, then it must be unlinked

Add state filter on import button

Log mapping errors in timesheet chatter

When a user imports his timesheets, instead of blocking all entries from being imported
on a mapping exception, the exception is logged in the chatter

Improve unit test coverage

Add mapping of field to_invoice
[ADD] setup.py

Prevent access errors when updating timesheet entry

Fix deletion of timesheet entry

Replace copyright headers with simplified version

Minor lint fixes

Improve Redmin Connector

Allow importing timesheets from different Redmine instances.
Each user may configure his/her Redmine server.

Improve performance by caching data of issues and project. The data of each object
is only queried one time.

Minor lint fixes

Minor fixes

Minor fixes

Fix exception handler
[MIG] Rename manifest file

[MIG] Replace "openerp" ocurrences with "odoo"

[MIG] Do not use RedmineConnectorSession anymore

(issue #212)

- extend ConnectorEnvironment to host the redmine_cache that was
  previously extended in RedmineConnectorSession

- remove session parameter from connector.get_environment (the
  connector module takes the environment from the backend object
  now). the default language from the backend is not applied there,
  because the session object is not available anymore.

- Simplify RedmineModelBinder reusing the generalizations from of
  Binder. This way the use of the session property is not needed.

- Proxy the redmine_cache of RedmineImportSyncronizer to the one saved
  in the connector environment. The same happens for RedmineAdapter

- Simplify RedmineImportSynchronizer to avoid the use of session

- remove "session" parameter from: import_batch, import_record,
  mock_delay, get_environment, import_single_user_time_entries. It is
  not replaced with "env", because env parameter passing is also
  removed in the last version of odoo_connector. the environment is
  now taken from the backend_record...

- that's why some methods pass now the backend object instead of the
  backend_id. The backend is used now to get the environment, not at
  the opossite.

[MIG] replace `hr.analytic.timesheet` by `account.analytic.line`

- since v9 the model 'hr.analytic.timesheet` has been replaced by
  `account.analytic.line`:

  https://github.com/OCA/OpenUpgrade/blob/9.0/addons/hr_timesheet/migrations/9.0.1.0/post-migration.py#L17

- note that in v9 we need also a mapper, in order to set::

       is_timesheet = True

  during the import of the timesheet records

[MIG] Use queue_job module from OCA/queue

see: OCA/queue#1

[MIG] Renamed ImportSynchronizer to Importer

- see: OCA/connector#47

[MIG] import exception module

- the job exception types has been moved to the module: `queue_job`.

- They are still loaded / proxied by the module
  `connector.exception`.

- But somehow this requires that the module is correctly imported.

- It is better to use always import. See:
  http://effbot.org/zone/import-confusion.htm

- Import made similar to:

  OCA/connector#188 (comment)

[MIG] slight changes to the Binder

- Rename 'to_backend' to 'to_external'

- Rename 'to_odoo' to 'to_internal'

see: OCA/connector@fef7ee2

pep8 adjustments

[MIG] rename ImportSynchronizers that left

[MIG] fix hr_timesheet_sheet_form

- the `buttons` element taked as reference by the previous version
  does not exist anymore

- another position was selected so the result is the same

fix pylint suggestions

fix pyflakes errors
@eLBati eLBati changed the title [10.0] porting redmine connector [10.0] [WIPporting redmine connector Apr 23, 2018
@eLBati eLBati changed the title [10.0] [WIPporting redmine connector [10.0] [WIP] porting redmine connector Apr 23, 2018
@pedrobaeza pedrobaeza added this to the 10.0 milestone Apr 23, 2018
@eLBati eLBati force-pushed the 10.0-redmine-connector-lb branch 6 times, most recently from ac8a0d1 to 74458bb Compare April 26, 2018 09:36
@eLBati eLBati force-pushed the 10.0-redmine-connector-lb branch from 74458bb to 5bfdb7d Compare May 3, 2018 08:57
IMP Allow to use an existing field in redmine project
REF to new connector API
IMP security
FIX handle ForbiddenError
IMP handle redmine users with no login field

FIX
setuptools-odoo/setuptools_odoo/core.py", line 221, in _find_addons_dir
    raise RuntimeError("More than one addons namespace found.")
@eLBati eLBati force-pushed the 10.0-redmine-connector-lb branch from 5bfdb7d to 965fd86 Compare May 24, 2018 13:54
Copy link

@yucer yucer left a comment

Choose a reason for hiding this comment

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

Task synchronization tips.

raise UserError(
'Could not connect to Redmine: %s' % ustr(e))

projects = adapter.redmine_api.project.all()
Copy link

Choose a reason for hiding this comment

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

This way checks also if the value is set for the custom field in redmine.

         projects = adapter.redmine_api.project.all()
         exist = False
+        assigned = False
 
         if projects:
             if hasattr(projects[0], 'custom_fields'):
                 for cs in projects[0].custom_fields:
                     if cs['name'] == self.contract_ref:
                         exist = True
+                        assigned = bool(cs['value'])
             elif hasattr(projects[0], self.contract_ref):
                 exist = True
 
-        if exist is True:
-            raise UserError(
-                _('Connection test succeeded\n'
-                  'Everything seems properly set up'))
-        else:
+        if not exist:
             raise UserError(
                 _("Redmine backend configuration error\n"
                   "The contract # field name doesn't exist.")
             )
+        elif not assigned:
+            raise UserError(
+                _("Redmine backend configuration error\n"
+                  "The contract # field is not assigned in Redmine.")
+            )
+        else:
+            raise UserError(
+                _('Connection test succeeded\n'
+                  'Everything seems properly set up'))

Sorry if I did mistake the format. I am learning to make reviews. :-)

if record.get('version'):
task = self.env['project.task'].search([
('project_id', '=', project.id),
('name', '=', record['version'])
Copy link

Choose a reason for hiding this comment

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

Can you describe why to you use versions ?
What about matching with record['subject'] instead of by versions ?

('name', '=', record['version'])
])
if len(task) == 1:
res['task_id'] = task.id
Copy link

Choose a reason for hiding this comment

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

The title says Redmine Versions will be synchronized but they are only bound by the task.id
An additional import is needed.

Thank you for finding the time to reach this point.

@eLBati
Copy link
Member Author

eLBati commented Dec 7, 2018

@yucer Thanks for reviewing. If you want to continue this work, feel free to create your branch based on eLBati:10.0-redmine-connector-lb.
I don't plan to work on this ATM

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.

5 participants