Skip to content

Commit

Permalink
[MIG] document_page_approval: Finish migration
Browse files Browse the repository at this point in the history
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
  • Loading branch information
victoralmau committed Nov 12, 2024
1 parent 74660f1 commit f536e84
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 275 deletions.
6 changes: 4 additions & 2 deletions document_page/models/document_page_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,7 @@ def _get_diff(self, v1, v2):
context=True,
)

def name_get(self):
return [(rec.id, "%s #%i" % (rec.page_id.name, rec.id)) for rec in self]
@api.depends("page_id", "page_id.name")
def _compute_display_name(self):
for rec in self:
rec.display_name = f"{rec.page_id.name} #{rec.id}"
5 changes: 4 additions & 1 deletion document_page/security/document_page_security.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
<field name="name">Manager</field>
<field name="category_id" ref="document_knowledge.module_category_knowledge" />
<field name="implied_ids" eval="[(4, ref('group_document_editor'))]" />
<field name="users" eval="[(4, ref('base.user_admin'))]" />
<field
name="users"
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
/>
</record>
<record model="ir.rule" id="document_page_rule">
<field name="name">document_page multi-company</field>
Expand Down
1 change: 0 additions & 1 deletion document_page_approval/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 0 additions & 6 deletions document_page_approval/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
72 changes: 0 additions & 72 deletions document_page_approval/i18n/hr.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
77 changes: 0 additions & 77 deletions document_page_approval/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -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."
70 changes: 0 additions & 70 deletions document_page_approval/i18n/sl.po
Original file line number Diff line number Diff line change
Expand Up @@ -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."
1 change: 1 addition & 0 deletions document_page_approval/models/document_page_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DocumentPageHistory(models.Model):
],
"Status",
default="draft",
readonly=True,
)

approved_date = fields.Datetime()
Expand Down
1 change: 0 additions & 1 deletion document_page_approval/security/ir.model.access.csv

This file was deleted.

47 changes: 21 additions & 26 deletions document_page_approval/tests/test_document_page_approval.py
Original file line number Diff line number Diff line change
@@ -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",
}
)
Expand Down
Loading

0 comments on commit f536e84

Please sign in to comment.