diff --git a/odex30_base/size_restriction_for_attachments/README.rst b/odex30_base/size_restriction_for_attachments/README.rst new file mode 100755 index 0000000..a6e9561 --- /dev/null +++ b/odex30_base/size_restriction_for_attachments/README.rst @@ -0,0 +1,40 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Size Restriction For Attachments +================================ +This module allow to restrict attachment uploading size for a particular user. +Configuration +============= +*No Additional configuration is needed. + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +Developer: Swetha Anand @cybrosys, Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/odex30_base/size_restriction_for_attachments/__init__.py b/odex30_base/size_restriction_for_attachments/__init__.py new file mode 100644 index 0000000..7cdad7f --- /dev/null +++ b/odex30_base/size_restriction_for_attachments/__init__.py @@ -0,0 +1,3 @@ + +from . import models +from . import controllers diff --git a/odex30_base/size_restriction_for_attachments/__manifest__.py b/odex30_base/size_restriction_for_attachments/__manifest__.py new file mode 100644 index 0000000..9494bd1 --- /dev/null +++ b/odex30_base/size_restriction_for_attachments/__manifest__.py @@ -0,0 +1,33 @@ +{ + 'name': 'Size Restriction for Attachments', + 'version': '18.0.1.0.0', + 'category': 'Document Management', + 'summary': 'Restricts attachment file size based on user settings.', + 'description': """ + If the size of an attachment is greater than the maximum size + assigned for that user, an error message will be shown and the file + will not be uploaded. + """, + 'author': 'Cybrosys Techno Solutions (Updated by AI)', + 'website': 'https://www.cybrosys.com', + 'license': 'AGPL-3', + 'depends': [ + 'base', + 'web', + 'mail', + ], + 'data': [ + 'views/res_users.xml', + ], + 'assets': { + 'web.assets_backend': [ + 'size_restriction_for_attachments/static/src/js/size.js', + ], + }, + + + + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/odex30_base/size_restriction_for_attachments/controllers/__init__.py b/odex30_base/size_restriction_for_attachments/controllers/__init__.py new file mode 100644 index 0000000..ae553bb --- /dev/null +++ b/odex30_base/size_restriction_for_attachments/controllers/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Swetha Anand (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import main diff --git a/odex30_base/size_restriction_for_attachments/controllers/main.py b/odex30_base/size_restriction_for_attachments/controllers/main.py new file mode 100644 index 0000000..afd1ab8 --- /dev/null +++ b/odex30_base/size_restriction_for_attachments/controllers/main.py @@ -0,0 +1,68 @@ +import base64 +import logging +import json +import unicodedata + +from odoo.exceptions import AccessError +from odoo.http import request +from odoo import _, http +from odoo.addons.web.controllers.binary import Binary + +_logger = logging.getLogger(__name__) + + +def clean(name): + return name.replace('\x3c', '') + + +class Binary(Binary): + @http.route('/web/binary/upload_attachment', type='http', auth="user") + def upload_attachment(self, model, id, ufile, callback=None): + out = """""" + + files = request.httprequest.files.getlist('ufile') + Model = request.env['ir.attachment'] + args = [] + + max_size = request.env.user.max_size * 1024 * 1024 + + for ufile in files: + filename = ufile.filename + if request.httprequest.user_agent.browser == 'safari': + filename = unicodedata.normalize('NFD', ufile.filename) + + file_content = ufile.read() + file_size = len(file_content) + + if max_size and file_size > max_size: + args.append({'error': _( + 'Attachment size (%(size)s MB) cannot exceed %(max_size)s MB.', + size=round(file_size / (1024 * 1024), 2), + max_size=request.env.user.max_size + )}) + continue + try: + attachment = Model.create({ + 'name': filename, + 'raw': file_content, + 'res_model': model, + 'res_id': int(id) + }) + attachment._post_add_create() + except AccessError: + args.append({'error': _("You are not allowed to upload an attachment here.")}) + except Exception as e: + args.append({'error': _("Something horrible happened")}) + _logger.exception("Failed to upload attachment %s", ufile.filename) + else: + args.append({ + 'filename': clean(filename), + 'mimetype': attachment.mimetype, + 'id': attachment.id, + 'size': attachment.file_size + }) + + return out % (json.dumps(clean(callback)), json.dumps(args)) if callback else json.dumps(args) diff --git a/odex30_base/size_restriction_for_attachments/doc/RELEASE_NOTES.md b/odex30_base/size_restriction_for_attachments/doc/RELEASE_NOTES.md new file mode 100644 index 0000000..00495f8 --- /dev/null +++ b/odex30_base/size_restriction_for_attachments/doc/RELEASE_NOTES.md @@ -0,0 +1,7 @@ +## Module + +#### 19.04.2023 +#### Version 14.0.1.0.0 +#### ADD + +- Initial commit for Size Restriction For Attachments diff --git a/odex30_base/size_restriction_for_attachments/models/__init__.py b/odex30_base/size_restriction_for_attachments/models/__init__.py new file mode 100644 index 0000000..8bd2979 --- /dev/null +++ b/odex30_base/size_restriction_for_attachments/models/__init__.py @@ -0,0 +1,2 @@ + +from .import res_users diff --git a/odex30_base/size_restriction_for_attachments/models/res_users.py b/odex30_base/size_restriction_for_attachments/models/res_users.py new file mode 100644 index 0000000..0dd8a20 --- /dev/null +++ b/odex30_base/size_restriction_for_attachments/models/res_users.py @@ -0,0 +1,26 @@ + +from odoo import fields, models, api + + +class ResUSer(models.Model): + """Inherits res.users. to add new fields to set restriction on size of the + attachment to be uploaded and to set maximum size of attachment.""" + _inherit = 'res.users' + + set_restriction = fields.Boolean(string="Set Restriction", + help="If true then that person " + "will have restriction on " + "size of the attachment to " + "be uploaded.") + max_size = fields.Float(string="Maximum size(MB)", default=0.0, + help="Maximum size of attachment in MB.") + + @api.model + def get_current_user_size_restriction(self): + + user = self.env.user + return { + 'set_restriction': user.set_restriction, + 'max_size': user.max_size, + 'name': user.name, + } diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/check.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/check.png new file mode 100644 index 0000000..c8e85f5 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/check.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/chevron.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/chevron.png new file mode 100644 index 0000000..2089293 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/chevron.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/cogs.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/cogs.png new file mode 100644 index 0000000..95d0bad Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/cogs.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/consultation.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/consultation.png new file mode 100644 index 0000000..8319d4b Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/consultation.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/ecom-black.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/ecom-black.png new file mode 100644 index 0000000..a9385ff Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/ecom-black.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/education-black.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/education-black.png new file mode 100644 index 0000000..3eb09b2 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/education-black.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/hotel-black.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/hotel-black.png new file mode 100644 index 0000000..130f613 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/hotel-black.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/license.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/license.png new file mode 100644 index 0000000..a586979 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/license.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/lifebuoy.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/lifebuoy.png new file mode 100644 index 0000000..658d56c Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/lifebuoy.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/manufacturing-black.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 0000000..697eb0e Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/manufacturing-black.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/pos-black.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/pos-black.png new file mode 100644 index 0000000..97c0f90 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/pos-black.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/puzzle.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/puzzle.png new file mode 100644 index 0000000..65cf854 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/puzzle.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/restaurant-black.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/restaurant-black.png new file mode 100644 index 0000000..4a35eb9 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/restaurant-black.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/service-black.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/service-black.png new file mode 100644 index 0000000..301ab51 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/service-black.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/trading-black.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/trading-black.png new file mode 100644 index 0000000..9398ba2 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/trading-black.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/training.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/training.png new file mode 100644 index 0000000..884ca02 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/training.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/update.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/update.png new file mode 100644 index 0000000..ecbc5a0 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/update.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/user.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/user.png new file mode 100644 index 0000000..6ffb23d Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/user.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/icons/wrench.png b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/wrench.png new file mode 100644 index 0000000..6c04dea Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/icons/wrench.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/categories.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/categories.png new file mode 100644 index 0000000..bedf1e0 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/categories.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/check-box.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/check-box.png new file mode 100644 index 0000000..42caf24 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/check-box.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/compass.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/compass.png new file mode 100644 index 0000000..d5fed8f Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/compass.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/corporate.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/corporate.png new file mode 100644 index 0000000..2eb13ed Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/corporate.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/customer-support.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/customer-support.png new file mode 100644 index 0000000..79efc72 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/customer-support.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/cybrosys-logo.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 0000000..cc3cc0c Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/cybrosys-logo.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/features.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/features.png new file mode 100644 index 0000000..b41769f Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/features.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/logo.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/logo.png new file mode 100644 index 0000000..478462d Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/logo.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/pictures.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/pictures.png new file mode 100644 index 0000000..56d255f Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/pictures.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/pie-chart.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/pie-chart.png new file mode 100644 index 0000000..426e052 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/pie-chart.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/right-arrow.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/right-arrow.png new file mode 100644 index 0000000..730984a Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/right-arrow.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/star.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/star.png new file mode 100644 index 0000000..2eb9ab2 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/star.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/support.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/support.png new file mode 100644 index 0000000..4f18b8b Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/support.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/misc/whatsapp.png b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/whatsapp.png new file mode 100644 index 0000000..d513a53 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/misc/whatsapp.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/modules/1.png b/odex30_base/size_restriction_for_attachments/static/description/assets/modules/1.png new file mode 100644 index 0000000..4e4ea0e Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/modules/1.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/modules/2.png b/odex30_base/size_restriction_for_attachments/static/description/assets/modules/2.png new file mode 100644 index 0000000..844b870 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/modules/2.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/modules/3.png b/odex30_base/size_restriction_for_attachments/static/description/assets/modules/3.png new file mode 100644 index 0000000..0f0d5d3 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/modules/3.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/modules/4.png b/odex30_base/size_restriction_for_attachments/static/description/assets/modules/4.png new file mode 100644 index 0000000..713d6de Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/modules/4.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/modules/5.png b/odex30_base/size_restriction_for_attachments/static/description/assets/modules/5.png new file mode 100644 index 0000000..6d11dfe Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/modules/5.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/modules/6.gif b/odex30_base/size_restriction_for_attachments/static/description/assets/modules/6.gif new file mode 100644 index 0000000..474c6e6 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/modules/6.gif differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/hero.gif b/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/hero.gif new file mode 100644 index 0000000..add58c2 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/hero.gif differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/size141_en.png b/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/size141_en.png new file mode 100644 index 0000000..0ee4c40 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/size141_en.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/size142_en.png b/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/size142_en.png new file mode 100644 index 0000000..8a9b2fb Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/size142_en.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/size143_en.png b/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/size143_en.png new file mode 100644 index 0000000..b12b1c2 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/size143_en.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/size144_en.png b/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/size144_en.png new file mode 100644 index 0000000..055af2b Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/assets/screenshots/size144_en.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/banner.jpg b/odex30_base/size_restriction_for_attachments/static/description/banner.jpg new file mode 100644 index 0000000..41e3b98 Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/banner.jpg differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/icon.png b/odex30_base/size_restriction_for_attachments/static/description/icon.png new file mode 100644 index 0000000..442e65c Binary files /dev/null and b/odex30_base/size_restriction_for_attachments/static/description/icon.png differ diff --git a/odex30_base/size_restriction_for_attachments/static/description/index.html b/odex30_base/size_restriction_for_attachments/static/description/index.html new file mode 100644 index 0000000..8808a89 --- /dev/null +++ b/odex30_base/size_restriction_for_attachments/static/description/index.html @@ -0,0 +1,534 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+
+ +
+
+
+ +

+ Size Restriction For Attachments

+

Shows a warning message if attachment greater than users maximum attachment size.

+ + +
+
+
+
+ + +
+
+ +
+

Explore This + Module

+
+ + + + +
+
+ +
+

Overview +

+
+
+
+ This App will help to restrict the attachment size. If the size of attachment is greater than + the maximum size assigned for that person then error message will be shown. + +
+
+ + + +
+
+ +
+

Features +

+
+
+
+ + Can set restriction to the size of attachment file. +
+
+ + + + +
+
+ +
+

Screenshots +

+
+
+
+
+

Enable Set Restriction. +

+

Go to users and under access rights if we want to set restriction for a user then enable set restriction.

+ +
+ +
+

Set Maximum Size. +

+

Set maximum file size in mb which the user can upload.

+ +
+ +
+

Attachment.

+

If we try to attach a file greater than the maximum size an error message is shown.

+ +
+ +
+ +
+
+
+ + +
+
+ +
+

Suggested + Products +

+
+
+
+ +
+
+ + + + + + +
+
+ +
+

Our Services +

+
+ +
+
+
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+ +
+ + + + + +
+
+ +
+

Our + Industries +

+
+ +
+
+
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+
+
+ + + + +
+
+ +
+

Support +

+
+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on WhatsApp!

+ +

+91 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ + diff --git a/odex30_base/size_restriction_for_attachments/static/src/js/size.js b/odex30_base/size_restriction_for_attachments/static/src/js/size.js new file mode 100644 index 0000000..bb2d86f --- /dev/null +++ b/odex30_base/size_restriction_for_attachments/static/src/js/size.js @@ -0,0 +1,59 @@ + +import { registry } from "@web/core/registry"; +import { patch } from "@web/core/utils/patch"; +import { _t } from "@web/core/l10n/translation"; +import { AttachmentUploadService, attachmentUploadService } from '@mail/core/common/attachment_upload_service'; +import { rpc } from "@web/core/network/rpc"; + +export const customAttachmentSizeService = { + async start() { + let maxSize = 0; + try { + const result = await rpc("/web/dataset/call_kw/res.users/get_current_user_size_restriction", { + model: "res.users", + method: "get_current_user_size_restriction", + args: [], + kwargs: {}, + }); + if (result.set_restriction) { + maxSize = result.max_size * 1024 * 1024; + } + } catch (error) { + } + return { + getMaxSize: () => maxSize, + }; + }, +}; + +registry.category("services").add("custom_attachment_size", customAttachmentSizeService); + +attachmentUploadService.dependencies.push("custom_attachment_size"); + +patch(AttachmentUploadService.prototype, { + setup(env, services) { + super.setup(...arguments); + this.customAttachmentSizeService = services.custom_attachment_size; + }, + + async upload(thread, composer, file, options) { + const maxSize = this.customAttachmentSizeService?.getMaxSize(); + + if (typeof maxSize !== 'number') { + return super.upload(...arguments); + } + + console.log(`AttachmentUploadService Patch: Checking file "${file.name}". Size: ${file.size}, Max Size Allowed: ${maxSize}`); + + if (maxSize > 0 && file.size > maxSize) { + const maxSizeMB = (maxSize / 1024 / 1024).toFixed(2); + this.notificationService.add( + _t("The file '%s' exceeds the maximum size limit of %s MB and was not attached.", file.name, maxSizeMB), + { type: "danger" } + ); + return Promise.resolve(); + } + + return super.upload(...arguments); + } +}); diff --git a/odex30_base/size_restriction_for_attachments/views/res_users.xml b/odex30_base/size_restriction_for_attachments/views/res_users.xml new file mode 100644 index 0000000..804b4f9 --- /dev/null +++ b/odex30_base/size_restriction_for_attachments/views/res_users.xml @@ -0,0 +1,16 @@ + + + + res.users.view.form.inherit.size.restriction.for.attachments + res.users + + + + + + + \ No newline at end of file