diff --git a/document_page/models/document_page_history.py b/document_page/models/document_page_history.py index 35ddb3922ff..7b200e6abbb 100644 --- a/document_page/models/document_page_history.py +++ b/document_page/models/document_page_history.py @@ -66,11 +66,5 @@ def _get_diff(self, v1, v2): context=True, ) - # TODO: Replace for _compute_display_name def name_get(self): return [(rec.id, "%s #%i" % (rec.page_id.name, rec.id)) for rec in self] - - @api.depends("page_id") - def _compute_display_name(self): - for rec in self: - rec.display_name = rec.id, "%s #%i" % (rec.page_id.name, rec.id) diff --git a/document_page_approval/__manifest__.py b/document_page_approval/__manifest__.py index 648f4c64631..f2ca320ab33 100644 --- a/document_page_approval/__manifest__.py +++ b/document_page_approval/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Document Page Approval", - "version": "16.0.1.1.1", + "version": "17.0.1.0.0", "author": "Savoir-faire Linux, Odoo Community Association (OCA)", "website": "https://github.com/OCA/knowledge", "license": "AGPL-3", diff --git a/document_page_approval/hooks.py b/document_page_approval/hooks.py index d0b780a2627..5eb8761b298 100644 --- a/document_page_approval/hooks.py +++ b/document_page_approval/hooks.py @@ -5,10 +5,10 @@ _logger = logging.getLogger(__name__) -def post_init_hook(cr, registry): # pragma: no cover +def post_init_hook(env): # pragma: no cover # Set all pre-existing pages history to approved _logger.info("Setting history to approved.") - cr.execute( + env.cr.execute( """ UPDATE document_page_history SET state='approved', @@ -19,7 +19,7 @@ def post_init_hook(cr, registry): # pragma: no cover ) -def uninstall_hook(cr, registry): # pragma: no cover +def uninstall_hook(env): # pragma: no cover # Remove unapproved pages _logger.info("Deleting unapproved Change Requests.") - cr.execute("DELETE FROM document_page_history WHERE state != 'approved'") + env.cr.execute("DELETE FROM document_page_history WHERE state != 'approved'") diff --git a/document_page_approval/images/category.png b/document_page_approval/images/category.png index b88e2091ad8..410f661e981 100644 Binary files a/document_page_approval/images/category.png and b/document_page_approval/images/category.png differ diff --git a/document_page_approval/images/page_history.png b/document_page_approval/images/page_history.png index 80bee3c3977..7612df7f71f 100644 Binary files a/document_page_approval/images/page_history.png and b/document_page_approval/images/page_history.png differ diff --git a/document_page_approval/images/page_history_list.png b/document_page_approval/images/page_history_list.png index a2f52232a3e..2cefe8a158c 100644 Binary files a/document_page_approval/images/page_history_list.png and b/document_page_approval/images/page_history_list.png differ diff --git a/document_page_approval/models/document_page.py b/document_page_approval/models/document_page.py index d0b6ad2cbfc..ccfcaa8795a 100644 --- a/document_page_approval/models/document_page.py +++ b/document_page_approval/models/document_page.py @@ -19,7 +19,6 @@ class DocumentPage(models.Model): related="history_head.approved_date", store=True, index=True, - readonly=True, ) approved_uid = fields.Many2one( @@ -28,7 +27,6 @@ class DocumentPage(models.Model): related="history_head.approved_uid", store=True, index=True, - readonly=True, ) approval_required = fields.Boolean( @@ -137,8 +135,9 @@ def _create_history(self, vals): def action_changes_pending_approval(self): self.ensure_one() - action = self.env.ref("document_page_approval.action_change_requests") - action = action.sudo().read()[0] + action = self.env["ir.actions.act_window"]._for_xml_id( + "document_page_approval.action_change_requests" + ) context = literal_eval(action["context"]) context["search_default_page_id"] = self.id context["default_page_id"] = self.id diff --git a/document_page_approval/models/document_page_history.py b/document_page_approval/models/document_page_history.py index 905e6f0b3bb..1c988b6c45c 100644 --- a/document_page_approval/models/document_page_history.py +++ b/document_page_approval/models/document_page_history.py @@ -22,7 +22,6 @@ class DocumentPageHistory(models.Model): ], "Status", default="draft", - readonly=True, ) approved_date = fields.Datetime() @@ -79,7 +78,7 @@ def action_to_approve(self): [("groups_id", "in", guids), ("groups_id", "in", approver_gid.id)] ) rec.message_subscribe(partner_ids=users.mapped("partner_id").ids) - rec.message_post_with_template(template.id) + rec.message_post_with_source(template) else: # auto-approve if approval is not required rec.action_approve() diff --git a/document_page_approval/views/document_page_approval.xml b/document_page_approval/views/document_page_approval.xml index 5445e490c31..4451403e8d6 100644 --- a/document_page_approval/views/document_page_approval.xml +++ b/document_page_approval/views/document_page_approval.xml @@ -14,7 +14,7 @@ type="object" string="Send to Review" class="oe_highlight" - attrs="{'invisible':['|','|',('is_approval_required','=',False),('am_i_owner','=',False),('state', 'not in', ['draft'])]}" + invisible="not is_approval_required or not am_i_owner or state != 'draft'" />