[MIG] document_page_approval: Finish migration

Changes done:
- Squash administrative commits
- Purge translations
- Remove ir.model.access.csv file
- Improve tests (change to setUpClass)
- Replace name_get() to _compute_display_name() (document_page)
- Remove readonly=1 (redudant, it already is) defined in approved_uid and approved_date fields in views
- Restore readonly=1 to the state field
- Remove duplicate Back to draft button

TT51529
This commit is contained in:
Víctor Martínez 2024-11-12 10:29:19 +01:00 committed by Bhavesh Heliconia
parent a4972a014d
commit f606356ca0
10 changed files with 35 additions and 275 deletions

View File

@ -13,7 +13,6 @@
"data/email_template.xml",
"views/document_page_approval.xml",
"security/document_page_security.xml",
"security/ir.model.access.csv",
],
"images": [
"images/category.png",

View File

@ -433,9 +433,3 @@ msgstr ""
#, python-format
msgid "You need to cancel it before reopening."
msgstr "Necesita cancelarlo antes de volver a abrirlo."
#~ msgid "SMS Delivery error"
#~ msgstr "Error de entrega de SMS"
#~ msgid "Number of messages which requires an action"
#~ msgstr "Número de mensajes que requieren una acción"

View File

@ -407,75 +407,3 @@ msgstr ""
#, python-format
msgid "You need to cancel it before reopening."
msgstr "Morate otkazati prije ponovnog otvaranja."
#~ msgid "SMS Delivery error"
#~ msgstr "Greška pri isporuci SMSa"
#~ msgid "Number of messages which requires an action"
#~ msgstr "Broj poruka koje trebaju neku radnju"
#~ msgid ""
#~ "\n"
#~ " \n"
#~ "<p>Hello,</p>\n"
#~ "\n"
#~ "<p>${object.create_uid.name} submited a new Change Request for <b>"
#~ "${object.page_id.name}</b> and it needs your approval.</p>\n"
#~ "\n"
#~ "<h1><a href=\"${object.page_url}\">${object.display_name}</a></h1>\n"
#~ "<p>\n"
#~ "<b>Modified by:</b> ${object.create_uid.name}<br/>\n"
#~ "<b>Date:</b> ${object.create_date}<br>\n"
#~ "</p>\n"
#~ "\n"
#~ "% if object.summary:\n"
#~ "<h3>Summary</h3>\n"
#~ "<p>${object.summary}</p>\n"
#~ "% endif\n"
#~ "\n"
#~ "<h3>Diff</h3>\n"
#~ "<div style=\"overflow-x:scroll; font-size:0.85em; margin-bottom:2em;\">\n"
#~ "${object.diff|safe}\n"
#~ "</div>\n"
#~ "\n"
#~ "<p>Have a great day.</p>\n"
#~ "\n"
#~ "--<br/>\n"
#~ "\n"
#~ "<p>Odoo</p>\n"
#~ " \n"
#~ " "
#~ msgstr ""
#~ "\n"
#~ " \n"
#~ "<p>Pozdrav,</p>\n"
#~ "\n"
#~ "<p>${object.create_uid.name} je podnio novi zahtjev za izmjenom <b>"
#~ "${object.page_id.name}</b> i potrebno je vaše odobrenje.</p>\n"
#~ "\n"
#~ "<h1><a href=\"${object.page_url}\">${object.display_name}</a></h1>\n"
#~ "<p>\n"
#~ "<b>Uredio:</b> ${object.create_uid.name}<br/>\n"
#~ "<b>Datum:</b> ${object.create_date}<br>\n"
#~ "</p>\n"
#~ "\n"
#~ "% if object.summary:\n"
#~ "<h3>Sažetak</h3>\n"
#~ "<p>${object.summary}</p>\n"
#~ "% endif\n"
#~ "\n"
#~ "<h3>Razlika</h3>\n"
#~ "<div style=\"overflow-x:scroll; font-size:0.85em; margin-bottom:2em;\">\n"
#~ "${object.diff|safe}\n"
#~ "</div>\n"
#~ "\n"
#~ "<p>Ugodan dan.</p>\n"
#~ "\n"
#~ "--<br/>\n"
#~ "\n"
#~ "<p>Odoo</p>\n"
#~ " \n"
#~ " "
#~ msgid "New version of ${object.display_name} needs your approval"
#~ msgstr "Nova verzija ${object.display_name} traži vaše odobrenje"

View File

@ -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"
#~ "<p>Hello,</p>\n"
#~ "\n"
#~ "<p>${object.create_uid.name} submited a new Change Request for <b>"
#~ "${object.page_id.name}</b> and it needs your approval.</p>\n"
#~ "\n"
#~ "<h1><a href=\"${object.page_url}\">${object.display_name}</a></h1>\n"
#~ "<p>\n"
#~ "<b>Modified by:</b> ${object.create_uid.name}<br/>\n"
#~ "<b>Date:</b> ${object.create_date}<br>\n"
#~ "</p>\n"
#~ "\n"
#~ "% if object.summary:\n"
#~ "<h3>Summary</h3>\n"
#~ "<p>${object.summary}</p>\n"
#~ "% endif\n"
#~ "\n"
#~ "<h3>Diff</h3>\n"
#~ "<div style=\"overflow-x:scroll; font-size:0.85em; margin-bottom:2em;\">\n"
#~ "${object.diff|safe}\n"
#~ "</div>\n"
#~ "\n"
#~ "<p>Have a great day.</p>\n"
#~ "\n"
#~ "--<br/>\n"
#~ "\n"
#~ "<p>Odoo</p>\n"
#~ " \n"
#~ " "
#~ msgstr ""
#~ "\n"
#~ " \n"
#~ "<p>Ciao,</p>\n"
#~ "\n"
#~ "<p>${object.create_uid.name} ha aggiunto una Richiesta di Modifica per <b>"
#~ "${object.page_id.name}</b> e necessita la tua approvazione.</p>\n"
#~ "\n"
#~ "<h1><a href=\"${object.page_url}\">${object.display_name}</a></h1>\n"
#~ "<p>\n"
#~ "<b>Modicato da:</b> ${object.create_uid.name}<br/>\n"
#~ "<b>Data:</b> ${object.create_date}<br>\n"
#~ "</p>\n"
#~ "\n"
#~ "% if object.summary:\n"
#~ "<h3>Riepilogo</h3>\n"
#~ "<p>${object.summary}</p>\n"
#~ "% endif\n"
#~ "\n"
#~ "<h3>Differenze</h3>\n"
#~ "<div style=\"overflow-x:scroll; font-size:0.85em; margin-bottom:2em;\">\n"
#~ "${object.diff|safe}\n"
#~ "</div>\n"
#~ "\n"
#~ "<p>Buona giornata!</p>\n"
#~ "\n"
#~ "--<br/>\n"
#~ "\n"
#~ "<p>Odoo</p>\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 <b>%s</b> has been cancelled by %s."
#~ msgstr "La richiesta di modifica <b>%s</b> è stata annullata da %s."

View File

@ -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"
#~ "<p>Hello,</p>\n"
#~ "\n"
#~ "<p>${object.create_uid.name} submited a new Change Request for <b>"
#~ "${object.page_id.name}</b> and it needs your approval.</p>\n"
#~ "\n"
#~ "<h1><a href=\"${object.page_url}\">${object.display_name}</a></h1>\n"
#~ "<p>\n"
#~ "<b>Modified by:</b> ${object.create_uid.name}<br/>\n"
#~ "<b>Date:</b> ${object.create_date}<br>\n"
#~ "</p>\n"
#~ "\n"
#~ "% if object.summary:\n"
#~ "<h3>Summary</h3>\n"
#~ "<p>${object.summary}</p>\n"
#~ "% endif\n"
#~ "\n"
#~ "<h3>Diff</h3>\n"
#~ "<div style=\"overflow-x:scroll; font-size:0.85em; margin-bottom:2em;\">\n"
#~ "${object.diff|safe}\n"
#~ "</div>\n"
#~ "\n"
#~ "<p>Have a great day.</p>\n"
#~ "\n"
#~ "--<br/>\n"
#~ "\n"
#~ "<p>Odoo</p>\n"
#~ " \n"
#~ " "
#~ msgstr ""
#~ "\n"
#~ " \n"
#~ "<p>Pozdravljeni.</p>\n"
#~ "\n"
#~ "<p>${object.create_uid.name} je vložil novo zahtevo po spremembi za <b>"
#~ "${object.page_id.name}</b> , ki jo morate odobriti.</p>\n"
#~ "\n"
#~ "<h1><a href=\"${object.page_url}\">${object.display_name}</a></h1>\n"
#~ "<p>\n"
#~ "<b>Spremenil:</b> ${object.create_uid.name}<br/>\n"
#~ "<b>Datum:</b> ${object.create_date}<br>\n"
#~ "</p>\n"
#~ "\n"
#~ "% if object.summary:\n"
#~ "<h3>Povzetek</h3>\n"
#~ "<p>${object.summary}</p>\n"
#~ "% endif\n"
#~ "\n"
#~ "<h3>Razlika</h3>\n"
#~ "<div style=\"overflow-x:scroll; font-size:0.85em; margin-bottom:2em;\">\n"
#~ "${object.diff|safe}\n"
#~ "</div>\n"
#~ "\n"
#~ "<p>Lep pozdrav.</p>\n"
#~ "\n"
#~ "--<br/>\n"
#~ "\n"
#~ "<p>Odoo</p>\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 <b>%s</b> has been cancelled by %s."
#~ msgstr "Zahtevo po spremembi <b>%s</b> je preklical %s."

View File

@ -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 @@ class DocumentPage(models.Model):
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

View File

@ -22,6 +22,7 @@ class DocumentPageHistory(models.Model):
],
"Status",
default="draft",
readonly=True,
)
approved_date = fields.Datetime()

View File

@ -1 +0,0 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink

View File

@ -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(
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",
)
cls.approver_gid = cls.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)]}
)
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])
],
}
)
# 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",
}
)

View File

@ -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')"
/>
<!-- cancel & reopen, if i am owner or approver -->
<button
name="action_draft"
type="object"
string="Back to draft"
invisible="(not am_i_owner or not am_i_approver) and (state != 'to approve')"
invisible="(not am_i_owner or not am_i_approver) and (state not in ('cancelled', 'to approve'))"
/>
<field name="am_i_owner" invisible="1" />
<field name="am_i_approver" invisible="1" />
<field name="is_approval_required" invisible="1" />
<field
name="state"
readonly="1"
widget="statusbar"
statusbar_visible="draft,approved"
/>
@ -176,21 +168,21 @@
/>
</xpath>
<field name="content_uid" position="after">
<field name="approved_uid" readonly="1" />
<field name="approved_uid" />
</field>
<field name="content_date" position="attributes">
<attribute name="invisible">1</attribute>
</field>
<field name="content_date" position="after">
<field name="approved_date" readonly="1" />
<field name="approved_date" />
</field>
<field name="history_ids" position="inside">
<tree>
<field name="id" />
<field name="approved_date" readonly="1" />
<field name="approved_date" />
<field name="summary" />
<field name="create_uid" />
<field name="approved_uid" readonly="1" />
<field name="approved_uid" />
</tree>
</field>
</field>
@ -203,8 +195,8 @@
<field name="arch" type="xml">
<field name="content" position="before">
<group class="oe_read_only" invisible="type != 'content'">
<field name="approved_date" readonly="1" />
<field name="approved_uid" readonly="1" />
<field name="approved_date" />
<field name="approved_uid" />
</group>
</field>
</field>
@ -237,9 +229,9 @@
<attribute name="decoration-muted">state=='cancelled'</attribute>
</tree>
<tree position="inside">
<field name="state" readonly="1" />
<field name="approved_uid" readonly="1" />
<field name="approved_date" readonly="1" />
<field name="state" />
<field name="approved_uid" />
<field name="approved_date" />
</tree>
</field>
</record>
@ -250,7 +242,7 @@
<field name="inherit_id" ref="document_page.view_wiki_history_filter" />
<field name="arch" type="xml">
<field name="page_id" position="before">
<field name="state" readonly="1" />
<field name="state" />
</field>
<field name="create_uid" position="after">
<filter name="draft" string="Draft" domain="[('state','=','draft')]" />