-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][ADD] attachment_log #3161
base: 16.0
Are you sure you want to change the base?
Conversation
9b18974
to
fc0cd0a
Compare
message = record.message_post( | ||
body=Markup( | ||
_( | ||
"User <b>%(username)s</b> is attached a new file: <i>%(filename)s</i>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"User <b>%(username)s</b> is attached a new file: <i>%(filename)s</i>" | |
"<b>%(username)s</b> attached a file: <i>%(filename)s</i>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would then show as Mitchell Admin attached a file: Invoice.pdf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are my concerns: why should we post a message for every attachment added?
What if an incoming email arrives with 10+ attachments in it? It will result in 10+ messages trashing the record chatter.
You can simply show name of the user who added attachment together with the creation date. That is.
attachment_log/__manifest__.py
Outdated
"website": "https://github.com/OCA/server-tools", | ||
"license": "AGPL-3", | ||
"category": "Generic Modules", | ||
"depends": ["base", "mail"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to depend on base
because mail
already depends on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add test coverage for the features you are adding.
record = self.env[self.res_model].sudo().browse(self.res_id) | ||
message_text = _( | ||
"<b>%(username)s</b> %(action)s a file: <i>%(filename)s</i>" | ||
) % { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use correct method for string translations.
attachment_log/__manifest__.py
Outdated
"summary": "Add log info for attachments", | ||
"website": "https://github.com/OCA/server-tools", | ||
"license": "AGPL-3", | ||
"category": "Generic Modules", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that such category exists? If yes, please share a link to it.
attachment_log/__manifest__.py
Outdated
"attachment_log/static/src/components/*/*", | ||
] | ||
}, | ||
"installable": True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True
is the default value for this key, no need to add it.
class IrAttachment(models.Model): | ||
_inherit = "ir.attachment" | ||
|
||
def _send_attachment_notification(self, is_create=False, is_unlink=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Posting messages in chatter should be an option that is toggled in the configuration. Because some users might considered it not useful and even annoying.
attachment_log/__manifest__.py
Outdated
@@ -0,0 +1,18 @@ | |||
{ | |||
"name": "Attachment Log", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name is irrelevant because you are not adding any logging. There is no attachment log implemented.
It either logging or tracking.
Suggested name could be "Attachment Logging" with the technical name adjusted accordingly.
attachment_log/__manifest__.py
Outdated
"name": "Attachment Log", | ||
"version": "16.0.1.0.0", | ||
"author": "Cetmix, Odoo Community Association (OCA)", | ||
"summary": "Add log info for attachments", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not adding any log info to attachments. You are showing tracking information or metadata.
So should be something like Show attachment information in chatter
.
@@ -0,0 +1,4 @@ | |||
This module adds the following features for attachments: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
"filename": self.name, | ||
"action": action, | ||
} | ||
message = record.message_post( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use a custom message subtype for such messages in order to allow more flexible configuration.
cd55848
to
7e55b4c
Compare
7e55b4c
to
81f090d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add CONFIGURE.rts to explain the configuration process.
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.
Add screenshots that make both configuration and usage easier. Must be not more than 800px width.
Here is an example. Don't use this picture because you need to fix the configuration view first.
attachment_logging/__manifest__.py
Outdated
"name": "Attachment Logging", | ||
"version": "16.0.1.0.0", | ||
"author": "Cetmix, Odoo Community Association (OCA)", | ||
"summary": "Show attachment information in chatter", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show attachment<remove_extra_space_here> information in chatter
|
||
use_attachment_log = fields.Boolean( | ||
config_parameter="attachment_logging.use_attachment_log", | ||
help="Log a file operation for record in chatter", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log attachment operations in chatter
attachment_logging/readme/USAGE.rst
Outdated
@@ -0,0 +1 @@ | |||
Module automatically log in chatter the date and time when each attachment was added and which user linked or unlinked files to attachments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
<field name="use_attachment_log" /> | ||
</div> | ||
<div class="o_setting_right_pane"> | ||
<span class="o_form_label">Attachment Log</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attachment Logging
<div class="o_setting_right_pane"> | ||
<span class="o_form_label">Attachment Log</span> | ||
<div class="text-muted col-md-12"> | ||
Log attached or unlinked file in chatter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log a note in record chatter when an attachment is added or removed.
<div class="text-muted col-md-12"> | ||
Log attached or unlinked file in chatter | ||
</div> | ||
<div |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this twillio div doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review LGTM
Hi @yostashiro! Thank you for noticing that! Will fix. |
This module adds the following features for attachments: