mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-22 21:32:18 -06:00
[document_page_approval] Improve ux by adding user_has_drafts to document pages.
This commit is contained in:
@@ -66,6 +66,11 @@ class DocumentPage(models.Model):
|
||||
string='Has changes pending approval'
|
||||
)
|
||||
|
||||
user_has_drafts = fields.Boolean(
|
||||
compute='_compute_user_has_drafts',
|
||||
string='User has drafts?',
|
||||
)
|
||||
|
||||
@api.multi
|
||||
@api.depends('approval_required', 'parent_id.is_approval_required')
|
||||
def _compute_is_approval_required(self):
|
||||
@@ -119,6 +124,15 @@ class DocumentPage(models.Model):
|
||||
('state', '=', 'to approve')])
|
||||
rec.has_changes_pending_approval = (changes > 0)
|
||||
|
||||
@api.multi
|
||||
def _compute_user_has_drafts(self):
|
||||
history = self.env['document.page.history']
|
||||
for rec in self:
|
||||
changes = history.search_count([
|
||||
('page_id', '=', rec.id),
|
||||
('state', '=', 'draft')])
|
||||
rec.user_has_drafts = (changes > 0)
|
||||
|
||||
@api.multi
|
||||
def _create_history(self, vals):
|
||||
res = super(DocumentPage, self)._create_history(vals)
|
||||
|
||||
Reference in New Issue
Block a user