-
-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] queue_job_batch, test_queue_job_batch: Migration to 16.0
- Loading branch information
1 parent
7fc0c3b
commit d486958
Showing
19 changed files
with
434 additions
and
275 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
~~~~~~~~~~~~~ | ||
|
This file contains 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 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 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,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]> |
This file contains 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 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,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
26
queue_job_batch/static/src/js/batch_menu_container_view.esm.js
This file contains 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,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", | ||
}); |
This file contains 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,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, | ||
}), | ||
}, | ||
}); |
This file contains 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,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); |
This file contains 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,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(), | ||
}, | ||
}); |
Oops, something went wrong.