Skip to content
Merged
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
4 changes: 2 additions & 2 deletions queue_job/models/queue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ class JobChannel(models.Model):
@api.depends('name', 'parent_id.complete_name')
def _compute_complete_name(self):
for record in self:
# if not record.name:
# return # new record
if not record.name:
continue # new record
channel = record
parts = [channel.name]
while channel.parent_id:
Expand Down
2 changes: 2 additions & 0 deletions queue_job/readme/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Next
* [ADD] Default "related action" for jobs, opening a form or list view (when
the job is linked to respectively one record on several).
(`#46 <https://github.com/OCA/queue/pull/46>`_)
* [FIX] Error when creating a job channel manually
(`#96 <https://github.com/OCA/queue/pull/96>`_)

11.0.1.1.0 (2018-05-25)
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions queue_job/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import test_runner_channels
from . import test_runner_runner
from . import test_json_field
from . import test_model_job_channel
59 changes: 59 additions & 0 deletions queue_job/tests/test_model_job_channel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# copyright 2018 Camptocamp
# license agpl-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from psycopg2 import IntegrityError

import odoo

from odoo.tests import common


class TestJobChannel(common.TransactionCase):

def setUp(self):
super(TestJobChannel, self).setUp()
self.Channel = self.env['queue.job.channel']
self.root_channel = self.Channel.search(
[('name', '=', 'root')]
)

def test_channel_new(self):
channel = self.Channel.new()
self.assertFalse(channel.name)
self.assertFalse(channel.complete_name)

def test_channel_create(self):
channel = self.Channel.create({
'name': 'sub',
'parent_id': self.root_channel.id,
})
self.assertEqual(channel.name, 'sub')
self.assertEqual(channel.complete_name, 'root.sub')
channel2 = self.Channel.create({
'name': 'sub',
'parent_id': channel.id,
})
self.assertEqual(channel2.name, 'sub')
self.assertEqual(channel2.complete_name, 'root.sub.sub')

@odoo.tools.mute_logger('odoo.sql_db')
def test_channel_complete_name_uniq(self):
channel = self.Channel.create({
'name': 'sub',
'parent_id': self.root_channel.id,
})
self.assertEqual(channel.name, 'sub')
self.assertEqual(channel.complete_name, 'root.sub')

with self.assertRaises(IntegrityError):
self.Channel.create({
'name': 'sub',
'parent_id': self.root_channel.id,
})

def test_channel_name_get(self):
channel = self.Channel.create({
'name': 'sub',
'parent_id': self.root_channel.id,
})
self.assertEqual(channel.name_get(), [(channel.id, 'root.sub')])