-
-
Notifications
You must be signed in to change notification settings - Fork 535
[18.0][MIG] queue_job_batch, test_queue_job_batch: Migration to 18.0 #744
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d48b29f
[ADD] queue_job_batch
etobella 53ef01b
[11.0][FIX] queue_job_batch: view all in the systray not working
LoisRForgeFlow 196b897
[11.0][FIX] queue_job_batch:
LoisRForgeFlow 564db17
[MIG] queue_job_batch, test_queue_job_batch: Migration to 12.0
LoisRForgeFlow 0144e1d
[12.0] [FIX] Allow users from group queue_job_batch_user to write on …
qgroulard 11141d0
Added translation using Weblate (French)
ypapouin f1f7e6e
[IMP] queue_job_batch, test_queue_job_batch: black, isort, prettier
anothingguy f25e1bd
[14.0][MIG] queue_job_batch, test_queue_job_batch: Migration to 14.0
anothingguy c1786ee
[MIG] queue_job_batch, test_queue_job_batch: Migration to 15.0
amh-mw e1d0fb1
[IMP] queue_job_batch, test_queue_job_batch: black, isort, prettier
JasminSForgeFlow 64befc2
[MIG] queue_job_batch, test_queue_job_batch: Migration to 16.0
JasminSForgeFlow 9995386
Added translation using Weblate (Spanish)
Ivorra78 dab33fa
Added translation using Weblate (Italian)
mymage 5cb212e
[IMP] queue_job_batch: Fix systray icon visibility for allowed group …
JasminSForgeFlow c2b7ee6
[IMP] queue_job_batch, test_queue_job_batch: black, isort, prettier
anothingguy 5e45eb1
[14.0][MIG] queue_job_batch, test_queue_job_batch: Migration to 14.0
anothingguy 1982009
[MIG] queue_job_batch, test_queue_job_batch: Migration to 15.0
amh-mw 30354ba
[IMP] queue_job_batch, test_queue_job_batch: black, isort, prettier
JasminSForgeFlow ef9ca9a
[MIG] queue_job_batch, test_queue_job_batch: Migration to 16.0
JasminSForgeFlow 0268593
Added translation using Weblate (Italian)
mymage 6c76dd5
[IMP] queue_job_batch, test_queue_job_batch: pre-commit auto fixes
yankinmax 752c650
[MIG] queue_job_batch, test_queue_job_batch: Migration to 18.0
yankinmax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,15 +38,13 @@ Example: | |
| .. code:: python | ||
|
|
||
| from odoo import models, fields, api | ||
| from odoo.addons.queue_job.job import job | ||
|
|
||
|
|
||
| class MyModel(models.Model): | ||
| _name = 'my.model' | ||
| _name = 'my.model' | ||
|
|
||
| @api.multi | ||
| @job | ||
| def my_method(self, a, k=None): | ||
| _logger.info('executed with a: %s and k: %s', a, k) | ||
| def my_method(self, a, k=None): | ||
| _logger.info('executed with a: %s and k: %s', a, k) | ||
|
|
||
|
|
||
| class MyOtherModel(models.Model): | ||
|
|
@@ -55,11 +53,9 @@ Example: | |
| @api.multi | ||
| def button_do_stuff(self): | ||
| batch = self.env['queue.job.batch'].get_new_batch('Group') | ||
| model = self.env['my.model'].with_context(job_batch=batch) | ||
| for i in range(1, 100): | ||
| self.env['my.model'].with_context( | ||
| job_batch=batch | ||
| ).with_delay().my_method('a', k=i) | ||
| batch.enqueue() | ||
| model.with_delay().my_method('a', k=i) | ||
|
|
||
| In the snippet of code above, when we call ``button_do_stuff``, 100 jobs | ||
| capturing the method and arguments will be postponed. It will be | ||
|
|
@@ -101,16 +97,21 @@ Authors | |
| Contributors | ||
| ------------ | ||
|
|
||
| - Enric Tobella <[email protected]> | ||
| - Enric Tobella <[email protected]> | ||
|
|
||
| - `Trobz <https://trobz.com>`__: | ||
|
|
||
| - Hoang Diep <[email protected]> | ||
|
|
||
| - `Trobz <https://trobz.com>`__: | ||
| - `ForgeFlow <https://forgeflow.com>`__: | ||
|
|
||
| - Hoang Diep <[email protected]> | ||
| - Lois Rilo <[email protected]> | ||
| - Jasmin Solanki <[email protected]> | ||
|
|
||
| - `ForgeFlow <https://forgeflow.com>`__: | ||
| - `Camptocamp <https://camptocamp.com>`__: | ||
|
|
||
| - Lois Rilo <lois.rilo@forgeflow.com> | ||
| - Jasmin Solanki <jasmin.solanki@forgeflow.com> | ||
| - Maksym Yankin <maksym.yankin@camptocamp.com> | ||
| - Iván Todorovich <ivan.todorovich@camptocamp.com> | ||
|
|
||
| Other credits | ||
| ------------- | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| from . import controllers | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import webclient |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Copyright 2025 Camptocamp SA (https://www.camptocamp.com). | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo.http import request | ||
|
|
||
| from odoo.addons.mail.controllers.webclient import WebclientController | ||
|
|
||
|
|
||
| class WebClient(WebclientController): | ||
| def _process_request_for_internal_user(self, store, **kwargs): | ||
| res = super()._process_request_for_internal_user(store, **kwargs) | ||
| if kwargs.get("systray_get_queue_job_batches"): | ||
| # sudo: bus.bus: reading non-sensitive last id | ||
| bus_last_id = request.env["bus.bus"].sudo()._bus_last_id() | ||
| batches = request.env.user._get_queue_job_batches() | ||
| store.add(batches) | ||
| store.add( | ||
| { | ||
| "queueJobBatchCounter": len(batches), | ||
| "queueJobBatchCounterBusId": bus_last_id, | ||
| } | ||
| ) | ||
| return res | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Copyright 2025 Camptocamp SA (https://www.camptocamp.com). | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
|
|
||
| def migrate(cr, version): | ||
| cr.execute( | ||
| """ | ||
| UPDATE queue_job_batch | ||
| SET state = 'pending' | ||
| WHERE state = 'draft' | ||
| """ | ||
| ) | ||
| cr.execute( | ||
| """ | ||
| UPDATE queue_job_batch | ||
| SET is_read = FALSE | ||
| WHERE state != 'finished' AND is_read | ||
| """ | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| from . import queue_job, queue_job_batch | ||
| from . import queue_job_batch | ||
| from . import queue_job | ||
| from . import res_users |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Copyright 2025 Camptocamp SA (https://www.camptocamp.com). | ||
| # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
|
||
| from odoo import models | ||
|
|
||
|
|
||
| class Users(models.Model): | ||
| _name = "res.users" | ||
| _inherit = ["res.users"] | ||
|
|
||
| def _init_store_data(self, store): | ||
| res = super()._init_store_data(store) | ||
| store.add( | ||
| { | ||
| "hasQueueJobBatchUserGroup": self.env.user.has_group( | ||
| "queue_job_batch.group_queue_job_batch_user" | ||
| ), | ||
| } | ||
| ) | ||
| return res | ||
|
|
||
| def _get_queue_job_batches(self): | ||
| # See :meth:`controllers.webclient.WebClient._process_request_for_internal_user` | ||
| self.ensure_one() | ||
| return self.env["queue.job.batch"].search( | ||
| [ | ||
| ("user_id", "=", self.id), | ||
| ("is_read", "=", False), | ||
| ] | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,7 @@ | |
| - [ForgeFlow](https://forgeflow.com): | ||
| - Lois Rilo \<<[email protected]>\> | ||
| - Jasmin Solanki \<<[email protected]>\> | ||
|
|
||
| - [Camptocamp](https://camptocamp.com): | ||
| - Maksym Yankin \<<[email protected]>\> | ||
| - Iván Todorovich \<<[email protected]>\> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need this depends? Job count is not stored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, for the UI. I'd be necessary when reading the field programatically, though, without invalidating caches. It's a habit 😓