Hello,
\n" -#~ "\n" -#~ "${object.create_uid.name} submited a new Change Request for " -#~ "${object.page_id.name} and it needs your approval.
\n" -#~ "\n" -#~ "\n"
-#~ "Modified by: ${object.create_uid.name}
\n"
-#~ "Date: ${object.create_date}
\n"
-#~ "
${object.summary}
\n" -#~ "% endif\n" -#~ "\n" -#~ "Have a great day.
\n" -#~ "\n" -#~ "--Odoo
\n" -#~ " \n" -#~ " " -#~ msgstr "" -#~ "\n" -#~ " \n" -#~ "Pozdrav,
\n" -#~ "\n" -#~ "${object.create_uid.name} je podnio novi zahtjev za izmjenom " -#~ "${object.page_id.name} i potrebno je vaše odobrenje.
\n" -#~ "\n" -#~ "\n"
-#~ "Uredio: ${object.create_uid.name}
\n"
-#~ "Datum: ${object.create_date}
\n"
-#~ "
${object.summary}
\n" -#~ "% endif\n" -#~ "\n" -#~ "Ugodan dan.
\n" -#~ "\n" -#~ "--Odoo
\n" -#~ " \n" -#~ " " - -#~ msgid "New version of ${object.display_name} needs your approval" -#~ msgstr "Nova verzija ${object.display_name} traži vaše odobrenje" diff --git a/document_page_approval/i18n/it.po b/document_page_approval/i18n/it.po index 5fc6879058c..a41f6bf5a24 100644 --- a/document_page_approval/i18n/it.po +++ b/document_page_approval/i18n/it.po @@ -437,80 +437,3 @@ msgstr "" #, python-format msgid "You need to cancel it before reopening." msgstr "Devi cancellarlo prima di riaprirlo." - -#~ msgid "SMS Delivery error" -#~ msgstr "Errore consegna SMS" - -#~ msgid "Number of messages which requires an action" -#~ msgstr "Numero di messaggi che richiedono un'azione" - -#~ msgid "" -#~ "\n" -#~ " \n" -#~ "Hello,
\n" -#~ "\n" -#~ "${object.create_uid.name} submited a new Change Request for " -#~ "${object.page_id.name} and it needs your approval.
\n" -#~ "\n" -#~ "\n"
-#~ "Modified by: ${object.create_uid.name}
\n"
-#~ "Date: ${object.create_date}
\n"
-#~ "
${object.summary}
\n" -#~ "% endif\n" -#~ "\n" -#~ "Have a great day.
\n" -#~ "\n" -#~ "--Odoo
\n" -#~ " \n" -#~ " " -#~ msgstr "" -#~ "\n" -#~ " \n" -#~ "Ciao,
\n" -#~ "\n" -#~ "${object.create_uid.name} ha aggiunto una Richiesta di Modifica per " -#~ "${object.page_id.name} e necessita la tua approvazione.
\n" -#~ "\n" -#~ "\n"
-#~ "Modicato da: ${object.create_uid.name}
\n"
-#~ "Data: ${object.create_date}
\n"
-#~ "
${object.summary}
\n" -#~ "% endif\n" -#~ "\n" -#~ "Buona giornata!
\n" -#~ "\n" -#~ "--Odoo
\n" -#~ " \n" -#~ " " - -#~ msgid "New version of ${object.display_name} needs your approval" -#~ msgstr "" -#~ "La nuova versione di ${object.display_name} richiede la tua approvazione" - -#, python-format -#~ msgid "Change request %s has been cancelled by %s." -#~ msgstr "La richiesta di modifica %s è stata annullata da %s." diff --git a/document_page_approval/i18n/sl.po b/document_page_approval/i18n/sl.po index 0aa832c67fd..14ede494341 100644 --- a/document_page_approval/i18n/sl.po +++ b/document_page_approval/i18n/sl.po @@ -409,73 +409,3 @@ msgstr "" #, python-format msgid "You need to cancel it before reopening." msgstr "Pred ponovnim odprtjem jo morate preklicati." - -#~ msgid "" -#~ "\n" -#~ " \n" -#~ "Hello,
\n" -#~ "\n" -#~ "${object.create_uid.name} submited a new Change Request for " -#~ "${object.page_id.name} and it needs your approval.
\n" -#~ "\n" -#~ "\n"
-#~ "Modified by: ${object.create_uid.name}
\n"
-#~ "Date: ${object.create_date}
\n"
-#~ "
${object.summary}
\n" -#~ "% endif\n" -#~ "\n" -#~ "Have a great day.
\n" -#~ "\n" -#~ "--Odoo
\n" -#~ " \n" -#~ " " -#~ msgstr "" -#~ "\n" -#~ " \n" -#~ "Pozdravljeni.
\n" -#~ "\n" -#~ "${object.create_uid.name} je vložil novo zahtevo po spremembi za " -#~ "${object.page_id.name} , ki jo morate odobriti.
\n" -#~ "\n" -#~ "\n"
-#~ "Spremenil: ${object.create_uid.name}
\n"
-#~ "Datum: ${object.create_date}
\n"
-#~ "
${object.summary}
\n" -#~ "% endif\n" -#~ "\n" -#~ "Lep pozdrav.
\n" -#~ "\n" -#~ "--Odoo
\n" -#~ " \n" -#~ " " - -#~ msgid "New version of ${object.display_name} needs your approval" -#~ msgstr "Nova verzija ${object.display_name} potrebuje vašo odobritev" - -#, python-format -#~ msgid "Change request %s has been cancelled by %s." -#~ msgstr "Zahtevo po spremembi %s je preklical %s." diff --git a/document_page_approval/models/document_page.py b/document_page_approval/models/document_page.py index ccfcaa8795a..1977a769999 100644 --- a/document_page_approval/models/document_page.py +++ b/document_page_approval/models/document_page.py @@ -2,9 +2,8 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from ast import literal_eval - from odoo import api, fields, models +from odoo.tools.safe_eval import safe_eval class DocumentPage(models.Model): @@ -138,7 +137,7 @@ def action_changes_pending_approval(self): action = self.env["ir.actions.act_window"]._for_xml_id( "document_page_approval.action_change_requests" ) - context = literal_eval(action["context"]) + context = safe_eval(action["context"]) context["search_default_page_id"] = self.id context["default_page_id"] = self.id action["context"] = context diff --git a/document_page_approval/models/document_page_history.py b/document_page_approval/models/document_page_history.py index 1c988b6c45c..c2c89af9db4 100644 --- a/document_page_approval/models/document_page_history.py +++ b/document_page_approval/models/document_page_history.py @@ -22,6 +22,7 @@ class DocumentPageHistory(models.Model): ], "Status", default="draft", + readonly=True, ) approved_date = fields.Datetime() diff --git a/document_page_approval/security/ir.model.access.csv b/document_page_approval/security/ir.model.access.csv deleted file mode 100644 index 97dd8b917b8..00000000000 --- a/document_page_approval/security/ir.model.access.csv +++ /dev/null @@ -1 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink diff --git a/document_page_approval/tests/test_document_page_approval.py b/document_page_approval/tests/test_document_page_approval.py index e9154ade084..9e250e2e6be 100644 --- a/document_page_approval/tests/test_document_page_approval.py +++ b/document_page_approval/tests/test_document_page_approval.py @@ -1,43 +1,38 @@ -from odoo.tests import common +from odoo.tests import new_test_user +from odoo.addons.base.tests.common import BaseCommon -class TestDocumentPageApproval(common.TransactionCase): - def setUp(self): - super().setUp() - self.page_obj = self.env["document.page"] - self.history_obj = self.env["document.page.history"] + +class TestDocumentPageApproval(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.page_obj = cls.env["document.page"] + cls.history_obj = cls.env["document.page.history"] # demo - self.category1 = self.env.ref("document_page.demo_category1") - self.page1 = self.env.ref("document_page.demo_page1") - self.approver_gid = self.env.ref( - "document_page_approval.group_document_approver_user" - ) - self.env.ref("base.user_root").write({"groups_id": [(4, self.approver_gid.id)]}) - self.env.ref("base.user_admin").write( - {"groups_id": [(4, self.approver_gid.id)]} + cls.category1 = cls.env.ref("document_page.demo_category1") + cls.page1 = cls.env.ref("document_page.demo_page1") + cls.user2 = new_test_user( + cls.env, + login="test-user2", + groups="base.group_user,document_page_approval.group_document_approver_user", ) - self.user2 = self.env["res.users"].create( - { - "name": "Test user 2", - "login": "Test user 2", - "groups_id": [ - (6, 0, [self.env.ref("base.group_user").id, self.approver_gid.id]) - ], - } + cls.approver_gid = cls.env.ref( + "document_page_approval.group_document_approver_user" ) # demo_approval - self.category2 = self.page_obj.create( + cls.category2 = cls.page_obj.create( { "name": "This category requires approval", "type": "category", "approval_required": True, - "approver_gid": self.approver_gid.id, + "approver_gid": cls.approver_gid.id, } ) - self.page2 = self.page_obj.create( + cls.page2 = cls.page_obj.create( { "name": "This page requires approval", - "parent_id": self.category2.id, + "parent_id": cls.category2.id, "content": "This content will require approval", } ) diff --git a/document_page_approval/views/document_page_approval.xml b/document_page_approval/views/document_page_approval.xml index 4451403e8d6..dce962ced56 100644 --- a/document_page_approval/views/document_page_approval.xml +++ b/document_page_approval/views/document_page_approval.xml @@ -44,21 +44,13 @@ name="action_draft" type="object" string="Back to draft" - invisible="(not am_i_owner or not am_i_approver) and (state != 'cancelled')" - /> - -