<a class="reference external image-reference" href="http://www.gnu.org/licenses/LGPL-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-lgpl--3-blue.svg">
</a>
<a name="cms-mixin"></a>
<h2>CMS mixin</h2>
<ul class="simple">
<li><code>cms.security.mixin</code></li>
<li><code>cms.orderable.mixin</code></li>
<li><code>cms.coremetadata.mixin</code></li>
<li><code>cms.content.mixin</code></li>
<li><code>cms.parent.mixin</code></li>
</ul>
<a name="security-mixin"></a>
<h3>Security mixin</h3>
<p>Implements basic security features on your model. Provides:</p>
<ul class="simple">
<li>only owner can edit or delete</li>
<li>only owner can view if not published</li>
<li>only published items are visible by other users or anonymous users</li>
<li>you can grant view/edit permissions by using <cite>read_group_ids</cite> and <cite>write_group_ids</cite></li>
<li>the model controller will raise <cite>NotFound</cite> if current user cannot see the item
<strong>before</strong> template rendering (right now you get an access error
only if you access a field of the object)</li>
</ul>
<p>All of this is automatically activated by setting the flag <cite>_auto_security_policy = True</cite>.
By default is <cite>False</cite> as you might want to implement your own security policy.</p>
<p>Usage:</p>
<pre>
<code lang="python">class SecuredModel(models.Model):
_name = 'testmodel.secured'
_inherit = [
'website.published.mixin',
'cms.security.mixin',
]
# generate security automatically
_auto_security_policy = True</code>
</pre>
<a name="orderable-mixin"></a>
<h3>Orderable mixin</h3>
<p>Implements basic ordering features:</p>
<ul class="simple">
<li>order model by <cite>sequence desc</cite> by default</li>
<li>last created item has always higher sequence</li>
</ul>
<p>Usage:</p>
<pre>
<code lang="python">class OrderableModel(models.Model):
_name = 'testmodel.orderable'
_inherit = [
'cms.orderable.mixin',
]</code>
</pre>
<a name="coremetadata-mixin"></a>
<h3>Coremetadata mixin</h3>
<p>Implements basic core metadata features:</p>
<ul>
<li><p class="first">exposes create/write fields:</p>
<blockquote>
<p><cite>create_uid</cite>, <cite>write_uid</cite>, <cite>create_date</cite>, <cite>write_date</cite></p>
</blockquote>
<p>so that you can use them in backend forms to show important info</p>
</li>
<li><p class="first">adds new fields:</p>
<blockquote>
<ul class="simple">
<li><cite>published_uid</cite> to track who published an item</li>
<li><cite>published_date</cite> to track when an item has been published</li>
</ul>
</blockquote>
</li>
</ul>
<p>Usage:</p>
<pre>
<code lang="python">class CoremetadataModel(models.Model):
_name = 'testmodel.coremetadata'
_inherit = [
'website.published.mixin',
'cms.orderable.mixin',
]</code>
</pre>
<a name="content-mixin"></a>
<h3>Content mixin</h3>
<p>Implements basic website content features:</p>
<ul>
<li><p class="first">the following mixin are already implemented:</p>
<blockquote>
<ul class="simple">
<li><code>website.published.mixin</code></li>
<li><code>cms.coremetadata.mixin</code></li>
<li><code>cms.orderable.mixin</code></li>
</ul>
</blockquote>
</li>
<li><p class="first">adds basic fields:</p>
<blockquote>
<ul class="simple">
<li><cite>name</cite> defines content's name and "sluggified" in URL</li>
<li><cite>description</cite> brief description of the content</li>
<li><cite>body</cite> to contain HTML content</li>
</ul>
</blockquote>
</li>
<li><p class="first">generate basic URL: just provide a <cite>cms_url_prefix</cite> attribute
to have an URL like <cite>myodoo.com/contents/bla-1</cite>.</p>
</li>
</ul>
<p>Usage:</p>
<pre>
<code lang="python">class ContentModel(models.Model):
_name = 'testmodel.content'
_inherit = [
'cms.content.mixin',
]
cms_url_prefix = '/contents/'</code>
</pre>
<a name="parent-mixin"></a>
<h3>Parent mixin</h3>
<p>Implements basic website hierarchy features:</p>
<ul class="simple">
<li>parent / children relations without need to re-define relation per each model</li>
<li>constrain to avoid recursive parent of parent relation</li>
<li>helper method for action to open children list in backend</li>
<li><cite>hierarchy</cite> method to list the full hierarchy of an item</li>
<li><cite>name_get</cite> overide to include - on demand - the full hierarchy path on an item</li>
<li><cite>get_listing</cite> method to list all descendant items</li>
</ul>
<p>Usage:</p>
<pre>
<code lang="python">class ParentModel(models.Model):
"""A test model that implements `cms.parent.mixin`."""
_name = 'testmodel.parent'
_description = 'cms_mixin: parent test model'
_inherit = [
'cms.parent.mixin',
]
name = fields.Char()</code>
</pre>
<a name="bug-tracker"></a>
<h2>Bug Tracker</h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/website-cms/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.</p>
<a name="credits"></a>
<h2>Credits</h2>
<a name="contributors"></a>
<h3>Contributors</h3>
<ul class="simple">
<li>Simone Orsi at Camptocamp</li>
</ul>
<a name="maintainer"></a>
<h3>Maintainer</h3>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>This module is maintained by the OCA.</p>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.</p>
<p>To contribute to this module, please visit <a class="reference external" href="https://odoo-community.org">https://odoo-community.org</a>.</p>