Author: |
Camptocamp, Odoo Community Association (OCA) |
License: |
LGPL-3 |
Branch: |
merge-branch-2118-11.0.0.7.0 |
Repository: |
camptocamp/server-tools |
Dependencies: |
base |
Languages: |
Python (156, 100.0%) |
Other branches: |
merge-branch-2118-11.0.0.10.0,
merge-branch-2118-11.0.0.11.0,
merge-branch-2118-11.0.0.2.0,
merge-branch-2118-11.0.0.3.0,
merge-branch-2118-11.0.0.4.0,
merge-branch-2118-11.0.0.5.0,
merge-branch-2118-11.0.0.6.0,
merge-branch-2118-11.0.0.6.1,
merge-branch-2118-11.0.0.8.0,
merge-branch-2118-11.0.0.9.0,
merge-branch-2118-11.0.1.0.0,
merge-branch-2118-11.0.1.0.1,
merge-branch-2118-11.0.1.0.10,
merge-branch-2118-11.0.1.0.11,
merge-branch-2118-11.0.1.0.12,
merge-branch-2118-11.0.1.0.13,
merge-branch-2118-11.0.1.0.14,
merge-branch-2118-11.0.1.0.15,
merge-branch-2118-11.0.1.0.2,
merge-branch-2118-11.0.1.0.3,
merge-branch-2118-11.0.1.0.4,
merge-branch-2118-11.0.1.0.5,
merge-branch-2118-11.0.1.0.6,
merge-branch-2118-11.0.1.0.7,
merge-branch-2118-11.0.1.0.8,
merge-branch-2118-11.0.1.0.9,
merge-branch-2118-11.0.1.1.0,
merge-branch-2118-11.0.1.1.1,
merge-branch-2118-11.0.1.1.2,
merge-branch-2118-11.0.1.1.3,
merge-branch-2118-11.0.1.1.4,
merge-branch-2118-11.0.1.1.5,
merge-branch-2118-11.0.1.1.6,
merge-branch-2118-11.0.1.1.7,
merge-branch-2118-11.0.1.1.8,
merge-branch-2118-11.0.1.1.9,
merge-branch-2118-11.0.10,
merge-branch-2118-11.0.11,
merge-branch-2118-11.0.12,
merge-branch-2118-11.0.8,
merge-branch-2118-11.0.9,
merge-branch-2118-11.1.0,
merge-branch-2118-11.2.0,
merge-branch-2118-11.3.0,
merge-branch-2118-11.4.0,
merge-branch-2118-master,
merge-branch-2118-master-15ac0ff2,
merge-branch-2118-master-37d93332,
and
merge-branch-2118-pin_external_branches-7cb8a9de |
Other repositories: |
simahawk/server-tools |
<a class="reference external image-reference" href="https://www.gnu.org/licenses/LGPL"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a>
<a name="base-binary-validation"></a>
<h2>Base binary validation</h2>
<p>Provide base validation for binary attachments.</p>
<p>You can:</p>
<ul class="simple">
<li>validate standard attachments on create/write</li>
<li>use <cite>BinaryValidated</cite> field to validate them automatically</li>
</ul>
<p>NOTE: to improve mimetype guessing you should install <cite>libmagic</cite> on you system
since Odoo standard leads to random results.</p>
<a name="batteries-not-included"></a>
<h3>Batteries not included</h3>
<p>This module is meant to be used by integrators and developers
to add validation to existing or custom models.
You won't see any change in Odoo after installing it.</p>
<a name="usage"></a>
<h4>Usage</h4>
<a name="validate-ir-attachment"></a>
<h3>Validate <cite>ir.attachment</cite></h3>
<p>You can validate standard attachments by providing <cite>allowed_mimetypes</cite> in context:</p>
<pre>
<code>self.env['ir.attachment'].with_context(allowed_mimetypes=('application/pdf')).create({...})</code>
</pre>
<a name="validate-fields-w-attachment-true"></a>
<h3>Validate fields w/ <cite>attachment=True</cite></h3>
<p>Define your field:</p>
<pre>
<code>from odoo.addons.base_binary_validation.fields import BinaryValidated
class Foo(models.Model):
[...]
terms_conditions = BinaryValidated(
string='Terms and Conditions',
attachment=True,
allowed_mimetypes=('application/pdf', ),
)</code>
</pre>
<p>In both cases, if <cite>allowed_mimetypes</cite> is not satisfied you'll get a validation error.</p>
<a name="known-issues-roadmap"></a>
<h4>Known issues / Roadmap</h4>
<ul class="simple">
<li>Validate non <cite>attachment</cite> binary fields</li>
</ul>
<a name="bug-tracker"></a>
<h4>Bug Tracker</h4>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.</p>
<a name="credits"></a>
<h4>Credits</h4>
<a name="images"></a>
<h3>Images</h3>
<ul class="simple">
<li>Odoo Community Association: <a class="reference external" href="https://odoo-community.org/logo.png">Icon</a>.</li>
</ul>
<a name="contributors"></a>
<h3>Contributors</h3>
<ul class="simple">
<li>Simone Orsi <<a class="reference external" href="mailto:simone.orsi@camptocamp.com">simone.orsi@camptocamp.com</a>></li>
</ul>
<p>Do not contact contributors directly about support or help with technical issues.</p>
<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>