Skip to content

[18.0][IMP] queue_job: Channel default parent_id - #1020

Open
qgroulard wants to merge 2 commits into
OCA:18.0from
acsone:18.0-queue_job_channel_default_parent-qgr
Open

qgroulard wants to merge 2 commits into
OCA:18.0from
acsone:18.0-queue_job_channel_default_parent-qgr

Conversation

@qgroulard

Copy link
Copy Markdown
Contributor

Channels are configurable at DB level since #962.
To benefit fully from this new feature, we'd like to create channels in the xml data and configure them from the UI.
However, up to now, it is not allowed to create a channel without setting its parent.

I propose to remove this constraint and set 'root' as the default parent. We still make sure that every channel (except root) has a parent, but xml data can now be added without parent_id, and the parent_id won't be overwritten at each update.

@oca-cla-bot

oca-cla-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @guewen, @sbidoul,
some modules you are maintaining are being modified, check this out!

@guewen guewen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! That's right it allows to create channels with with no parent_id field in the xml and then handle it from the UI.
I wonder why the changes in create/write are needed though, and why we can't only rely on the field's default value?

Comment thread queue_job/models/queue_job_channel.py Outdated
Comment on lines +217 to +218
if "parent_id" in values:
values = self._with_default_parent(values)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we write with "parent_id": False, I think it should just fail and not replace Falsewith the root channel IMO, what is the use case for this corner case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No use case, I just wanted to make this as robust as before and prevent any path to set a channel without parent.
I agree that keeping the failure is cleaner though, I have removed this part.

Comment thread queue_job/models/queue_job_channel.py Outdated
Comment on lines +212 to +214
if channel.name == "root" and (
"parent_id" in values
or ("name" in values and not self.env.context.get("install_mode"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did you need to change the condition?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Again for robustness against a weird corner case, but this is outdated.
I think the new implementation is cleaner, thank you for your review.

Comment thread queue_job/models/queue_job_channel.py Outdated
Comment on lines +174 to +177
vals_list = [
vals if vals.get("name") == "root" else self._with_default_parent(vals)
for vals in vals_list
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't the default value enough? I do not see why we would pass an empty channel_id to create?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You are right. We still need to do something to be able to find an existing channel if there is one, see the new version.

@qgroulard
qgroulard force-pushed the 18.0-queue_job_channel_default_parent-qgr branch from 17a6d65 to 5f5b5bc Compare October 26, 2026 16:02
@OCA-git-bot OCA-git-bot added the mod:test_queue_job Module test_queue_job label Oct 26, 2026
@qgroulard
qgroulard force-pushed the 18.0-queue_job_channel_default_parent-qgr branch from 5f5b5bc to 0b7bb86 Compare October 26, 2026 16:11

@guewen guewen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

The parent is still enforced on every channels except root, but
instead of throwing an error when empty, set it to 'root' by default.
No need to force this in the data anymore, 'root' is the default value
and it should stay editable in the DB.
@qgroulard
qgroulard force-pushed the 18.0-queue_job_channel_default_parent-qgr branch from 0b7bb86 to dff164f Compare October 27, 2026 12:36
@OCA-git-bot OCA-git-bot added mod:queue_job_batch Module queue_job_batch mod:queue_job_cron Module queue_job_cron labels Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved mod:queue_job_batch Module queue_job_batch mod:queue_job_cron Module queue_job_cron mod:queue_job Module queue_job mod:test_queue_job Module test_queue_job series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants