[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:
Iván Todorovich 2018-09-17 11:37:57 -03:00 committed by mreficent
parent ae6338653d
commit 88c85037fb
5 changed files with 35 additions and 1 deletions

View File

@ -4,7 +4,7 @@
{
'name': 'Document Page',
'version': '11.0.2.0.0',
'version': '11.0.2.1.0',
'category': 'Knowledge Management',
'author': 'OpenERP SA, Odoo Community Association (OCA)',
'images': [

View File

@ -104,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."""

View File

@ -19,6 +19,16 @@ class DocumentPageHistory(models.Model):
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
def _compute_diff(self):
"""Shows a diff between this version and the previous version"""

View File

@ -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>

View File

@ -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"/>
@ -50,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"/>