From c91e3128d78abe053d387a838d7b362172b4e398 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Tue, 9 Jul 2019 09:42:36 +0200 Subject: [PATCH 01/35] [ADD] queue_job_batch [UPD] Update queue_job_batch.pot --- test_queue_job_batch/README.rst | 73 +++ test_queue_job_batch/__init__.py | 0 test_queue_job_batch/__manifest__.py | 15 + .../i18n/test_queue_job_batch.pot | 14 + test_queue_job_batch/readme/CONTRIBUTORS.rst | 1 + test_queue_job_batch/readme/DESCRIPTION.rst | 1 + .../static/description/icon.png | Bin 0 -> 1803 bytes .../static/description/icon.svg | 127 ++++++ .../static/description/index.html | 419 ++++++++++++++++++ test_queue_job_batch/tests/__init__.py | 1 + .../tests/test_queue_job_batch.py | 67 +++ 11 files changed, 718 insertions(+) create mode 100644 test_queue_job_batch/README.rst create mode 100644 test_queue_job_batch/__init__.py create mode 100644 test_queue_job_batch/__manifest__.py create mode 100644 test_queue_job_batch/i18n/test_queue_job_batch.pot create mode 100644 test_queue_job_batch/readme/CONTRIBUTORS.rst create mode 100644 test_queue_job_batch/readme/DESCRIPTION.rst create mode 100644 test_queue_job_batch/static/description/icon.png create mode 100644 test_queue_job_batch/static/description/icon.svg create mode 100644 test_queue_job_batch/static/description/index.html create mode 100644 test_queue_job_batch/tests/__init__.py create mode 100644 test_queue_job_batch/tests/test_queue_job_batch.py diff --git a/test_queue_job_batch/README.rst b/test_queue_job_batch/README.rst new file mode 100644 index 0000000000..dc825db2e1 --- /dev/null +++ b/test_queue_job_batch/README.rst @@ -0,0 +1,73 @@ +==================== +Test Job Queue Batch +==================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github + :target: https://github.com/OCA/queue/tree/11.0/test_queue_job_batch + :alt: OCA/queue +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/queue-11-0/queue-11-0-test_queue_job_batch + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/230/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This addon is used to test the queue job batch functionality + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Creu Blanca + +Contributors +~~~~~~~~~~~~ + +* Enric Tobella + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/queue `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/test_queue_job_batch/__init__.py b/test_queue_job_batch/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test_queue_job_batch/__manifest__.py b/test_queue_job_batch/__manifest__.py new file mode 100644 index 0000000000..f4351af798 --- /dev/null +++ b/test_queue_job_batch/__manifest__.py @@ -0,0 +1,15 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + + +{ + 'name': 'Test Job Queue Batch', + 'version': '11.0.1.1.0', + 'author': 'Creu Blanca,Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/queue/', + 'license': 'AGPL-3', + 'category': 'Generic Modules', + 'depends': [ + 'queue_job_batch', + 'test_queue_job', + ], +} diff --git a/test_queue_job_batch/i18n/test_queue_job_batch.pot b/test_queue_job_batch/i18n/test_queue_job_batch.pot new file mode 100644 index 0000000000..447d3bb3ca --- /dev/null +++ b/test_queue_job_batch/i18n/test_queue_job_batch.pot @@ -0,0 +1,14 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + diff --git a/test_queue_job_batch/readme/CONTRIBUTORS.rst b/test_queue_job_batch/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..93ec993e04 --- /dev/null +++ b/test_queue_job_batch/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Enric Tobella diff --git a/test_queue_job_batch/readme/DESCRIPTION.rst b/test_queue_job_batch/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..e647a1de27 --- /dev/null +++ b/test_queue_job_batch/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This addon is used to test the queue job batch functionality diff --git a/test_queue_job_batch/static/description/icon.png b/test_queue_job_batch/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a735e94d10274d83c86106188a9339a8132d3e0c GIT binary patch literal 1803 zcmah~c~H~W7XAgv(y&8>7!g9?2_uX6j9M0H2w{85B1;<{1rjv~0!hFHRF)XSs%&K| zy8?01ZzMf}g@Olm>$+c8(L7t8l94@SXuM#Y%*o&QRbl=pI4m0ANqL(m=VhOB6+L z*Lhdsd4F2?`FL_11&EK2w~3@iojXOQQ*3B)XUZjxC;)(DcoLig5-P-%UeO4O;j8M> z5z5w&>``j7wRQDV!nGRcwLAY-?IhJ8X-03muA!FvvPmjPLLFW$74FebVjc)}q?aHH zFett0P9zgO$<-1zeWEsVCA51utf&wyfBnP4 zYui_Ca`pMJWPQQIM)$SdG*dPyUpzv<+obbut06zJp(C9v+kFT$g+hKQwf|ReHT?yo zHrWVM?x3A=>1bRjudwvQAYnd=b}QPoVOmDG@una4{ob^VXoI;sM^(+N)yy}cI-%^Y zH4J+>PI%}?|Ig8Hv9V1lu)ynM0`rq9YWl|x`or_sR;%k;WFB@UtQ(P@9XxApZMiKo z+b_{3xpAviio=LK&Eyevrz(1P$Eq7SVEB<^+~7Dn4m@%D2?y!`OnM_2$5XIJOuz8o^VI{hTb=VJrwRwQv(V^g40 zM?pu;)J55ClhJk;P?l=QVE^2sM1~3iyqU5ncT1n$f#}$n@pr<36201#pqWRIF|u>7 z7J02Kt>$kINfnF?DZE)hY`e|m>Gc+b-?v_)l(|CU{9;Is|*(t1cgRGs1ZNxCP^;VJCk zfD4W?m^iEkD=w_T=&wXO>FC|16^18h{$H(mfRWFW`D=8`%2$M`v@8gB!pESar2=24~@ zY0LpD0VwMR;|@76rl@fl1osV4#cDL1(&@slA5H}jHzVjumaPn#08U|4H{v`Ay1B7l)atQ5H-JJEenHC24` zlQ&RHRq71$t9}1t2!$_pd&Ec${+iT$xNYKEmT0o{wC?oMvxLval8<@^j%>H?W4V^WqaAQUGU`^1QF?3V7&bj)6;dWD0UNa*~U zy7SGt4Q;N6fvI&Qkz#&8?F6}$&D!DeC+n2T+DS=!qT~--xC=5gWM^r76L9TpT;^zU zp%#qA-g-riw9JpwQAX^#AY<^8KxI_)x8G>-A1xk>Lz^TW?yx@3!98mOy~Jp=7_w$F}>xp&gnbNY8kH_ee~;CT`T$B~s*QLN?5sOj{Q0bmRGdj$X{3Vamcw?nc&z(4hrqAcMB zC}VpL1}Vq6`*?}6?t`l`1`aJ!oWShiDjU|YhyDP$9fEDW~l4_xhFwRfP9Cw*?0`4OzpVh;{rTgy$KKSB + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test_queue_job_batch/static/description/index.html b/test_queue_job_batch/static/description/index.html new file mode 100644 index 0000000000..add72d2d68 --- /dev/null +++ b/test_queue_job_batch/static/description/index.html @@ -0,0 +1,419 @@ + + + + + + +Test Job Queue Batch + + + +
+

Test Job Queue Batch

+ + +

Beta License: AGPL-3 OCA/queue Translate me on Weblate Try me on Runbot

+

This addon is used to test the queue job batch functionality

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Creu Blanca
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/queue project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/test_queue_job_batch/tests/__init__.py b/test_queue_job_batch/tests/__init__.py new file mode 100644 index 0000000000..39cec46423 --- /dev/null +++ b/test_queue_job_batch/tests/__init__.py @@ -0,0 +1 @@ +from . import test_queue_job_batch diff --git a/test_queue_job_batch/tests/test_queue_job_batch.py b/test_queue_job_batch/tests/test_queue_job_batch.py new file mode 100644 index 0000000000..d0d283ba87 --- /dev/null +++ b/test_queue_job_batch/tests/test_queue_job_batch.py @@ -0,0 +1,67 @@ +from odoo.tests.common import TransactionCase +from odoo.addons.queue_job.job import Job + + +class TestQueueJobGroup(TransactionCase): + def test_batch(self): + self.cr.execute('delete from queue_job') + batch = self.env['queue.job.batch'].get_new_batch('TEST') + self.assertFalse(batch.job_ids) + model = self.env['test.queue.job'].with_context( + job_batch=batch + ) + job_1 = model.with_delay().testing_method() + self.assertEqual(job_1.db_record().state, 'pending') + job_2 = model.with_delay().testing_method() + self.assertEqual(job_2.db_record().state, 'pending') + batch.refresh() + jobs = job_1.db_record() + jobs |= job_2.db_record() + self.assertEqual(jobs, batch.job_ids) + batch.set_read() + self.assertTrue(batch.is_read) + self.assertEqual(batch.state, 'draft') + self.assertEqual(job_2.state, 'pending') + self.assertEqual(job_2.state, 'pending') + batch.enqueue() + self.assertEqual(batch.state, 'enqueued') + self.assertEqual(job_2.state, 'pending') + self.assertEqual(job_2.state, 'pending') + job_domain = [ + ('uuid', '!=', job_1.uuid), + ('uuid', '!=', job_2.uuid), + ] + update = self.env['queue.job'].search(job_domain) + self.assertFalse(update) + job = Job.load(self.env, job_1.uuid) + job.perform() + job.set_done() + job.store() + update = self.env['queue.job'].search(job_domain) + self.assertTrue(update) + self.assertEqual(1, len(update)) + job = Job.load(self.env, update.uuid) + job.perform() + job.set_done() + job.store() + batch.refresh() + self.assertEqual(batch.state, 'progress') + self.assertEqual(batch.completeness, 0.5) + job_domain.append(('uuid', '!=', update.uuid)) + update = self.env['queue.job'].search(job_domain) + self.assertFalse(update) + job = Job.load(self.env, job_2.uuid) + job.perform() + job.set_done() + job.store() + update = self.env['queue.job'].search(job_domain) + self.assertTrue(update) + self.assertEqual(1, len(update)) + job = Job.load(self.env, update.uuid) + job.perform() + job.set_done() + job.store() + batch.refresh() + self.assertEqual(batch.state, 'finished') + self.assertEqual(batch.completeness, 1) + self.assertFalse(batch.is_read) From 4a7f849f8a4488af2ade0e5841117cac7246e9d1 Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Thu, 31 Oct 2019 12:55:20 +0100 Subject: [PATCH 02/35] [MIG] queue_job_batch, test_queue_job_batch: Migration to 12.0 standard migration and some little ux improvements: now hide button is a fa-check button that on click just marks as read the batch, do not navigate to it and updates immediately the systray. --- test_queue_job_batch/README.rst | 11 ++++++----- test_queue_job_batch/__manifest__.py | 2 +- test_queue_job_batch/i18n/test_queue_job_batch.pot | 2 +- test_queue_job_batch/readme/CONTRIBUTORS.rst | 1 + test_queue_job_batch/static/description/index.html | 7 ++++--- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/test_queue_job_batch/README.rst b/test_queue_job_batch/README.rst index dc825db2e1..bfe16f7743 100644 --- a/test_queue_job_batch/README.rst +++ b/test_queue_job_batch/README.rst @@ -14,13 +14,13 @@ Test Job Queue Batch :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github - :target: https://github.com/OCA/queue/tree/11.0/test_queue_job_batch + :target: https://github.com/OCA/queue/tree/12.0/test_queue_job_batch :alt: OCA/queue .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/queue-11-0/queue-11-0-test_queue_job_batch + :target: https://translation.odoo-community.org/projects/queue-12-0/queue-12-0-test_queue_job_batch :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/230/11.0 + :target: https://runbot.odoo-community.org/runbot/230/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -38,7 +38,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -54,6 +54,7 @@ Contributors ~~~~~~~~~~~~ * Enric Tobella +* Lois Rilo Maintainers ~~~~~~~~~~~ @@ -68,6 +69,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/queue `_ project on GitHub. +This module is part of the `OCA/queue `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/test_queue_job_batch/__manifest__.py b/test_queue_job_batch/__manifest__.py index f4351af798..09a749338e 100644 --- a/test_queue_job_batch/__manifest__.py +++ b/test_queue_job_batch/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Test Job Queue Batch', - 'version': '11.0.1.1.0', + 'version': '12.0.1.1.0', 'author': 'Creu Blanca,Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/queue/', 'license': 'AGPL-3', diff --git a/test_queue_job_batch/i18n/test_queue_job_batch.pot b/test_queue_job_batch/i18n/test_queue_job_batch.pot index 447d3bb3ca..d2e396f159 100644 --- a/test_queue_job_batch/i18n/test_queue_job_batch.pot +++ b/test_queue_job_batch/i18n/test_queue_job_batch.pot @@ -3,7 +3,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 11.0\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" diff --git a/test_queue_job_batch/readme/CONTRIBUTORS.rst b/test_queue_job_batch/readme/CONTRIBUTORS.rst index 93ec993e04..c34631de53 100644 --- a/test_queue_job_batch/readme/CONTRIBUTORS.rst +++ b/test_queue_job_batch/readme/CONTRIBUTORS.rst @@ -1 +1,2 @@ * Enric Tobella +* Lois Rilo diff --git a/test_queue_job_batch/static/description/index.html b/test_queue_job_batch/static/description/index.html index add72d2d68..50779fbdf6 100644 --- a/test_queue_job_batch/static/description/index.html +++ b/test_queue_job_batch/static/description/index.html @@ -367,7 +367,7 @@

Test Job Queue Batch

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/queue Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/queue Translate me on Weblate Try me on Runbot

This addon is used to test the queue job batch functionality

Table of contents

@@ -386,7 +386,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -401,6 +401,7 @@

Authors

Contributors

@@ -410,7 +411,7 @@

Maintainers

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/queue project on GitHub.

+

This module is part of the OCA/queue project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

From 3ff734d70809a1d6854fb53dcd26a863f1ede72a Mon Sep 17 00:00:00 2001 From: Yann Papouin Date: Fri, 20 Nov 2020 16:14:26 +0000 Subject: [PATCH 03/35] Added translation using Weblate (French) --- test_queue_job_batch/i18n/fr.po | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 test_queue_job_batch/i18n/fr.po diff --git a/test_queue_job_batch/i18n/fr.po b/test_queue_job_batch/i18n/fr.po new file mode 100644 index 0000000000..fd6c4f872f --- /dev/null +++ b/test_queue_job_batch/i18n/fr.po @@ -0,0 +1,14 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" From 7b02cb06e84024f893de4e5923e7a76571d6fef0 Mon Sep 17 00:00:00 2001 From: Diep Huu Hoang Date: Fri, 3 Dec 2021 15:39:09 +0700 Subject: [PATCH 04/35] [IMP] queue_job_batch, test_queue_job_batch: black, isort, prettier --- test_queue_job_batch/__manifest__.py | 18 ++++---- .../tests/test_queue_job_batch.py | 43 +++++++++---------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/test_queue_job_batch/__manifest__.py b/test_queue_job_batch/__manifest__.py index 09a749338e..b5d3e8d2ff 100644 --- a/test_queue_job_batch/__manifest__.py +++ b/test_queue_job_batch/__manifest__.py @@ -2,14 +2,14 @@ { - 'name': 'Test Job Queue Batch', - 'version': '12.0.1.1.0', - 'author': 'Creu Blanca,Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/queue/', - 'license': 'AGPL-3', - 'category': 'Generic Modules', - 'depends': [ - 'queue_job_batch', - 'test_queue_job', + "name": "Test Job Queue Batch", + "version": "12.0.1.1.0", + "author": "Creu Blanca,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/queue", + "license": "AGPL-3", + "category": "Generic Modules", + "depends": [ + "queue_job_batch", + "test_queue_job", ], } diff --git a/test_queue_job_batch/tests/test_queue_job_batch.py b/test_queue_job_batch/tests/test_queue_job_batch.py index d0d283ba87..a85a00efe3 100644 --- a/test_queue_job_batch/tests/test_queue_job_batch.py +++ b/test_queue_job_batch/tests/test_queue_job_batch.py @@ -1,43 +1,42 @@ from odoo.tests.common import TransactionCase + from odoo.addons.queue_job.job import Job class TestQueueJobGroup(TransactionCase): def test_batch(self): - self.cr.execute('delete from queue_job') - batch = self.env['queue.job.batch'].get_new_batch('TEST') + self.cr.execute("delete from queue_job") + batch = self.env["queue.job.batch"].get_new_batch("TEST") self.assertFalse(batch.job_ids) - model = self.env['test.queue.job'].with_context( - job_batch=batch - ) + model = self.env["test.queue.job"].with_context(job_batch=batch) job_1 = model.with_delay().testing_method() - self.assertEqual(job_1.db_record().state, 'pending') + self.assertEqual(job_1.db_record().state, "pending") job_2 = model.with_delay().testing_method() - self.assertEqual(job_2.db_record().state, 'pending') + self.assertEqual(job_2.db_record().state, "pending") batch.refresh() jobs = job_1.db_record() jobs |= job_2.db_record() self.assertEqual(jobs, batch.job_ids) batch.set_read() self.assertTrue(batch.is_read) - self.assertEqual(batch.state, 'draft') - self.assertEqual(job_2.state, 'pending') - self.assertEqual(job_2.state, 'pending') + self.assertEqual(batch.state, "draft") + self.assertEqual(job_2.state, "pending") + self.assertEqual(job_2.state, "pending") batch.enqueue() - self.assertEqual(batch.state, 'enqueued') - self.assertEqual(job_2.state, 'pending') - self.assertEqual(job_2.state, 'pending') + self.assertEqual(batch.state, "enqueued") + self.assertEqual(job_2.state, "pending") + self.assertEqual(job_2.state, "pending") job_domain = [ - ('uuid', '!=', job_1.uuid), - ('uuid', '!=', job_2.uuid), + ("uuid", "!=", job_1.uuid), + ("uuid", "!=", job_2.uuid), ] - update = self.env['queue.job'].search(job_domain) + update = self.env["queue.job"].search(job_domain) self.assertFalse(update) job = Job.load(self.env, job_1.uuid) job.perform() job.set_done() job.store() - update = self.env['queue.job'].search(job_domain) + update = self.env["queue.job"].search(job_domain) self.assertTrue(update) self.assertEqual(1, len(update)) job = Job.load(self.env, update.uuid) @@ -45,16 +44,16 @@ def test_batch(self): job.set_done() job.store() batch.refresh() - self.assertEqual(batch.state, 'progress') + self.assertEqual(batch.state, "progress") self.assertEqual(batch.completeness, 0.5) - job_domain.append(('uuid', '!=', update.uuid)) - update = self.env['queue.job'].search(job_domain) + job_domain.append(("uuid", "!=", update.uuid)) + update = self.env["queue.job"].search(job_domain) self.assertFalse(update) job = Job.load(self.env, job_2.uuid) job.perform() job.set_done() job.store() - update = self.env['queue.job'].search(job_domain) + update = self.env["queue.job"].search(job_domain) self.assertTrue(update) self.assertEqual(1, len(update)) job = Job.load(self.env, update.uuid) @@ -62,6 +61,6 @@ def test_batch(self): job.set_done() job.store() batch.refresh() - self.assertEqual(batch.state, 'finished') + self.assertEqual(batch.state, "finished") self.assertEqual(batch.completeness, 1) self.assertFalse(batch.is_read) From a2c9453e892cb9a0907527bda23d4235b587e5cc Mon Sep 17 00:00:00 2001 From: Diep Huu Hoang Date: Fri, 3 Dec 2021 16:58:11 +0700 Subject: [PATCH 05/35] [14.0][MIG] queue_job_batch, test_queue_job_batch: Migration to 14.0 --- test_queue_job_batch/README.rst | 17 ++++++++++---- test_queue_job_batch/__manifest__.py | 2 +- .../i18n/test_queue_job_batch.pot | 5 ++-- test_queue_job_batch/readme/CONTRIBUTORS.rst | 2 ++ test_queue_job_batch/readme/CREDITS.rst | 1 + .../static/description/index.html | 23 +++++++++++++++---- 6 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 test_queue_job_batch/readme/CREDITS.rst diff --git a/test_queue_job_batch/README.rst b/test_queue_job_batch/README.rst index bfe16f7743..9512197214 100644 --- a/test_queue_job_batch/README.rst +++ b/test_queue_job_batch/README.rst @@ -14,13 +14,13 @@ Test Job Queue Batch :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github - :target: https://github.com/OCA/queue/tree/12.0/test_queue_job_batch + :target: https://github.com/OCA/queue/tree/14.0/test_queue_job_batch :alt: OCA/queue .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/queue-12-0/queue-12-0-test_queue_job_batch + :target: https://translation.odoo-community.org/projects/queue-14-0/queue-14-0-test_queue_job_batch :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/230/12.0 + :target: https://runbot.odoo-community.org/runbot/230/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -38,7 +38,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -55,6 +55,13 @@ Contributors * Enric Tobella * Lois Rilo +* `Trobz `_: + * Hoang Diep + +Other credits +~~~~~~~~~~~~~ + +The migration of this module from 12.0 to 14.0 was financially supported by Camptocamp Maintainers ~~~~~~~~~~~ @@ -69,6 +76,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/queue `_ project on GitHub. +This module is part of the `OCA/queue `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/test_queue_job_batch/__manifest__.py b/test_queue_job_batch/__manifest__.py index b5d3e8d2ff..74841f66c1 100644 --- a/test_queue_job_batch/__manifest__.py +++ b/test_queue_job_batch/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Test Job Queue Batch", - "version": "12.0.1.1.0", + "version": "14.0.1.0.0", "author": "Creu Blanca,Odoo Community Association (OCA)", "website": "https://github.com/OCA/queue", "license": "AGPL-3", diff --git a/test_queue_job_batch/i18n/test_queue_job_batch.pot b/test_queue_job_batch/i18n/test_queue_job_batch.pot index d2e396f159..4d8b20f912 100644 --- a/test_queue_job_batch/i18n/test_queue_job_batch.pot +++ b/test_queue_job_batch/i18n/test_queue_job_batch.pot @@ -3,12 +3,11 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" - diff --git a/test_queue_job_batch/readme/CONTRIBUTORS.rst b/test_queue_job_batch/readme/CONTRIBUTORS.rst index c34631de53..76bc3d9075 100644 --- a/test_queue_job_batch/readme/CONTRIBUTORS.rst +++ b/test_queue_job_batch/readme/CONTRIBUTORS.rst @@ -1,2 +1,4 @@ * Enric Tobella * Lois Rilo +* `Trobz `_: + * Hoang Diep diff --git a/test_queue_job_batch/readme/CREDITS.rst b/test_queue_job_batch/readme/CREDITS.rst new file mode 100644 index 0000000000..ca6e4f9cdb --- /dev/null +++ b/test_queue_job_batch/readme/CREDITS.rst @@ -0,0 +1 @@ +The migration of this module from 12.0 to 14.0 was financially supported by Camptocamp diff --git a/test_queue_job_batch/static/description/index.html b/test_queue_job_batch/static/description/index.html index 50779fbdf6..3112b1460c 100644 --- a/test_queue_job_batch/static/description/index.html +++ b/test_queue_job_batch/static/description/index.html @@ -367,7 +367,7 @@

Test Job Queue Batch

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/queue Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/queue Translate me on Weblate Try me on Runbot

This addon is used to test the queue job batch functionality

Table of contents

@@ -376,7 +376,8 @@

Test Job Queue Batch

  • Credits
  • @@ -386,7 +387,7 @@

    Bug Tracker

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    @@ -402,16 +403,28 @@

    Contributors

    +
    +
    +

    Other credits

    +

    The migration of this module from 12.0 to 14.0 was financially supported by Camptocamp

    -

    Maintainers

    +

    Maintainers

    This module is maintained by the OCA.

    Odoo Community Association

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    -

    This module is part of the OCA/queue project on GitHub.

    +

    This module is part of the OCA/queue project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    From 669cd4bb1ef352920e3c49e6d64da7ecd9263868 Mon Sep 17 00:00:00 2001 From: Adam Heinz Date: Sun, 22 Jan 2023 09:21:59 -0500 Subject: [PATCH 06/35] [MIG] queue_job_batch, test_queue_job_batch: Migration to 15.0 --- test_queue_job_batch/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_queue_job_batch/__manifest__.py b/test_queue_job_batch/__manifest__.py index 74841f66c1..63340bdafe 100644 --- a/test_queue_job_batch/__manifest__.py +++ b/test_queue_job_batch/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Test Job Queue Batch", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "author": "Creu Blanca,Odoo Community Association (OCA)", "website": "https://github.com/OCA/queue", "license": "AGPL-3", From 9bd64b89e30540a1dd75ac5bf406e67f3eb6f3d4 Mon Sep 17 00:00:00 2001 From: JasminSForgeFlow Date: Wed, 1 Nov 2023 15:21:30 +0530 Subject: [PATCH 07/35] [IMP] queue_job_batch, test_queue_job_batch: black, isort, prettier --- test_queue_job_batch/README.rst | 23 +++++----- .../static/description/index.html | 42 ++++++++++--------- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/test_queue_job_batch/README.rst b/test_queue_job_batch/README.rst index 9512197214..cc8ff9a72f 100644 --- a/test_queue_job_batch/README.rst +++ b/test_queue_job_batch/README.rst @@ -2,10 +2,13 @@ Test Job Queue Batch ==================== -.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:64220ab4fcbcae233c9e61c22e7fa90d88b1d494c301f55cb3834653fe7a06e5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status @@ -14,16 +17,16 @@ Test Job Queue Batch :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github - :target: https://github.com/OCA/queue/tree/14.0/test_queue_job_batch + :target: https://github.com/OCA/queue/tree/16.0/test_queue_job_batch :alt: OCA/queue .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/queue-14-0/queue-14-0-test_queue_job_batch + :target: https://translation.odoo-community.org/projects/queue-16-0/queue-16-0-test_queue_job_batch :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/230/14.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/queue&target_branch=16.0 + :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This addon is used to test the queue job batch functionality @@ -37,8 +40,8 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -76,6 +79,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/queue `_ project on GitHub. +This module is part of the `OCA/queue `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/test_queue_job_batch/static/description/index.html b/test_queue_job_batch/static/description/index.html index 3112b1460c..c5c51402df 100644 --- a/test_queue_job_batch/static/description/index.html +++ b/test_queue_job_batch/static/description/index.html @@ -1,20 +1,20 @@ - + - + Test Job Queue Batch + + +
    +

    Job Queue Batch

    + + +

    Beta License: AGPL-3 OCA/queue Translate me on Weblate Try me on Runbot

    +

    This addon adds an a grouper for queue jobs.

    +

    It allows to show your jobs in a batched form in order to know better the +results.

    +

    Example:

    +
    +from odoo import models, fields, api
    +from odoo.addons.queue_job.job import job
    +
    +class MyModel(models.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)
    +
    +
    +class MyOtherModel(models.Model):
    +    _name = 'my.other.model'
    +
    +    @api.multi
    +    def button_do_stuff(self):
    +        batch = self.env['queue.job.batch'].get_new_batch('Group')
    +        for i in range(1, 100):
    +            self.env['my.model'].with_context(
    +                job_batch=batch
    +            ).with_delay().my_method('a', k=i)
    +        batch.enqueue()
    +
    +

    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 executed as +soon as the Jobrunner has a free bucket, which can be instantaneous if no other +job is running.

    +

    Once all the jobs have finished, the grouper will be marked as finished.

    +

    Table of contents

    + +
    +

    Usage

    +

    You can manage your batch jobs from the Systray. A new button will be shown +with your currently executing job batches and the recently finished job groups.

    +
    +
    +

    Bug Tracker

    +

    Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

    +

    Do not contact contributors directly about support or help with technical issues.

    +
    +
    +

    Credits

    +
    +

    Authors

    +
      +
    • Creu Blanca
    • +
    +
    +
    +

    Contributors

    + +
    +
    +

    Maintainers

    +

    This module is maintained by the OCA.

    +Odoo Community Association +

    OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

    +

    This module is part of the OCA/queue project on GitHub.

    +

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    +
    +
    +
    + + diff --git a/queue_job_batch/static/src/js/systray.js b/queue_job_batch/static/src/js/systray.js new file mode 100644 index 0000000000..5833a8fa7d --- /dev/null +++ b/queue_job_batch/static/src/js/systray.js @@ -0,0 +1,139 @@ +odoo.define('queue_job_batch.systray', function (require) { + "use strict"; + + var core = require('web.core'); + var session = require('web.session'); + var SystrayMenu = require('web.SystrayMenu'); + var Widget = require('web.Widget'); + var bus = require('bus.bus').bus; + + var QWeb = core.qweb; + + var QueueJobBatchMenu = Widget.extend({ + template:'queue_job_batch.view.Menu', + events: { + "click": "_onMenuClick", + "click .o_mail_channel_preview": "_onQueueJobBatchClick", + "click .o_view_all_batch_jobs": "_viewAllQueueJobBatches", + "click .o_queue_job_batch_hide": "_hideJobBatchClick", + }, + renderElement: function () { + this._super(); + var self = this; + session.user_has_group( + 'queue_job_batch.group_queue_job_batch_user' + ).then(function (data) { + self.manager = data; + if (data) { + self.do_show(); + } + }); + }, + start: function () { + var self = this; + session.user_has_group( + 'queue_job_batch.group_queue_job_batch_user' + ).then(function (data) { + self.manager = data; + if (data) { + self.$queue_job_batch_preview = self.$( + '.o_mail_navbar_dropdown_channels' + ); + self._updateQueueJobBatchesPreview(); + var channel = 'queue.job.batch'; + bus.add_channel(channel); + bus.on( + 'notification', + self, self._updateQueueJobBatchesPreview + ); + } + }); + return this._super(); + }, + + _getQueueJobBatchesData: function () { + var self = this; + + return self._rpc({ + model: 'queue.job.batch', + method: 'search_read', + args: [[ + ['user_id', '=', session.uid], + '|', ['state', 'in', ['draft', 'progress']], + ['is_read', '=', false], + ], [ + 'name', 'job_count', 'completeness', 'failed_percentage', + 'finished_job_count', 'failed_job_count', 'state', + ]], + kwargs: { + context: session.user_context, + }, + }).then(function (data) { + self.job_batches = data; + self.jobBatchesCounter = data.length; + self.$('.o_notification_counter').text(self.jobBatchesCounter); + self.$el.toggleClass( + 'o_no_notification', !self.jobBatchesCounter + ); + }); + }, + + _isOpen: function () { + return this.$el.hasClass('open'); + }, + + _updateQueueJobBatchesPreview: function () { + var self = this; + self._getQueueJobBatchesData().then(function () { + self.$queue_job_batch_preview.html(QWeb.render( + 'queue_job_batch.view.Data', { + job_batches : self.job_batches, + } + )); + }); + }, + _hideJobBatchClick: function (event) { + var queue_job_batch_id = parseInt( + $(event.currentTarget, 10).data('job-batch-id'), 10); + this._hideJobBatch(event, queue_job_batch_id); + }, + _hideJobBatch: function (event, queue_job_batch_id) { + this._rpc({ + model: 'queue.job.batch', + method: 'set_read', + args: [[queue_job_batch_id]], + kwargs: { + context: session.user_context, + }, + }); + }, + _onQueueJobBatchClick: function (event) { + var queue_job_batch_id = parseInt( + $(event.currentTarget, 10).data('job-batch-id'), 10); + this._hideJobBatch(event, queue_job_batch_id); + this.do_action({ + type: 'ir.actions.act_window', + name: 'Job batches', + res_model: 'queue.job.batch', + views: [[false, 'form']], + res_id: queue_job_batch_id, + }); + }, + _viewAllQueueJobBatches: function () { + this.do_action( + 'queue_job_batch.action_view_your_queue_job_batch'); + }, + _onMenuClick: function () { + if (!this._isOpen()) { + this._updateQueueJobBatchesPreview(); + } + }, + + }); + + SystrayMenu.Items.push(QueueJobBatchMenu); + + return { + QueueJobBatchMenu: QueueJobBatchMenu, + }; +}); diff --git a/queue_job_batch/static/src/less/systray.less b/queue_job_batch/static/src/less/systray.less new file mode 100644 index 0000000000..a4958d5c6c --- /dev/null +++ b/queue_job_batch/static/src/less/systray.less @@ -0,0 +1,44 @@ +.o_job_batch_navbar_item { + + &.open .o_job_batch_navbar_dropdown { + .o-flex-display(); + .o-flex-flow(column, nowrap); + } + .o_notification_counter { + .o-position-absolute(@top: 20%, @right: 1px); + background: @odoo-brand-optional; + color: white; + padding: 0em 0.3em; + font-size: 0.7em; + } + .o_job_batch_navbar_dropdown { + width: 350px; + padding: 0; + } + + .o_job_queue_failed { + color: red; + } + .o_job_queue_finished { + color: green; + } + .o_job_queue_progress { + color: gray; + } + .o_progressbar_complete { + &.o_queue_job_finished_progressbar { + background-color:green; + float:left; + } + + &.o_queue_job_failed_progressbar { + background-color:red; + float:right; + } + } +} + +.o_view_all_job_batches { + .btn-link; + padding: 5px; +} \ No newline at end of file diff --git a/queue_job_batch/static/src/xml/systray.xml b/queue_job_batch/static/src/xml/systray.xml new file mode 100644 index 0000000000..9fb2441afc --- /dev/null +++ b/queue_job_batch/static/src/xml/systray.xml @@ -0,0 +1,62 @@ + + + + +
  • + + +
  • +
    + + + +
  • + No jobs to view. +
  • +
    + +
    +
    + + + +
    +
    +
    + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + + + + diff --git a/queue_job_batch/views/assets_backend.xml b/queue_job_batch/views/assets_backend.xml new file mode 100644 index 0000000000..1c6799f6ab --- /dev/null +++ b/queue_job_batch/views/assets_backend.xml @@ -0,0 +1,10 @@ + + +