@ -0,0 +1,49 @@ |
|||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg |
|||
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
Chatter Attachment Manager |
|||
========================== |
|||
This module helps to manage attachments in chatter and in discuss |
|||
|
|||
Configuration |
|||
============= |
|||
* No Additional configuration is needed. |
|||
|
|||
License |
|||
------- |
|||
Gnu Affero General Public License, Version 3 (AGPL v3). |
|||
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
|||
|
|||
Company |
|||
------- |
|||
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
|||
|
|||
Credits |
|||
------- |
|||
* Developer: (V16) Anagha S, |
|||
(V17) Sabeel B, |
|||
(V18) Nikhil M |
|||
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 <https://cybrosys.com/>`__ |
|||
|
|||
Further information |
|||
=================== |
|||
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nikhil M (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 <http://www.gnu.org/licenses/>. |
|||
################################################################################ |
|||
from . import controllers |
|||
from . import models |
@ -0,0 +1,61 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nikhil M (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 <http://www.gnu.org/licenses/>. |
|||
################################################################################ |
|||
{ |
|||
'name': 'Chatter Attachment Manager', |
|||
'version': '18.0.1.0.0', |
|||
'category': 'Discuss, Document Management', |
|||
'summary': 'This module help to manage attachments', |
|||
'description': """This module helps to enhance the attachment management |
|||
capabilities within Odoo.Can easily edit,read, save, preview your documents |
|||
inside odoo. Module works in discuss, chat and chatter of any record""", |
|||
'author': 'Cybrosys Techno Solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'website': "https://www.cybrosys.com", |
|||
'depends': ['base', 'mail', 'web'], |
|||
'data': [ |
|||
'security/ir.model.access.csv', |
|||
'views/ir_attachment_views.xml', |
|||
'report/chatter_attachments_manager_report_templates.xml', |
|||
], |
|||
'assets': { |
|||
'web.assets_backend': [ |
|||
'https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.6.0/fabric.js', |
|||
'https://uicdn.toast.com/tui.code-snippet/v1.5.0/tui-code-snippet.min.js', |
|||
'https://uicdn.toast.com/tui-color-picker/v2.2.6/tui-color-picker.js', |
|||
'https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.3/FileSaver.min.js', |
|||
'https://uicdn.toast.com/tui-image-editor/latest/tui-image-editor.js', |
|||
'https://uicdn.toast.com/tui-image-editor/latest/tui-image-editor.css', |
|||
'chatter_attachments_manager/static/src/attachment_control_panel/**/*', |
|||
'chatter_attachments_manager/static/src/attachment_image/**/*', |
|||
'chatter_attachments_manager/static/src/css/**/*', |
|||
'chatter_attachments_manager/static/src/registry/**/*', |
|||
], |
|||
}, |
|||
'external_dependencies': {'python': ['pandas','qrcode','python-docx']}, |
|||
'images': [ |
|||
'static/description/banner.png', |
|||
], |
|||
'license': 'AGPL-3', |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False |
|||
} |
@ -0,0 +1,21 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nikhil M (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 <http://www.gnu.org/licenses/>. |
|||
################################################################################ |
|||
from . import chatter_attachment_manager |
@ -0,0 +1,62 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nikhil M (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 <http://www.gnu.org/licenses/>. |
|||
################################################################################ |
|||
import zipfile |
|||
from datetime import datetime |
|||
|
|||
try: |
|||
from BytesIO import BytesIO |
|||
except ImportError: |
|||
from io import BytesIO |
|||
|
|||
from odoo import http |
|||
from odoo.http import request, content_disposition |
|||
|
|||
class Binary(http.Controller): |
|||
"""Attachment downloading binary class.""" |
|||
|
|||
@http.route('/web/binary/download_document', type='http', |
|||
auth='public') |
|||
def download_zip(self, **kwargs): |
|||
"""This method used to download all chatter attachments inside a record |
|||
as a zip file.""" |
|||
model = kwargs.get('param1', 0) |
|||
tab_id = int(kwargs.get('param2', 0)) |
|||
attachment_ids = request.env['ir.attachment'].search( |
|||
[('res_model', '=', model), ('res_id', '=', tab_id)]) |
|||
file_dict = {} |
|||
for attachment_id in attachment_ids: |
|||
file_store = attachment_id.store_fname |
|||
if file_store: |
|||
file_name = attachment_id.name |
|||
file_path = attachment_id._full_path(file_store) |
|||
file_dict[f"{file_store}:{file_name}"] = { |
|||
'path': file_path, 'name': file_name} |
|||
zip_filename = datetime.now() |
|||
zip_filename = f"{zip_filename}.zip" |
|||
bit_io = BytesIO() |
|||
with zipfile.ZipFile(bit_io, "w", |
|||
zipfile.ZIP_DEFLATED) as zip_file: |
|||
for file_info in file_dict.values(): |
|||
zip_file.write(file_info["path"], file_info["name"]) |
|||
zip_file.close() |
|||
return request.make_response(bit_io.getvalue(), headers=[ |
|||
('Content-Type', 'application/zip'), |
|||
('Content-Disposition', http.content_disposition(zip_filename))]) |
@ -0,0 +1,6 @@ |
|||
## Module <chatter_attachments_manager> |
|||
|
|||
#### 02.11.2024 |
|||
#### Version 18.0.1.0.0 |
|||
#### ADD |
|||
- Initial commit for Chatter Attachment Manager |
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################### |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nikhil M (odoo@cybrosys.com) |
|||
# |
|||
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1) |
|||
# It is forbidden to publish, distribute, sublicense, or sell copies of the |
|||
# Software or modified copies 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 NON INFRINGEMENT. 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. |
|||
# |
|||
############################################################################### |
|||
from . import ir_attachment |
|||
from . import ir_attachment_tag |
@ -0,0 +1,112 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nikhil M (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 <http://www.gnu.org/licenses/>. |
|||
################################################################################ |
|||
import io |
|||
import base64 |
|||
from io import BytesIO |
|||
|
|||
import pandas as pd |
|||
from docx import Document as DocxDocument |
|||
import qrcode |
|||
from odoo import api, fields, models |
|||
|
|||
|
|||
class IrAttachment(models.Model): |
|||
"""Extended Attachment Model (Inherited from 'ir.attachment') |
|||
|
|||
This class represents an extension of the original 'ir.attachment' model in |
|||
Odoo. The 'ir.attachment' model is a built-in Odoo model that handles file |
|||
attachments to various records, such as documents, emails, or notes. |
|||
|
|||
In this custom model, we extend the functionality of 'ir.attachment' to add |
|||
new fields and custom methods to cater to specific requirements of our |
|||
application. |
|||
""" |
|||
_inherit = 'ir.attachment' |
|||
|
|||
tags_ids = fields.Many2many(comodel_name='ir.attachment.tag', |
|||
string='Tags', help="Tags for attachments") |
|||
|
|||
@api.model |
|||
def decode_content(self, attach_id, doc_type): |
|||
"""Decode XLSX or DOC File Data. |
|||
This method takes a binary file data from an attachment and decodes |
|||
the content of the file for XLSX and DOC file formats. |
|||
:param int attach_id: id of attachment. |
|||
:param str doc_type: the type of the given attachment either 'xlsx' or |
|||
'doc' |
|||
:return: return the decoded data.""" |
|||
attachment = self.sudo().browse(attach_id) |
|||
xlsx_data = base64.b64decode(attachment.datas) |
|||
if doc_type in ['xlsx', 'xls', 'docx']: |
|||
try: |
|||
if doc_type == 'xlsx': |
|||
content = pd.read_excel(BytesIO(xlsx_data), |
|||
engine='openpyxl', |
|||
converters={'A': str}) |
|||
elif doc_type == 'xls': |
|||
content = pd.read_excel(BytesIO(xlsx_data), engine='xlrd', |
|||
converters={'A': str}) |
|||
elif doc_type == 'docx': |
|||
doc = DocxDocument(io.BytesIO(xlsx_data)) |
|||
paragraphs = [p.text for p in doc.paragraphs] |
|||
return paragraphs |
|||
else: |
|||
raise ValueError("Unsupported file format") |
|||
html_table = content.to_html(index=False) |
|||
return html_table |
|||
except TypeError: |
|||
return ("<p style='padding-top:8px;color:red;'>" |
|||
"No preview available</p>") |
|||
text = "Cant Preview" |
|||
return text |
|||
|
|||
@api.model |
|||
def save_edited_image(self, attachment_id, myImage): |
|||
"""The image is replaced by image from Toast image editor |
|||
:param int attach_id: id of attachment. |
|||
:param str image: new image data |
|||
:return file containing image |
|||
""" |
|||
file = self.sudo().browse(attachment_id) |
|||
file.write({'datas': myImage.strip('data:image/png;base64')}) |
|||
return file |
|||
|
|||
@api.model |
|||
def generate_qr_code(self, attach_id): |
|||
"""Generate qr code for attachment tha allow anyone to download it.""" |
|||
base_url = self.env['ir.config_parameter'].sudo().get_param( |
|||
'web.base.url') |
|||
data = {} |
|||
download_url = f"mail/channel/1/attachment/{attach_id}?download=true" |
|||
if qrcode and base64: |
|||
attach_qr = qrcode.QRCode( |
|||
version=3, |
|||
error_correction=qrcode.constants.ERROR_CORRECT_L, |
|||
box_size=4, border=4) |
|||
attach_qr.add_data(base_url + download_url) |
|||
attach_qr.make(fit=True) |
|||
img = attach_qr.make_image() |
|||
temp = BytesIO() |
|||
img.save(temp, format="PNG") |
|||
qr_image = base64.b64encode(temp.getvalue()) |
|||
data.update({'image': qr_image, |
|||
'company': self.env.company.name}) |
|||
return data |
@ -0,0 +1,39 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Nikhil M (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 <http://www.gnu.org/licenses/>. |
|||
################################################################################ |
|||
from random import randint |
|||
from odoo import fields, models |
|||
|
|||
|
|||
class AttachmentTag(models.Model): |
|||
"""Attachment tag model.""" |
|||
_name = "ir.attachment.tag" |
|||
_description = "Attachment Tag" |
|||
|
|||
def _get_default_color(self): |
|||
"""To get default color for tags.""" |
|||
return randint(1, 11) |
|||
|
|||
name = fields.Char(string='Tag Name', required=True, translate=True, |
|||
help='Name of tags.') |
|||
color = fields.Integer(string='Color', default=_get_default_color, |
|||
help="Tag color.") |
|||
_sql_constraints = [ |
|||
('name_uniq', 'unique (name)', "Tag name already exists !"),] |
@ -0,0 +1,27 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Attachment report contain qrcode--> |
|||
<record id="attachment_qr_code" model="ir.actions.report"> |
|||
<field name="name">Attachment QR Code</field> |
|||
<field name="model">ir.attachment</field> |
|||
<field name="report_type">qweb-pdf</field> |
|||
<field name="report_name">chatter_attachments_manager.attachment_qr_report_template</field> |
|||
<field name="report_file">chatter_attachments_manager.attachment_qr_report_template</field> |
|||
</record> |
|||
<!-- Attachment QR code report--> |
|||
<template id="attachment_qr_report_template"> |
|||
<t t-call="web.basic_layout"> |
|||
<div class="page container"> |
|||
<div class="text-center"> |
|||
<h2>Attachment Qrcode |
|||
</h2> |
|||
<br/> |
|||
<img class="qr-code-img" style="width:420px;height:420px;" |
|||
t-attf-src="data:image/png;base64,{{image}}"/> |
|||
<br/> |
|||
You can scan the qr code and download the file. |
|||
</div> |
|||
</div> |
|||
</t> |
|||
</template> |
|||
</odoo> |
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 678 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 81 KiB |
After Width: | Height: | Size: 83 KiB |
After Width: | Height: | Size: 83 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 565 B |