mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-14 01:41:26 -06:00
Required impossible. Protected method needed
Content field can't be required for first document version _create_history is needed for dependencies
This commit is contained in:
parent
29c88d5bc7
commit
c20ada3946
@ -32,7 +32,6 @@ class DocumentPage(models.Model):
|
|||||||
compute="_compute_content",
|
compute="_compute_content",
|
||||||
inverse="_inverse_content",
|
inverse="_inverse_content",
|
||||||
search="_search_content",
|
search="_search_content",
|
||||||
required=True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
draft_name = fields.Char(
|
draft_name = fields.Char(
|
||||||
@ -90,6 +89,7 @@ class DocumentPage(models.Model):
|
|||||||
help="If set, page is accessible only from this company",
|
help="If set, page is accessible only from this company",
|
||||||
index=True,
|
index=True,
|
||||||
ondelete="cascade",
|
ondelete="cascade",
|
||||||
|
default=lambda self: self.env.company,
|
||||||
)
|
)
|
||||||
backend_url = fields.Char(
|
backend_url = fields.Char(
|
||||||
string="Backend URL",
|
string="Backend URL",
|
||||||
@ -143,10 +143,9 @@ class DocumentPage(models.Model):
|
|||||||
rec.content = self._HTML_WIDGET_DEFAULT_VALUE
|
rec.content = self._HTML_WIDGET_DEFAULT_VALUE
|
||||||
|
|
||||||
def _inverse_content(self):
|
def _inverse_content(self):
|
||||||
vals = []
|
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.type == "content" and rec.content != rec.history_head.content:
|
if rec.type == "content" and rec.content != rec.history_head.content:
|
||||||
vals.append(
|
rec._create_history(
|
||||||
{
|
{
|
||||||
"page_id": rec.id,
|
"page_id": rec.id,
|
||||||
"name": rec.draft_name,
|
"name": rec.draft_name,
|
||||||
@ -154,7 +153,10 @@ class DocumentPage(models.Model):
|
|||||||
"content": rec.content,
|
"content": rec.content,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.env["document.page.history"].create(vals)
|
|
||||||
|
def _create_history(self, vals):
|
||||||
|
self.ensure_one()
|
||||||
|
return self.env["document.page.history"].create(vals)
|
||||||
|
|
||||||
def _search_content(self, operator, value):
|
def _search_content(self, operator, value):
|
||||||
return [("history_head.content", operator, value)]
|
return [("history_head.content", operator, value)]
|
||||||
|
Loading…
Reference in New Issue
Block a user