Skip to content

Commit d5ad0c4

Browse files
committed
[18.0][FIX] document_page: Don't change last history name and summary when
creating new revision of page. Fixes an issue where editing a document.page and changing name and/or summary (to create a new revision) also changes name and summary of the history_head. draft_name and draft_summary are now computed fields (based on history_head) but have set the inverse without actually setting the value, to allow setting them when creating a new draft page. The issue is prominently evident when using document_page_approval where the name/summary for the new draft also change the last approved version (aka history_head) which should not happen.
1 parent 6a2eff3 commit d5ad0c4

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

document_page/models/document_page.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ class DocumentPage(models.Model):
3636
draft_name = fields.Char(
3737
string="Name",
3838
help="Name for the changes made",
39-
related="history_head.name",
40-
readonly=False,
39+
compute="_compute_content",
40+
inverse="_inverse_content",
4141
)
4242

4343
draft_summary = fields.Char(
4444
string="Summary",
4545
help="Describe the changes made",
46-
related="history_head.summary",
47-
readonly=False,
46+
compute="_compute_content",
47+
inverse="_inverse_content",
4848
)
4949

5050
template = fields.Html(
@@ -135,12 +135,18 @@ def _compute_content(self):
135135
for rec in self:
136136
if rec.type == "category":
137137
rec.content = rec._get_page_index(link=False)
138+
rec.draft_name = False
139+
rec.draft_summary = False
138140
else:
139141
if rec.history_head:
140142
rec.content = rec.history_head.content
143+
rec.draft_name = rec.history_head.name
144+
rec.draft_summary = rec.history_head.summary
141145
else:
142146
# html widget's default, so it doesn't trigger ghost save
143147
rec.content = self._HTML_WIDGET_DEFAULT_VALUE
148+
rec.draft_name = False
149+
rec.draft_summary = False
144150

145151
def _inverse_content(self):
146152
for rec in self:

0 commit comments

Comments
 (0)