Skip to content

Commit

Permalink
ADD Redmine Versions will be synchronized with Odoo tasks, using thei…
Browse files Browse the repository at this point in the history
…r name to match
  • Loading branch information
eLBati committed Aug 21, 2018
1 parent e9e675a commit 2bd4227
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion redmine_import_time_entry/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
'name': 'Redmine Import Time Entry',
'version': '10.0.1.1.0',
'version': '10.0.1.2.0',
'author': 'Savoir-faire Linux,Odoo Community Association (OCA)',
'maintainer': 'Odoo Community Association (OCA)',
'website': 'http://odoo-community.org',
Expand Down
4 changes: 4 additions & 0 deletions redmine_import_time_entry/models/redmine_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class redmine_backend(models.Model):
"to a project in Odoo. Each redmine project must have a unique "
"value for this attribute."
)
sync_tasks = fields.Boolean(
"Sync Versions -> Tasks",
help="Redmine Versions will be synchronized with Odoo tasks, "
"using their name to match")
time_entry_last_update = fields.Datetime(
'Last Time Entry Update', required=True,
# At the first import, this field must have a value so that the
Expand Down
4 changes: 4 additions & 0 deletions redmine_import_time_entry/unit/backend_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ def read(self, redmine_id):
'project_name': project.name,
'project_id': long(project.id),
'updated_on': entry.updated_on,
'comments': entry.comments,
}

if self.backend_record.sync_tasks:
res['version'] = issue.version

user = self.redmine_api.user.get(entry.user.id)
if hasattr(user, 'login'):
res['user_login'] = user.login
Expand Down
15 changes: 13 additions & 2 deletions redmine_import_time_entry/unit/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class TimeEntryImportMapper(Component):
@mapping
def name(self, record):
name = self.backend_record.location
if record.get('comments'):
name = "%s - %s" % (record['comments'], name)

issue_id = record['issue_id']

Expand Down Expand Up @@ -64,11 +66,20 @@ def account_id(self, record):
})

project = projects[0]

return {
res = {
'project_id': project.id,
}

if record.get('version'):
task = self.env['project.task'].search([
('project_id', '=', project.id),
('name', '=', record['version'])
])
if len(task) == 1:
res['task_id'] = task.id

return res

@mapping
def user_id(self, record):
user = None
Expand Down
1 change: 1 addition & 0 deletions redmine_import_time_entry/views/redmine_backend_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
string="Test Contract # field name"
colspan="2"
/>
<field name="sync_tasks" cospan="2"/>
</group>
<group>
<field name="time_entry_last_update"/>
Expand Down

0 comments on commit 2bd4227

Please sign in to comment.