Skip to content

Commit 9a5edd8

Browse files
ivantodorovichMiquelRForgeFlow
authored andcommitted
[MIG] document_page_multi_company (OCA#188)
* [MIG] document_page_multi_company Added this feature from the old module directly in document_page
1 parent 1df31ca commit 9a5edd8

5 files changed

Lines changed: 35 additions & 1 deletion

File tree

document_page/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{
66
'name': 'Document Page',
7-
'version': '11.0.2.0.0',
7+
'version': '11.0.2.1.0',
88
'category': 'Knowledge Management',
99
'author': 'OpenERP SA, Odoo Community Association (OCA)',
1010
'images': [

document_page/models/document_page.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ class DocumentPage(models.Model):
104104
readonly=True,
105105
)
106106

107+
company_id = fields.Many2one(
108+
'res.company',
109+
'Company',
110+
help='If set, page is accessible only from this company',
111+
index=True,
112+
ondelete='cascade',
113+
)
114+
107115
@api.multi
108116
def _get_page_index(self, link=True):
109117
"""Return the index of a document."""

document_page/models/document_page_history.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ class DocumentPageHistory(models.Model):
1919
content = fields.Text()
2020
diff = fields.Text(compute='_compute_diff')
2121

22+
company_id = fields.Many2one(
23+
'res.company',
24+
'Company',
25+
help='If set, page is accessible only from this company',
26+
related='page_id.company_id',
27+
store=True,
28+
index=True,
29+
readonly=True,
30+
)
31+
2232
@api.multi
2333
def _compute_diff(self):
2434
"""Shows a diff between this version and the previous version"""

document_page/security/document_page_security.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,18 @@
1414
<field name="users" eval="[(4, ref('base.user_root'))]"/>
1515
</record>
1616

17+
<record model="ir.rule" id="document_page_rule">
18+
<field name="name">document_page multi-company</field>
19+
<field name="model_id" ref="model_document_page"/>
20+
<field name="global" eval="True"/>
21+
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
22+
</record>
23+
24+
<record model="ir.rule" id="document_page_history_rule">
25+
<field name="name">document_page_history multi-company</field>
26+
<field name="model_id" ref="model_document_page_history"/>
27+
<field name="global" eval="True"/>
28+
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
29+
</record>
30+
1731
</odoo>

document_page/views/document_page.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<tree string="Document Page">
2525
<field name="name"/>
2626
<field name="parent_id"/>
27+
<field name="company_id" groups="base.group_multi_company"/>
2728
<field name="create_uid" invisible="1"/>
2829
<field name="content_uid"/>
2930
<field name="content_date"/>
@@ -50,6 +51,7 @@
5051
<group>
5152
<group>
5253
<field name="parent_id" string="Category" context="{'default_type':'category'}"/>
54+
<field name="company_id" groups="base.group_multi_company"/>
5355
</group>
5456
<group>
5557
<field name="content_uid"/>

0 commit comments

Comments
 (0)