mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-14 01:41:26 -06:00
[document_page] FIX creating history when there are no changes made. Add history name field, to name revisions. Modified views to allow setting this field.
[document_page] FIX BUG: UI hanging when editing content. This was due to the api.depends on _compute_diff. Removing it because it's not really necessary since the field is not stored. [document_page] page_id should be readonly. Improve active field [document_page] Update version number [UPD] Update document_page.pot [MIG] document_page_multi_company (#188) * [MIG] document_page_multi_company Added this feature from the old module directly in document_page
This commit is contained in:
parent
3241e9ae54
commit
f534207697
@ -4,7 +4,7 @@
|
||||
|
||||
{
|
||||
'name': 'Document Page',
|
||||
'version': '11.0.1.0.0',
|
||||
'version': '11.0.2.1.0',
|
||||
'category': 'Knowledge Management',
|
||||
'author': 'OpenERP SA, Odoo Community Association (OCA)',
|
||||
'images': [
|
||||
|
@ -13,6 +13,11 @@ msgstr ""
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: document_page
|
||||
#: model:ir.model.fields,field_description:document_page.field_document_page_active
|
||||
msgid "Active"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_page
|
||||
#: model:ir.ui.view,arch_db:document_page.view_wiki_filter
|
||||
#: model:ir.ui.view,arch_db:document_page.view_wiki_history_filter
|
||||
@ -94,7 +99,7 @@ msgid "Created on"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_page
|
||||
#: model:ir.model.fields,help:document_page.field_document_page_summary
|
||||
#: model:ir.model.fields,help:document_page.field_document_page_draft_summary
|
||||
msgid "Describe the changes made"
|
||||
msgstr ""
|
||||
|
||||
@ -233,12 +238,19 @@ msgid "Menu Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_page
|
||||
#: model:ir.model.fields,field_description:document_page.field_document_page_draft_name
|
||||
#: model:ir.model.fields,field_description:document_page.field_document_page_history_name
|
||||
#: model:ir.ui.view,arch_db:document_page.view_category_form
|
||||
#: model:ir.ui.view,arch_db:document_page.view_wiki_form
|
||||
#: model:ir.ui.view,arch_db:document_page.view_wiki_menu_form
|
||||
msgid "Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_page
|
||||
#: model:ir.model.fields,help:document_page.field_document_page_draft_name
|
||||
msgid "Name for the changes made"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_page
|
||||
#: model:ir.model.fields,field_description:document_page.field_document_page_history_page_id
|
||||
msgid "Page"
|
||||
@ -276,6 +288,17 @@ msgstr ""
|
||||
msgid "Parent Menu"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_page
|
||||
#: model:ir.ui.view,arch_db:document_page.view_wiki_form
|
||||
#: model:ir.ui.view,arch_db:document_page.wiki_history_form
|
||||
msgid "Rev 01"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_page
|
||||
#: model:ir.ui.view,arch_db:document_page.view_wiki_form
|
||||
msgid "Revision"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_page
|
||||
#: code:addons/document_page/wizard/document_page_show_diff.py:28
|
||||
#, python-format
|
||||
@ -283,8 +306,8 @@ msgid "Select one or maximum two history revisions!"
|
||||
msgstr ""
|
||||
|
||||
#. module: document_page
|
||||
#: model:ir.model.fields,field_description:document_page.field_document_page_draft_summary
|
||||
#: model:ir.model.fields,field_description:document_page.field_document_page_history_summary
|
||||
#: model:ir.model.fields,field_description:document_page.field_document_page_summary
|
||||
msgid "Summary"
|
||||
msgstr ""
|
||||
|
||||
|
@ -21,6 +21,8 @@ class DocumentPage(models.Model):
|
||||
default="content"
|
||||
)
|
||||
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
parent_id = fields.Many2one(
|
||||
'document.page',
|
||||
'Category',
|
||||
@ -42,7 +44,16 @@ class DocumentPage(models.Model):
|
||||
)
|
||||
|
||||
# no-op computed field
|
||||
summary = fields.Char(
|
||||
draft_name = fields.Char(
|
||||
string='Name',
|
||||
help='Name for the changes made',
|
||||
compute=lambda x: x,
|
||||
inverse=lambda x: x,
|
||||
)
|
||||
|
||||
# no-op computed field
|
||||
draft_summary = fields.Char(
|
||||
string='Summary',
|
||||
help='Describe the changes made',
|
||||
compute=lambda x: x,
|
||||
inverse=lambda x: x,
|
||||
@ -93,6 +104,14 @@ class DocumentPage(models.Model):
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
company_id = fields.Many2one(
|
||||
'res.company',
|
||||
'Company',
|
||||
help='If set, page is accessible only from this company',
|
||||
index=True,
|
||||
ondelete='cascade',
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _get_page_index(self, link=True):
|
||||
"""Return the index of a document."""
|
||||
@ -124,10 +143,12 @@ class DocumentPage(models.Model):
|
||||
@api.multi
|
||||
def _inverse_content(self):
|
||||
for rec in self:
|
||||
if rec.type == 'content':
|
||||
if rec.type == 'content' and \
|
||||
rec.content != rec.history_head.content:
|
||||
rec._create_history({
|
||||
'name': rec.draft_name,
|
||||
'summary': rec.draft_summary,
|
||||
'content': rec.content,
|
||||
'summary': rec.summary,
|
||||
})
|
||||
|
||||
@api.multi
|
||||
|
@ -14,12 +14,22 @@ class DocumentPageHistory(models.Model):
|
||||
_order = 'id DESC'
|
||||
|
||||
page_id = fields.Many2one('document.page', 'Page', ondelete='cascade')
|
||||
summary = fields.Char('Summary', index=True)
|
||||
content = fields.Text("Content")
|
||||
name = fields.Char(index=True)
|
||||
summary = fields.Char(index=True)
|
||||
content = fields.Text()
|
||||
diff = fields.Text(compute='_compute_diff')
|
||||
|
||||
company_id = fields.Many2one(
|
||||
'res.company',
|
||||
'Company',
|
||||
help='If set, page is accessible only from this company',
|
||||
related='page_id.company_id',
|
||||
store=True,
|
||||
index=True,
|
||||
readonly=True,
|
||||
)
|
||||
|
||||
@api.multi
|
||||
@api.depends('content', 'page_id.history_ids')
|
||||
def _compute_diff(self):
|
||||
"""Shows a diff between this version and the previous version"""
|
||||
history = self.env['document.page.history']
|
||||
|
@ -14,4 +14,18 @@
|
||||
<field name="users" eval="[(4, ref('base.user_root'))]"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule" id="document_page_rule">
|
||||
<field name="name">document_page multi-company</field>
|
||||
<field name="model_id" ref="model_document_page"/>
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule" id="document_page_history_rule">
|
||||
<field name="name">document_page_history multi-company</field>
|
||||
<field name="model_id" ref="model_document_page_history"/>
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<tree string="Document Page">
|
||||
<field name="name"/>
|
||||
<field name="parent_id"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="create_uid" invisible="1"/>
|
||||
<field name="content_uid"/>
|
||||
<field name="content_date"/>
|
||||
@ -38,6 +39,11 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Document Page">
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button name="toggle_active" type="object" groups="document_page.group_document_manager" class="oe_stat_button" icon="fa-archive">
|
||||
<field name="active" widget="boolean_button" options="{'terminology': 'archive'}"/>
|
||||
</button>
|
||||
</div>
|
||||
<field name="type" invisible="1"/>
|
||||
<h1>
|
||||
<field name="name" placeholder="Name"/>
|
||||
@ -45,6 +51,7 @@
|
||||
<group>
|
||||
<group>
|
||||
<field name="parent_id" string="Category" context="{'default_type':'category'}"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="content_uid"/>
|
||||
@ -54,17 +61,21 @@
|
||||
</group>
|
||||
<notebook>
|
||||
<page name="content" string="Content">
|
||||
<label for="summary" class="oe_edit_only"/>
|
||||
<field name="summary" placeholder="eg: Changed ... for ..." class="oe_edit_only"/>
|
||||
<group string="Revision" class="oe_edit_only">
|
||||
<field name="draft_name" placeholder="Rev 01" class="oe_edit_only" />
|
||||
<field name="draft_summary" placeholder="eg: Changed ... for ..." class="oe_edit_only" />
|
||||
</group>
|
||||
<div>
|
||||
<label for="content" class="oe_edit_only"/>
|
||||
<field name="content" widget="html" placeholder="e.g. Once upon a time..." required="1"
|
||||
options="{'safe': True}"/>
|
||||
<field name="content" widget="html" placeholder="e.g. Once upon a time..." required="1" options="{'safe': True}"/>
|
||||
</div>
|
||||
</page>
|
||||
<page name="history" string="History">
|
||||
<field name="history_ids">
|
||||
<tree>
|
||||
<field name="id"/>
|
||||
<field name="create_date"/>
|
||||
<field name="name"/>
|
||||
<field name="summary"/>
|
||||
<field name="create_uid"/>
|
||||
</tree>
|
||||
|
@ -9,6 +9,7 @@
|
||||
<tree string="Document History">
|
||||
<field name="id"/>
|
||||
<field name="page_id"/>
|
||||
<field name="name"/>
|
||||
<field name="summary"/>
|
||||
<field name="create_uid"/>
|
||||
<field name="create_date"/>
|
||||
@ -39,18 +40,19 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Document Page History">
|
||||
<sheet>
|
||||
<h1><field name="page_id"/></h1>
|
||||
<h1><field name="page_id" readonly="1"/></h1>
|
||||
<group>
|
||||
<group>
|
||||
<field name="create_uid" readonly="1"/>
|
||||
<field name="create_date" readonly="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<field name="name" placeholder="Rev 01"/>
|
||||
<field name="summary" placeholder="eg: Changed ... for ..."/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page name="content" string="Content">
|
||||
<label for="summary"/>
|
||||
<field name="summary" placeholder="eg: Changed ... for ..."/>
|
||||
<label for="content"/>
|
||||
<field name="content" widget="html" placeholder="e.g. Once upon a time..." options="{'safe': True}"/>
|
||||
</page>
|
||||
<page name="diff" string="Changes">
|
||||
|
Loading…
Reference in New Issue
Block a user