Skip to content

Commit

Permalink
[MIG] queue_job_batch, test_queue_job_batch: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminSForgeFlow committed Nov 9, 2023
1 parent 7fc0c3b commit d486958
Show file tree
Hide file tree
Showing 19 changed files with 434 additions and 275 deletions.
6 changes: 4 additions & 2 deletions queue_job_batch/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Job Queue Batch
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:46934d893ba24b20e4b25b6693bd5cc8944e7b10f8cf386c6f10368c65844e48
!! source digest: sha256:29600b710f0225edee91943dea2ea88211e9ce6e9db61ac8c66b1aa0672967b1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -102,9 +102,11 @@ Contributors
~~~~~~~~~~~~

* Enric Tobella <[email protected]>
* Lois Rilo <[email protected]>
* `Trobz <https://trobz.com>`_:
* Hoang Diep <[email protected]>
* `ForgeFlow <https://forgeflow.com>`_:
* Lois Rilo <[email protected]>
* Jasmin Solanki <[email protected]>

Other credits
~~~~~~~~~~~~~
Expand Down
11 changes: 4 additions & 7 deletions queue_job_batch/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Copyright 2019 Creu Blanca
# Copyright 2019 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# Copyright 2023 ForgeFlow S.L. (http://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

{
"name": "Job Queue Batch",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/queue",
"license": "AGPL-3",
Expand All @@ -25,12 +24,10 @@
"views/queue_job_batch_views.xml",
],
"assets": {
"web.assets_qweb": [
"queue_job_batch/static/src/xml/systray.xml",
],
"web.assets_backend": [
"queue_job_batch/static/src/js/systray.js",
"queue_job_batch/static/src/js/*.js",
"queue_job_batch/static/src/scss/systray.scss",
"queue_job_batch/static/src/xml/*.xml",
],
},
}
8 changes: 3 additions & 5 deletions queue_job_batch/models/queue_job_batch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2019 Creu Blanca
# Copyright 2019 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# Copyright 2023 ForgeFlow S.L. (http://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import api, fields, models
Expand Down Expand Up @@ -86,9 +85,8 @@ def check_state(self):
def set_read(self):
res = self.write({"is_read": True})
notifications = []
channel = "queue.job.batch"
notification_type = "is_read"
notifications.append([channel, notification_type, {}])
channel = "queue.job.batch/updated"
notifications.append([self.env.user.partner_id, channel, {}])
self.env["bus.bus"]._sendmany(notifications)
return res

Expand Down
4 changes: 3 additions & 1 deletion queue_job_batch/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
* Enric Tobella <[email protected]>
* Lois Rilo <[email protected]>
* `Trobz <https://trobz.com>`_:
* Hoang Diep <[email protected]>
* `ForgeFlow <https://forgeflow.com>`_:
* Lois Rilo <[email protected]>
* Jasmin Solanki <[email protected]>
12 changes: 10 additions & 2 deletions queue_job_batch/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Job Queue Batch</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:46934d893ba24b20e4b25b6693bd5cc8944e7b10f8cf386c6f10368c65844e48
!! source digest: sha256:29600b710f0225edee91943dea2ea88211e9ce6e9db61ac8c66b1aa0672967b1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/queue/tree/16.0/queue_job_batch"><img alt="OCA/queue" src="https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/queue-16-0/queue-16-0-queue_job_batch"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/queue&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This addon adds an a grouper for queue jobs.</p>
Expand Down Expand Up @@ -443,7 +443,6 @@ <h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Enric Tobella &lt;<a class="reference external" href="mailto:etobella&#64;creublanca.es">etobella&#64;creublanca.es</a>&gt;</li>
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#64;eficent.com</a>&gt;</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://trobz.com">Trobz</a>:</dt>
<dd><ul class="first last">
Expand All @@ -452,6 +451,15 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference external" href="https://forgeflow.com">ForgeFlow</a>:</dt>
<dd><ul class="first last">
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
<li>Jasmin Solanki &lt;<a class="reference external" href="mailto:jasmin.solanki&#64;forgeflow.com">jasmin.solanki&#64;forgeflow.com</a>&gt;</li>
</ul>
</dd>
</dl>
</li>
</ul>
</div>
<div class="section" id="other-credits">
Expand Down
62 changes: 62 additions & 0 deletions queue_job_batch/static/src/js/batch.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/** @odoo-module **/

import {one} from "@mail/model/model_field";
import {registerModel} from "@mail/model/model_core";
import session from "web.session";
const {Component} = owl;

registerModel({
name: "QueueJobBatch",
modelMethods: {
convertData(data) {
return {
irModel: {
id: data.id,
name: data.name,
job_count: data.job_count,
completeness: data.completeness,
failed_percentage: data.failed_percentage,
finished_job_count: data.finished_job_count,
failed_job_count: data.failed_job_count,
state: data.state,
},
};
},
},
recordMethods: {
_hideJobBatch: function () {
var res_id = this.irModel.id;
this.queueJobBatchMenuView.close();
this.delete();
Component.env.services.rpc({
model: "queue.job.batch",
method: "set_read",
args: [res_id],
kwargs: {
context: session.user_context,
},
});
},
_onQueueJobBatchClick: function () {
var res_id = this.irModel.id;
this._hideJobBatch();
this.env.services.action.doAction({
type: "ir.actions.act_window",
name: "Job batches",
res_model: "queue.job.batch",
views: [[false, "form"]],
res_id: res_id,
});
},
},
fields: {
queueJobBatchMenuView: one("QueueJobBatchMenuView", {
identifying: true,
inverse: "queueJobBatches",
}),
irModel: one("ir.model.queuejobbatch", {
identifying: true,
inverse: "queueJobBatch",
}),
},
});
26 changes: 26 additions & 0 deletions queue_job_batch/static/src/js/batch_menu_container_view.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** @odoo-module **/

// ensure components are registered beforehand.
import "./batch_menu_view.esm";
import {getMessagingComponent} from "@mail/utils/messaging_component";

const {Component} = owl;

export class QueueJobBatchMenuContainer extends Component {
/**
* @override
*/
setup() {
super.setup();
this.env.services.messaging.modelManager.messagingCreatedPromise.then(() => {
this.queueJobBatchMenuView =
this.env.services.messaging.modelManager.messaging.models.QueueJobBatchMenuView.insert();
this.render();
});
}
}

Object.assign(QueueJobBatchMenuContainer, {
components: {QueueJobBatchMenuView: getMessagingComponent("QueueJobBatchMenuView")},
template: "queue_job_batch.QueueJobBatchMenuContainer",
});
104 changes: 104 additions & 0 deletions queue_job_batch/static/src/js/batch_menu_model.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/** @odoo-module **/

import {attr, many} from "@mail/model/model_field";
import {registerModel} from "@mail/model/model_core";

import session from "web.session";

registerModel({
name: "QueueJobBatchMenuView",
lifecycleHooks: {
_created() {
this.fetchData();
document.addEventListener("click", this._onClickCaptureGlobal, true);
},
_willDelete() {
document.removeEventListener("click", this._onClickCaptureGlobal, true);
},
},
recordMethods: {
close() {
this.update({isOpen: false});
},
async fetchData() {
const data = await this.messaging.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},
});
this.update({
queueJobBatches: data.map((vals) =>
this.messaging.models.QueueJobBatch.convertData(vals)
),
});
},
/**
* @param {MouseEvent} ev
*/
onClickDropdownToggle(ev) {
ev.preventDefault();
if (this.isOpen) {
this.update({isOpen: false});
} else {
this.update({isOpen: true});
this.fetchData();
}
},
/**
* Closes the menu when clicking outside, if appropriate.
*
* @private
* @param {MouseEvent} ev
*/
_onClickCaptureGlobal(ev) {
if (!this.exists()) {
return;
}
if (!this.component || !this.component.root.el) {
return;
}
if (this.component.root.el.contains(ev.target)) {
return;
}
this.close();
},
_viewAllQueueJobBatches: function () {
this.close();
this.env.services.action.doAction(
"queue_job_batch.action_view_your_queue_job_batch"
);
},
},
fields: {
queueJobBatches: many("QueueJobBatch", {
sort: [["greater-first", "irModel.id"]],
inverse: "queueJobBatchMenuView",
}),
component: attr(),
counter: attr({
compute() {
return this.queueJobBatches.length;
},
}),
isOpen: attr({
default: false,
}),
},
});
29 changes: 29 additions & 0 deletions queue_job_batch/static/src/js/batch_menu_view.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/** @odoo-module **/

import {registerMessagingComponent} from "@mail/utils/messaging_component";
import {useComponentToModel} from "@mail/component_hooks/use_component_to_model";

const {Component} = owl;

export class QueueJobBatchMenuView extends Component {
/**
* @override
*/
setup() {
super.setup();
useComponentToModel({fieldName: "component"});
}
/**
* @returns {QueueJobBatchMenuView}
*/
get queueJobBatchMenuView() {
return this.props.record;
}
}

Object.assign(QueueJobBatchMenuView, {
props: {record: Object},
template: "queue_job_batch.QueueJobBatchMenuView",
});

registerMessagingComponent(QueueJobBatchMenuView);
31 changes: 31 additions & 0 deletions queue_job_batch/static/src/js/ir_model.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/** @odoo-module **/

import {attr, one} from "@mail/model/model_field";
import {registerModel} from "@mail/model/model_core";

registerModel({
name: "ir.model.queuejobbatch",
fields: {
/**
* Determines the name of the views that are available for this model.
*/
availableWebViews: attr({
compute() {
return ["kanban", "list", "form", "activity"];
},
}),
queueJobBatch: one("QueueJobBatch", {
inverse: "irModel",
}),
id: attr({
identifying: true,
}),
name: attr(),
job_count: attr(),
completeness: attr(),
failed_percentage: attr(),
finished_job_count: attr(),
failed_job_count: attr(),
state: attr(),
},
});
Loading

0 comments on commit d486958

Please sign in to comment.