Attachment Size Limit
Set a max file size and the allowed file types per model and per user group, refuse anything else on the server with a message that names the file, and keep a log of every refused upload.
| Odoo | 17.0, 18.0, 19.0, 20.0 |
| Editions | Community, Enterprise |
| Works with | Discuss (mail) and General Settings (base_setup). The rules work on any model with attachments; the screenshots use Contacts. |
| Licence | OPL-1, 79 EUR |
| Tests | 10 automated, run on every version |
| Module | attachment_ |
The situation
Standard Odoo has one upload limit for the whole database (web.max_file_upload_size, 128 MB by default) and no file type check. A salesperson drops a 48 MB phone video on a contact, someone attaches setup_drivers.exe to a vendor, and the filestore and the backups grow every week. Nobody sees it happen, because nothing refuses the file and nothing records it.
With the module you write upload rules: Contacts take PDF and images up to 5 MB, administrators get 10 MB there, every employee gets 20 MB elsewhere. The server picks the most specific rule for the document and the user, refuses a file that breaks it with a message such as "signed_contract_scan.pdf is 7.4 MB, larger than the 5 MB allowed on Contact by the rule Contacts: PDF and images up to 5 MB", and writes a line in Rejected Uploads.
What it adds
Getting started
Open Apps, clear the Apps filter, search for Attachment Size Limit and click Activate. It needs Discuss (mail) and General Settings, which install with it if they are missing. No rule exists after install, so nothing changes until you create one.
Apps › attachment_upload_size_rule › Activate
Open Settings, find Attachment Uploads and click Upload Rules. Create a rule, pick the Model and User Groups it applies to (or leave them empty), and set Max Size (MB), Allowed Extensions such as pdf, docx, xlsx, and Allowed MIME Types such as image/*. Leave both type lists empty to accept any type. In the same block, choose whether administrators bypass the rules and how many days Rejected Uploads keeps its lines.
Settings › General Settings › Attachment Uploads
Users attach files as they always do. A file that fits the rule goes through. A file that is too large or of a type the rule doesn't list is refused with the reason, and the refusal shows up in Settings › Technical › Attachment Uploads › Rejected Uploads, where you can see who tried what and adjust a rule if it is too strict.
Fine print
Log
Can a rule also cover the files in a binary field?
Tell us the model and the field, and we will tell you whether the same rule check fits it.
Email odoo.expert.111@gmail.com
Also by Awins
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module