Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ Available addons
----------------
addon | version | maintainers | summary
--- | --- | --- | ---
[attachment_logging](attachment_logging/) | 17.0.1.0.0 | | Show attachment information in chatter
[attachment_queue](attachment_queue/) | 17.0.1.0.0 | <a href='https://github.com/florian-dacosta'><img src='https://github.com/florian-dacosta.png' width='32' height='32' style='border-radius:50%;' alt='florian-dacosta'/></a> <a href='https://github.com/sebastienbeau'><img src='https://github.com/sebastienbeau.png' width='32' height='32' style='border-radius:50%;' alt='sebastienbeau'/></a> | Base module adding the concept of queue for processing files
[auditlog](auditlog/) | 17.0.1.1.0 | | Audit Log
[auto_backup](auto_backup/) | 17.0.1.1.0 | | Backups database
[auto_backup_fs_file](auto_backup_fs_file/) | 17.0.1.0.0 | | Store backups using some FSSPEC implementation
[base_cron_exclusion](base_cron_exclusion/) | 17.0.1.0.0 | <a href='https://github.com/LoisRForgeFlow'><img src='https://github.com/LoisRForgeFlow.png' width='32' height='32' style='border-radius:50%;' alt='LoisRForgeFlow'/></a> <a href='https://github.com/ChrisOForgeFlow'><img src='https://github.com/ChrisOForgeFlow.png' width='32' height='32' style='border-radius:50%;' alt='ChrisOForgeFlow'/></a> | Allow you to select scheduled actions that should not run simultaneously.
[base_exception](base_exception/) | 17.0.1.1.0 | <a href='https://github.com/hparfr'><img src='https://github.com/hparfr.png' width='32' height='32' style='border-radius:50%;' alt='hparfr'/></a> <a href='https://github.com/sebastienbeau'><img src='https://github.com/sebastienbeau.png' width='32' height='32' style='border-radius:50%;' alt='sebastienbeau'/></a> | This module provide an abstract model to manage customizable exceptions to be applied on different models (sale order, invoice, ...)
[base_fontawesome](base_fontawesome/) | 17.0.1.1.0 | | Up to date Fontawesome resources.
Expand Down
113 changes: 113 additions & 0 deletions attachment_logging/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

==================
Attachment Logging
==================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:61878ebe5df7c1dfd773c842b660cb795baa2d5ab9363557168a8c54ebd47d29
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/17.0/attachment_logging
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-17-0/server-tools-17-0-attachment_logging
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module shows attachment information in chatter. Following data is
displayed:

- User, who has created the attachment
- Attachment creation date

It also allows to log attachment related actions in the record chatter.

**Table of contents**

.. contents::
:local:

Configuration
=============

To enable note logging of attachment operations in record chatter:

- Go to "Settings > General Settings" and scroll to the "Discuss"
section.
- Activate the "Attachment Logging" checkbox.

|image|

.. |image| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/attachment_logging/static/src/img/settings.png

Usage
=====

Create date and user are displayed next to attachments in chatter. When
attachment is added or removed a note is logged in chatter if the
corresponding option is enabled in the General Settings.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20attachment_logging%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Cetmix

Contributors
------------

- Cetmix <cetmix.com>

- Ivan Sokolov
- Maksim Shurupov

- Binhex <`www.binhex.com\\> <http://www.binhex.com\>>`__

- Adasat Torres de León a.torres@binhex.cloud

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/17.0/attachment_logging>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions attachment_logging/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions attachment_logging/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Attachment Logging",
"version": "17.0.1.0.0",
"author": "Cetmix, Odoo Community Association (OCA)",
"summary": "Show attachment information in chatter",
"website": "https://github.com/OCA/server-tools",
"license": "AGPL-3",
"category": "Hidden/Tools",
"depends": ["mail"],
"data": [
"data/mail_message_subtype_data.xml",
"views/res_config_settings_views.xml",
],
"assets": {
"web.assets_backend": [
"attachment_logging/static/src/**/*",
]
},
}
11 changes: 11 additions & 0 deletions attachment_logging/data/mail_message_subtype_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">

<record id="mt_attachment" model="mail.message.subtype">
<field name="name">Attachments</field>
<field name="default" eval="False" />
<field name="internal" eval="True" />
<field name="sequence" eval="150" />
</record>

</odoo>
76 changes: 76 additions & 0 deletions attachment_logging/i18n/attachment_logging.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * attachment_logging
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: attachment_logging
#. odoo-python
#: code:addons/attachment_logging/models/ir_attachment.py:0
#, python-format
msgid "%(username)s %(action)s a file: %(filename)s"
msgstr ""

#. module: attachment_logging
#: model:ir.model,name:attachment_logging.model_ir_attachment
msgid "Attachment"
msgstr ""

#. module: attachment_logging
#: model_terms:ir.ui.view,arch_db:attachment_logging.res_config_settings_form_view
msgid "Attachment Logging"
msgstr ""

#. module: attachment_logging
#: model:mail.message.subtype,name:attachment_logging.mt_attachment
msgid "Attachments"
msgstr ""

#. module: attachment_logging
#: model:ir.model,name:attachment_logging.model_res_config_settings
msgid "Config Settings"
msgstr ""

#. module: attachment_logging
#: model_terms:ir.ui.view,arch_db:attachment_logging.res_config_settings_form_view
msgid "Log a note in record chatter when an attachment is added or removed."
msgstr ""

#. module: attachment_logging
#: model:ir.model.fields,help:attachment_logging.field_res_config_settings__use_attachment_log
msgid "Log attachment operations in chatter"
msgstr ""

#. module: attachment_logging
#: model:ir.model.fields,field_description:attachment_logging.field_ir_attachment__smart_search
#: model:ir.model.fields,field_description:attachment_logging.field_res_config_settings__smart_search
msgid "Smart Search"
msgstr ""

#. module: attachment_logging
#: model:ir.model.fields,field_description:attachment_logging.field_res_config_settings__use_attachment_log
msgid "Use Attachment Log"
msgstr ""

#. module: attachment_logging
#. odoo-python
#: code:addons/attachment_logging/models/ir_attachment.py:0
#, python-format
msgid "attached"
msgstr ""

#. module: attachment_logging
#. odoo-python
#: code:addons/attachment_logging/models/ir_attachment.py:0
#, python-format
msgid "unlinked"
msgstr ""
77 changes: 77 additions & 0 deletions attachment_logging/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * attachment_logging
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"

#. module: attachment_logging
#. odoo-python
#: code:addons/attachment_logging/models/ir_attachment.py:0
#, python-format
msgid "%(username)s %(action)s a file: %(filename)s"
msgstr ""

#. module: attachment_logging
#: model:ir.model,name:attachment_logging.model_ir_attachment
msgid "Attachment"
msgstr ""

#. module: attachment_logging
#: model_terms:ir.ui.view,arch_db:attachment_logging.res_config_settings_form_view
msgid "Attachment Logging"
msgstr ""

#. module: attachment_logging
#: model:mail.message.subtype,name:attachment_logging.mt_attachment
msgid "Attachments"
msgstr ""

#. module: attachment_logging
#: model:ir.model,name:attachment_logging.model_res_config_settings
msgid "Config Settings"
msgstr ""

#. module: attachment_logging
#: model_terms:ir.ui.view,arch_db:attachment_logging.res_config_settings_form_view
msgid "Log a note in record chatter when an attachment is added or removed."
msgstr ""

#. module: attachment_logging
#: model:ir.model.fields,help:attachment_logging.field_res_config_settings__use_attachment_log
msgid "Log attachment operations in chatter"
msgstr ""

#. module: attachment_logging
#: model:ir.model.fields,field_description:attachment_logging.field_ir_attachment__smart_search
#: model:ir.model.fields,field_description:attachment_logging.field_res_config_settings__smart_search
msgid "Smart Search"
msgstr ""

#. module: attachment_logging
#: model:ir.model.fields,field_description:attachment_logging.field_res_config_settings__use_attachment_log
msgid "Use Attachment Log"
msgstr ""

#. module: attachment_logging
#. odoo-python
#: code:addons/attachment_logging/models/ir_attachment.py:0
#, python-format
msgid "attached"
msgstr ""

#. module: attachment_logging
#. odoo-python
#: code:addons/attachment_logging/models/ir_attachment.py:0
#, python-format
msgid "unlinked"
msgstr ""
2 changes: 2 additions & 0 deletions attachment_logging/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import ir_attachment
from . import res_config_settings
76 changes: 76 additions & 0 deletions attachment_logging/models/ir_attachment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
from odoo import _, api, models
from odoo.tools.misc import format_datetime


class IrAttachment(models.Model):
_inherit = "ir.attachment"

def _send_attachment_notification(self, is_create=False, is_unlink=False):
"""
Send attachment notification

:param is_create: send notification for create method
:param is_unlink: send notification for unlink method
"""
if is_create:
action = _("attached")
elif is_unlink:
action = _("unlinked")
else:
return
record = self.env[self.res_model].sudo().browse(self.res_id)
message_text = _(
"%(username)s %(action)s a file: %(filename)s",
username=self.create_uid.name,
filename=self.name,
action=action,
)
record.message_post(
body=message_text,
message_type="notification",
author_id=self.env.ref("base.user_root").partner_id.id,
subtype_xmlid="attachment_logging.mt_attachment",
)

@api.model
def _is_use_attachment_log(self):
"""Check use attachment log"""
return (
self.env["ir.config_parameter"]
.sudo()
.get_param("attachment_logging.use_attachment_log", False)
)

def _post_add_create(self, **kwargs):
result = super()._post_add_create(**kwargs)
if self._is_use_attachment_log():
# Send notification after creation attachments
for attachment in self:
if self.pool and issubclass(
self.pool[attachment.res_model], self.pool["mail.thread"]
):
attachment._send_attachment_notification(is_create=True)
return result

def _delete_and_notify(self, message=None):
if self._is_use_attachment_log():
for attachment in self:
if self.pool and issubclass(
self.pool[attachment.res_model], self.pool["mail.thread"]
):
attachment._send_attachment_notification(is_unlink=True)
return super()._delete_and_notify(message)

def _attachment_format(self):
attachment_vals = super()._attachment_format()
for attachment_val in attachment_vals:
attachment = self.browse(attachment_val["id"])
attachment_val.update(
{
"create_user": attachment.create_uid.name,
"create_date": format_datetime(
self.env, attachment_val["create_date"]
),
}
)
return attachment_vals
Loading
Loading