Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Merge branch '15.0' into improve-test-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatnm0612 authored Jun 5, 2023
2 parents dad61f8 + 93421cf commit 2bc27fc
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 23 deletions.
5 changes: 4 additions & 1 deletion spp_change_request/models/change_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,10 @@ def open_request_detail(self):
self._check_phone_exist()
for rec in self:
# Open Request Form
return rec.open_change_request_form(target="current", mode="edit")
mode = "edit"
if self.env.user.id not in [self.assign_to_id.id, self.create_uid]:
mode = "readonly"
return rec.open_change_request_form(target="current", mode=mode)

def _check_phone_exist(self):
"""
Expand Down
39 changes: 20 additions & 19 deletions spp_change_request/static/src/js/hide_button.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,30 @@ odoo.define("spp_change_request.view_change_request_form", function (require) {
},
updateButtons: function () {
this._super.apply(this, arguments);
if (
this.$buttons &&
this.renderer.state.data.assign_to_id &&
this.renderer.state.data.assign_to_id.data &&
this.renderer.state.data.create_uid &&
this.renderer.state.data.create_uid.data
) {
if (this.getModelsToHide().includes(this.modelName)) {
if (
this.renderer.state.data.state === "draft" &&
this.renderer.state.data.assign_to_id.data.id !== user &&
this.renderer.state.data.create_uid.data.id !== user
var data = this.renderer.state.data;
if (this.getModelsToHide().includes(this.modelName)) {
// Only for models that needs to hide edit button
if (this.$buttons) {
// Check if button exists
this.$buttons.find(".o_form_button_edit").toggleClass("o_hidden", false);
if (data.state !== "draft") {
// Hide edit button if state is not draft
this.$buttons.find(".o_form_button_edit").toggleClass("o_hidden", true);
} else if (
!(
(data.assign_to_id &&
data.assign_to_id.data &&
data.assign_to_id.data.id === user) ||
(data.create_uid && data.create_uid.data && data.create_uid.data.id === user)
)
) {
// If current user is neither in assign_to_id or create_uid then the edit button will hide
this.$buttons.find(".o_form_button_edit").toggleClass("o_hidden", true);
} else {
this.$buttons.find(".o_form_button_edit").toggleClass("o_hidden", false);
}
} else {
this.$buttons.find(".o_form_button_edit").toggleClass("o_hidden", false);
var edit_mode = this.mode === "edit";
this.$buttons.find(".o_form_buttons_edit").toggleClass("o_hidden", !edit_mode);
this.$buttons.find(".o_form_buttons_view").toggleClass("o_hidden", edit_mode);
}
var edit_mode = this.mode === "edit";
this.$buttons.find(".o_form_buttons_edit").toggleClass("o_hidden", !edit_mode);
this.$buttons.find(".o_form_buttons_view").toggleClass("o_hidden", edit_mode);
}
},
});
Expand Down
9 changes: 8 additions & 1 deletion spp_idqueue/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@
"license": "LGPL-3",
"development_status": "Beta",
"maintainers": ["jeremi", "gonzalesedwin1123"],
"depends": ["base", "g2p_registry_base", "spp_idpass", "spp_area"],
"depends": [
"base",
"g2p_registry_base",
"spp_idpass",
"queue_job",
"spp_area",
],
"data": [
"data/id_pass.xml",
"data/queue_data.xml",
"security/g2p_security.xml",
"security/ir.model.access.csv",
"views/id_queue_view.xml",
Expand Down
10 changes: 10 additions & 0 deletions spp_idqueue/data/queue_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record model="queue.job.channel" id="channel_root_id_batch">
<field name="name">root_id_batch</field>
</record>
<record model="queue.job.channel" id="channel_id_batch">
<field name="name">id_batch</field>
<field name="parent_id" ref="channel_root_id_batch" />
</record>
</odoo>
12 changes: 12 additions & 0 deletions spp_idqueue/i18n/ar.po
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ msgid "Created on"
msgstr "انشأ على"

#. module: spp_idqueue
#: model:ir.model.fields,field_description:spp_idqueue.field_queue_job_channel__dms_directory_ids
#: model:ir.model.fields,field_description:spp_idqueue.field_res_config_settings__dms_directory_ids
#: model:ir.model.fields,field_description:spp_idqueue.field_res_partner__dms_directory_ids
#: model:ir.model.fields,field_description:spp_idqueue.field_spp_batch_create_wizard__dms_directory_ids
Expand Down Expand Up @@ -698,6 +699,11 @@ msgstr "متابع"
msgid "Is Idpass"
msgstr ""

#. module: spp_idqueue
#: model:ir.model,name:spp_idqueue.model_queue_job_channel
msgid "Job Channels"
msgstr ""

#. module: spp_idqueue
#: model:ir.model.fields,field_description:spp_idqueue.field_spp_batch_create_wizard____last_update
#: model:ir.model.fields,field_description:spp_idqueue.field_spp_multi_id_request_wizard____last_update
Expand Down Expand Up @@ -855,6 +861,12 @@ msgstr "عدد الرسائل غير المقروءة"
msgid "Other Info"
msgstr ""

#. module: spp_idqueue
#: code:addons/spp_idqueue/models/queue_job_channel.py:0
#, python-format
msgid "Parent channel required."
msgstr ""

#. module: spp_idqueue
#: code:addons/spp_idqueue/models/id_batch.py:0
#, python-format
Expand Down
12 changes: 12 additions & 0 deletions spp_idqueue/i18n/ckb.po
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ msgid "Created on"
msgstr ""

#. module: spp_idqueue
#: model:ir.model.fields,field_description:spp_idqueue.field_queue_job_channel__dms_directory_ids
#: model:ir.model.fields,field_description:spp_idqueue.field_res_config_settings__dms_directory_ids
#: model:ir.model.fields,field_description:spp_idqueue.field_res_partner__dms_directory_ids
#: model:ir.model.fields,field_description:spp_idqueue.field_spp_batch_create_wizard__dms_directory_ids
Expand Down Expand Up @@ -678,6 +679,11 @@ msgstr ""
msgid "Is Idpass"
msgstr ""

#. module: spp_idqueue
#: model:ir.model,name:spp_idqueue.model_queue_job_channel
msgid "Job Channels"
msgstr ""

#. module: spp_idqueue
#: model:ir.model.fields,field_description:spp_idqueue.field_spp_batch_create_wizard____last_update
#: model:ir.model.fields,field_description:spp_idqueue.field_spp_multi_id_request_wizard____last_update
Expand Down Expand Up @@ -835,6 +841,12 @@ msgstr ""
msgid "Other Info"
msgstr ""

#. module: spp_idqueue
#: code:addons/spp_idqueue/models/queue_job_channel.py:0
#, python-format
msgid "Parent channel required."
msgstr ""

#. module: spp_idqueue
#: code:addons/spp_idqueue/models/id_batch.py:0
#, python-format
Expand Down
12 changes: 12 additions & 0 deletions spp_idqueue/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ msgid "Created on"
msgstr "Créé sur"

#. module: spp_idqueue
#: model:ir.model.fields,field_description:spp_idqueue.field_queue_job_channel__dms_directory_ids
#: model:ir.model.fields,field_description:spp_idqueue.field_res_config_settings__dms_directory_ids
#: model:ir.model.fields,field_description:spp_idqueue.field_res_partner__dms_directory_ids
#: model:ir.model.fields,field_description:spp_idqueue.field_spp_batch_create_wizard__dms_directory_ids
Expand Down Expand Up @@ -710,6 +711,11 @@ msgstr ""
msgid "Is Idpass"
msgstr "est Idpass"

#. module: spp_idqueue
#: model:ir.model,name:spp_idqueue.model_queue_job_channel
msgid "Job Channels"
msgstr ""

#. module: spp_idqueue
#: model:ir.model.fields,field_description:spp_idqueue.field_spp_batch_create_wizard____last_update
#: model:ir.model.fields,field_description:spp_idqueue.field_spp_multi_id_request_wizard____last_update
Expand Down Expand Up @@ -869,6 +875,12 @@ msgstr ""
msgid "Other Info"
msgstr ""

#. module: spp_idqueue
#: code:addons/spp_idqueue/models/queue_job_channel.py:0
#, python-format
msgid "Parent channel required."
msgstr ""

#. module: spp_idqueue
#: code:addons/spp_idqueue/models/id_batch.py:0
#, python-format
Expand Down
12 changes: 12 additions & 0 deletions spp_idqueue/i18n/spp_idqueue.pot
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ msgid "Created on"
msgstr ""

#. module: spp_idqueue
#: model:ir.model.fields,field_description:spp_idqueue.field_queue_job_channel__dms_directory_ids
#: model:ir.model.fields,field_description:spp_idqueue.field_res_config_settings__dms_directory_ids
#: model:ir.model.fields,field_description:spp_idqueue.field_res_partner__dms_directory_ids
#: model:ir.model.fields,field_description:spp_idqueue.field_spp_batch_create_wizard__dms_directory_ids
Expand Down Expand Up @@ -683,6 +684,11 @@ msgstr ""
msgid "Is Idpass"
msgstr ""

#. module: spp_idqueue
#: model:ir.model,name:spp_idqueue.model_queue_job_channel
msgid "Job Channels"
msgstr ""

#. module: spp_idqueue
#: model:ir.model.fields,field_description:spp_idqueue.field_spp_batch_create_wizard____last_update
#: model:ir.model.fields,field_description:spp_idqueue.field_spp_multi_id_request_wizard____last_update
Expand Down Expand Up @@ -840,6 +846,12 @@ msgstr ""
msgid "Other Info"
msgstr ""

#. module: spp_idqueue
#: code:addons/spp_idqueue/models/queue_job_channel.py:0
#, python-format
msgid "Parent channel required."
msgstr ""

#. module: spp_idqueue
#: code:addons/spp_idqueue/models/id_batch.py:0
#, python-format
Expand Down
1 change: 1 addition & 0 deletions spp_idqueue/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
from . import id_queue
from . import id_batch
from . import registrant
from . import queue_job_channel
10 changes: 8 additions & 2 deletions spp_idqueue/models/id_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,17 @@ def _generate_batch(self, batch_ids):
ctr_ids += 1
queued_ids.append(queued_id.id)
if (ctr % self.JOBBATCH_SIZE == 0) or ctr == max_rec:
jobs.append(rec.delayable()._generate_cards(queued_ids))
jobs.append(
rec.delayable(channel="root_id_batch.id_batch")._generate_cards(
queued_ids
)
)
queued_ids = []

main_job = group(*jobs)
main_job.on_done(self.delayable().mark_as_done(rec))
main_job.on_done(
self.delayable(channel="root_id_batch.id_batch").mark_as_done(rec)
)
main_job.delay()

message_1 = _("{} started to generate this batch on {}.").format(
Expand Down
16 changes: 16 additions & 0 deletions spp_idqueue/models/queue_job_channel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from odoo import _, api, exceptions, models


class CustomQueueJobChannel(models.Model):
_inherit = "queue.job.channel"

@api.constrains("parent_id", "name")
def parent_required(self):
for record in self:
if (
record.name
and not record.name.startswith("root")
and not record.parent_id
):
raise exceptions.ValidationError(_("Parent channel required."))
return
1 change: 1 addition & 0 deletions spp_idqueue/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from . import test_registrant
from . import test_request_id_wizard
from . import test_res_config_settings
from . import test_queue_job_channel
11 changes: 11 additions & 0 deletions spp_idqueue/tests/test_queue_job_channel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from odoo.exceptions import ValidationError

from .common import Common


class TestCustomQueueJobChannel(Common):
def test_01_parent_required(self):
with self.assertRaisesRegex(ValidationError, "Parent channel required."):
self.env["queue.job.channel"].create({"name": "channel_program"})

self.env["queue.job.channel"].create({"name": "root_test"})

0 comments on commit 2bc27fc

Please sign in to comment.