mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-21 04:42:18 -06:00
[MIG] document_page_approval: Migration to 15.0
TT36950 [UPD] Update document_page_approval.pot [UPD] README.rst
This commit is contained in:
committed by
Bhavesh Heliconia
parent
705bf60493
commit
a045036e67
@@ -12,9 +12,7 @@ class DocumentPage(models.Model):
|
||||
|
||||
_inherit = "document.page"
|
||||
|
||||
history_ids = fields.One2many(
|
||||
order="approved_date DESC", domain=[("state", "=", "approved")]
|
||||
)
|
||||
history_ids = fields.One2many(domain=[("state", "=", "approved")])
|
||||
|
||||
approved_date = fields.Datetime(
|
||||
"Approved Date",
|
||||
@@ -48,6 +46,7 @@ class DocumentPage(models.Model):
|
||||
"Approval required",
|
||||
help="If true, changes of this page require approval",
|
||||
compute="_compute_is_approval_required",
|
||||
recursive=True,
|
||||
)
|
||||
|
||||
am_i_approver = fields.Boolean(compute="_compute_am_i_approver")
|
||||
@@ -57,8 +56,10 @@ class DocumentPage(models.Model):
|
||||
string="Approver groups",
|
||||
help="Groups that can approve changes to this document",
|
||||
compute="_compute_approver_group_ids",
|
||||
recursive=True,
|
||||
)
|
||||
|
||||
# pylint: disable=W8113
|
||||
has_changes_pending_approval = fields.Boolean(
|
||||
compute="_compute_has_changes_pending_approval",
|
||||
string="Has changes pending approval",
|
||||
@@ -68,6 +69,9 @@ class DocumentPage(models.Model):
|
||||
compute="_compute_user_has_drafts", string="User has drafts?"
|
||||
)
|
||||
|
||||
def _valid_field_parameter(self, field, name):
|
||||
return name == "order" or super()._valid_field_parameter(field, name)
|
||||
|
||||
@api.depends("approval_required", "parent_id.is_approval_required")
|
||||
def _compute_is_approval_required(self):
|
||||
"""Check if the document required approval based on his parents."""
|
||||
@@ -127,13 +131,14 @@ class DocumentPage(models.Model):
|
||||
rec.user_has_drafts = changes > 0
|
||||
|
||||
def _create_history(self, vals):
|
||||
res = super(DocumentPage, self)._create_history(vals)
|
||||
res = super()._create_history(vals)
|
||||
res.action_to_approve()
|
||||
return res
|
||||
|
||||
def action_changes_pending_approval(self):
|
||||
self.ensure_one()
|
||||
action = self.env.ref("document_page_approval.action_change_requests")
|
||||
action = action.read()[0]
|
||||
action = action.sudo().read()[0]
|
||||
context = literal_eval(action["context"])
|
||||
context["search_default_page_id"] = self.id
|
||||
context["default_page_id"] = self.id
|
||||
|
||||
@@ -11,6 +11,7 @@ class DocumentPageHistory(models.Model):
|
||||
|
||||
_name = "document.page.history"
|
||||
_inherit = ["document.page.history", "mail.thread"]
|
||||
_order = "approved_date DESC, id DESC"
|
||||
|
||||
state = fields.Selection(
|
||||
[
|
||||
@@ -24,7 +25,7 @@ class DocumentPageHistory(models.Model):
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
approved_date = fields.Datetime("Approved Date")
|
||||
approved_date = fields.Datetime()
|
||||
|
||||
approved_uid = fields.Many2one("res.users", "Approved by")
|
||||
|
||||
@@ -126,8 +127,8 @@ class DocumentPageHistory(models.Model):
|
||||
for rec in self:
|
||||
rec.message_post(
|
||||
subtype_xmlid="mail.mt_comment",
|
||||
body=_("Change request <b>%s</b> has been cancelled by %s.")
|
||||
% (rec.display_name, self.env.user.name),
|
||||
body=_("Change request <b>%(name)s</b> has been cancelled by %(user)s.")
|
||||
% ({"name": rec.display_name, "user": self.env.user.name}),
|
||||
)
|
||||
|
||||
def action_cancel_and_draft(self):
|
||||
|
||||
Reference in New Issue
Block a user