Skip to content

Commit

Permalink
[MIG] autovacuum_message_attachment: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GabbasovDinar committed Feb 10, 2025
1 parent 65e1d1d commit 1f5f226
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 63 deletions.
84 changes: 73 additions & 11 deletions autovacuum_message_attachment/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,79 @@ messages you want to delete automatically.
Configuration
=============

- Go to the menu configuration => Technical => Email => Message And
Attachment Vacuum Rules
- Add the adequates rules for your company. On each rule, you can
indicate the models, type and subtypes for which you want to delete
the messages, along with a retention time (in days). Or for
attachment, you can specify a substring of the name.
- Activate the cron AutoVacuum Mails and Messages and/or AutoVacuum
Attachments

It is recommanded to run it frequently and when the system is not very
loaded. (For instance : once a day, during the night.)
To Create AutoVacuum Rules
--------------------------

Go to Settings -> Technical -> Email -> Message And Attachment Vacuum
Rules

- Press the "New" button to add a new rule

To Configure the Attachment AutoVacuum Rule
-------------------------------------------

- **Name:** Set the name of the rule
- **Type:** Select type "Attachment"
- **Company:** Select a Company
- **Retention Time:** Set Retention Time in days
- **Filename Pattern:** Set file name pattern (for example ".pdf")
- **Inherited Model:** Set the Inherited Model (optional)
- **Model:** Select the Model to apply the rule to
- **Model Filter Domain:** Specify the domain for the model to select
particular records only
- **Description:** Add a description for the rule set (optional)

|image1|

To Configure the Message AutoVacuum Rule
----------------------------------------

- **Name:** Set the name of the rule
- **Type:** Select type "Message"
- **Company:** Select a Company
- **Retention Time:** Set Retention Time in days
- **Message Type:** Select the Message Type to apply the rule to:

- **All:** Apply to all messages
- **Comment:** Apply to comments
- **System Notification:** Apply to system notifications
- **User Specific Notification:** Apply to user specific notifications

- **Empty Subtype:** Apply to messages with no subtype
- **Message Subtype:** Press the "Add line" button and select the
Chatter Message Subtype to apply the rule to
- **Model:** Select the Model to apply the rule to
- **Message Filter Domain:** Specify the domain for the model to select
particular records only
- **Description:** Add a description for the rule set (optional)

|image2|

To Configure AutoVacuum Cron Jobs
---------------------------------

Note: The AutoVacuum Mails and Messages and AutoVacuum Attachments
scheduled actions are created by default and need to be activated.

Go to Settings -> Technical -> Automation -> Scheduled Actions

- Activate the scheduled actions needed (AutoVacuum Mails and Messages
and/or AutoVacuum Attachments)
- Go to Actions -> Unarchive or toggle the Active status of the
scheduled action
- Select a record and specify the frequency of the cron job if needed

|image3|

|image4|

Note: It is recommanded to run it frequently and when the system is not
very loaded. (For instance : once a day, during the night.)

.. |image1| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/autovacuum_message_attachment/static/description/Attachment_Vacuum_Rule.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/autovacuum_message_attachment/static/description/Message_Vacuum_Rule.png
.. |image3| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/autovacuum_message_attachment/static/description/AutoVacuum_Cron_Jobs.png
.. |image4| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/autovacuum_message_attachment/static/description/AutoVacuum_Cron_Jobs2.png

Known issues / Roadmap
======================
Expand Down
3 changes: 1 addition & 2 deletions autovacuum_message_attachment/models/vacuum_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ def _compute_model_id(self):
)
model_id = fields.Many2one(
"ir.model",
readonly=True,
compute="_compute_model_id",
help="Technical field used to set attributes (invisible/required, "
"domain, etc...for other fields, like the domain filter",
)
model_filter_domain = fields.Text()
model = fields.Char(readonly=True, compute="_compute_model_id", string="Model code")
model = fields.Char(compute="_compute_model_id", string="Model code")
empty_model = fields.Boolean(
help="Take into account attachment not linked to any model, but only if a "
"pattern is set, to avoid deleting attachments generated/needed by odoo"
Expand Down
62 changes: 51 additions & 11 deletions autovacuum_message_attachment/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,51 @@
- Go to the menu configuration =\> Technical =\> Email =\> Message And
Attachment Vacuum Rules
- Add the adequates rules for your company. On each rule, you can
indicate the models, type and subtypes for which you want to delete
the messages, along with a retention time (in days). Or for
attachment, you can specify a substring of the name.
- Activate the cron AutoVacuum Mails and Messages and/or AutoVacuum
Attachments

It is recommanded to run it frequently and when the system is not very
loaded. (For instance : once a day, during the night.)
## To Create AutoVacuum Rules

Go to Settings -\> Technical -\> Email -\> Message And Attachment Vacuum Rules
- Press the "New" button to add a new rule

## To Configure the Attachment AutoVacuum Rule
- **Name:** Set the name of the rule
- **Type:** Select type "Attachment"
- **Company:** Select a Company
- **Retention Time:** Set Retention Time in days
- **Filename Pattern:** Set file name pattern (for example ".png")
- **Inherited Model:** Set the Inherited Model (optional)
- **Model:** Select the Model to apply the rule to
- **Model Filter Domain:** Specify the domain for the model to select particular records only
- **Description:** Add a description for the rule set (optional)

![](../static/description/Attachment_Vacuum_Rule.png)

## To Configure the Message AutoVacuum Rule
- **Name:** Set the name of the rule
- **Type:** Select type "Message"
- **Company:** Select a Company
- **Retention Time:** Set Retention Time in days
- **Message Type:** Select the Message Type to apply the rule to:
- **All:** Apply to all messages
- **Comment:** Apply to comments
- **System Notification:** Apply to system notifications
- **User Specific Notification:** Apply to user specific notifications
- **Empty Subtype:** Apply to messages with no subtype
- **Message Subtype:** Press the "Add line" button and select the Chatter Message Subtype to apply the rule to
- **Model:** Select the Model to apply the rule to
- **Message Filter Domain:** Specify the domain for the model to select particular records only
- **Description:** Add a description for the rule set (optional)

![](../static/description/Message_Vacuum_Rule.png)

## To Configure AutoVacuum Cron Jobs

Note: The AutoVacuum Mails and Messages and AutoVacuum Attachments scheduled actions are created by default and need to be activated.

Go to Settings -\> Technical -\> Automation -\> Scheduled Actions
- Activate the scheduled actions needed (AutoVacuum Mails and Messages and/or AutoVacuum Attachments)
- Go to Actions -> Unarchive or toggle the Active status of the scheduled action
- Select a record and specify the frequency of the cron job if needed

![](../static/description/AutoVacuum_Cron_Jobs.png)

![](../static/description/AutoVacuum_Cron_Jobs2.png)


Note: It is recommended to run it frequently and when the system is not very loaded. (For instance: once a day, during the night.)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 82 additions & 23 deletions autovacuum_message_attachment/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -378,58 +378,117 @@ <h1 class="title">AutoVacuum Mail Message and Attachment</h1>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-2">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a><ul>
<li><a class="reference internal" href="#to-create-autovacuum-rules" id="toc-entry-2">To Create AutoVacuum Rules</a></li>
<li><a class="reference internal" href="#to-configure-the-attachment-autovacuum-rule" id="toc-entry-3">To Configure the Attachment AutoVacuum Rule</a></li>
<li><a class="reference internal" href="#to-configure-the-message-autovacuum-rule" id="toc-entry-4">To Configure the Message AutoVacuum Rule</a></li>
<li><a class="reference internal" href="#to-configure-autovacuum-cron-jobs" id="toc-entry-5">To Configure AutoVacuum Cron Jobs</a></li>
</ul>
</li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-6">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-7">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-8">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-9">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-10">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-11">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<div class="section" id="to-create-autovacuum-rules">
<h2><a class="toc-backref" href="#toc-entry-2">To Create AutoVacuum Rules</a></h2>
<p>Go to Settings -&gt; Technical -&gt; Email -&gt; Message And Attachment Vacuum
Rules</p>
<ul class="simple">
<li>Press the “New” button to add a new rule</li>
</ul>
</div>
<div class="section" id="to-configure-the-attachment-autovacuum-rule">
<h2><a class="toc-backref" href="#toc-entry-3">To Configure the Attachment AutoVacuum Rule</a></h2>
<ul class="simple">
<li><strong>Name:</strong> Set the name of the rule</li>
<li><strong>Type:</strong> Select type “Attachment”</li>
<li><strong>Company:</strong> Select a Company</li>
<li><strong>Retention Time:</strong> Set Retention Time in days</li>
<li><strong>Filename Pattern:</strong> Set file name pattern (for example “.pdf”)</li>
<li><strong>Inherited Model:</strong> Set the Inherited Model (optional)</li>
<li><strong>Model:</strong> Select the Model to apply the rule to</li>
<li><strong>Model Filter Domain:</strong> Specify the domain for the model to select
particular records only</li>
<li><strong>Description:</strong> Add a description for the rule set (optional)</li>
</ul>
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/server-tools/17.0/autovacuum_message_attachment/static/description/Attachment_Vacuum_Rule.png" /></p>
</div>
<div class="section" id="to-configure-the-message-autovacuum-rule">
<h2><a class="toc-backref" href="#toc-entry-4">To Configure the Message AutoVacuum Rule</a></h2>
<ul class="simple">
<li>Go to the menu configuration =&gt; Technical =&gt; Email =&gt; Message And
Attachment Vacuum Rules</li>
<li>Add the adequates rules for your company. On each rule, you can
indicate the models, type and subtypes for which you want to delete
the messages, along with a retention time (in days). Or for
attachment, you can specify a substring of the name.</li>
<li>Activate the cron AutoVacuum Mails and Messages and/or AutoVacuum
Attachments</li>
<li><strong>Name:</strong> Set the name of the rule</li>
<li><strong>Type:</strong> Select type “Message”</li>
<li><strong>Company:</strong> Select a Company</li>
<li><strong>Retention Time:</strong> Set Retention Time in days</li>
<li><strong>Message Type:</strong> Select the Message Type to apply the rule to:<ul>
<li><strong>All:</strong> Apply to all messages</li>
<li><strong>Comment:</strong> Apply to comments</li>
<li><strong>System Notification:</strong> Apply to system notifications</li>
<li><strong>User Specific Notification:</strong> Apply to user specific notifications</li>
</ul>
</li>
<li><strong>Empty Subtype:</strong> Apply to messages with no subtype</li>
<li><strong>Message Subtype:</strong> Press the “Add line” button and select the
Chatter Message Subtype to apply the rule to</li>
<li><strong>Model:</strong> Select the Model to apply the rule to</li>
<li><strong>Message Filter Domain:</strong> Specify the domain for the model to select
particular records only</li>
<li><strong>Description:</strong> Add a description for the rule set (optional)</li>
</ul>
<p>It is recommanded to run it frequently and when the system is not very
loaded. (For instance : once a day, during the night.)</p>
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/server-tools/17.0/autovacuum_message_attachment/static/description/Message_Vacuum_Rule.png" /></p>
</div>
<div class="section" id="to-configure-autovacuum-cron-jobs">
<h2><a class="toc-backref" href="#toc-entry-5">To Configure AutoVacuum Cron Jobs</a></h2>
<p>Note: The AutoVacuum Mails and Messages and AutoVacuum Attachments
scheduled actions are created by default and need to be activated.</p>
<p>Go to Settings -&gt; Technical -&gt; Automation -&gt; Scheduled Actions</p>
<ul class="simple">
<li>Activate the scheduled actions needed (AutoVacuum Mails and Messages
and/or AutoVacuum Attachments)</li>
<li>Go to Actions -&gt; Unarchive or toggle the Active status of the
scheduled action</li>
<li>Select a record and specify the frequency of the cron job if needed</li>
</ul>
<p><img alt="image3" src="https://raw.githubusercontent.com/OCA/server-tools/17.0/autovacuum_message_attachment/static/description/AutoVacuum_Cron_Jobs.png" /></p>
<p><img alt="image4" src="https://raw.githubusercontent.com/OCA/server-tools/17.0/autovacuum_message_attachment/static/description/AutoVacuum_Cron_Jobs2.png" /></p>
<p>Note: It is recommanded to run it frequently and when the system is not
very loaded. (For instance : once a day, during the night.)</p>
</div>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
<h1><a class="toc-backref" href="#toc-entry-6">Known issues / Roadmap</a></h1>
<p>You have to be careful with rules regarding attachment deletion because
Odoo find the attachment to delete with their name. Odoo will find all
attachments containing the substring configured on the rule, so you have
to be specific enough on the other criterias (concerned models…) to
avoid unwanted attachment deletion.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-7">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20autovacuum_message_attachment%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-8">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-9">Authors</a></h2>
<ul class="simple">
<li>Akretion</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-10">Contributors</a></h2>
<ul class="simple">
<li>Florian da Costa &lt;<a class="reference external" href="mailto:florian.dacosta&#64;akretion.com">florian.dacosta&#64;akretion.com</a>&gt;</li>
<li>Enric Tobella &lt;<a class="reference external" href="mailto:etobella&#64;creublanca.es">etobella&#64;creublanca.es</a>&gt;</li>
Expand All @@ -438,7 +497,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-11">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
Expand Down
23 changes: 7 additions & 16 deletions autovacuum_message_attachment/views/rule_vacuum.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name="web_ribbon"
text="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active"
/>
<field name="active" invisible="1" />
<group col="1">
Expand All @@ -20,28 +20,19 @@
<field name="company_id" />
<field name="retention_time" />
</group>
<group
col="4"
attrs="{'invisible': [('ttype', '!=', 'message')]}"
>
<field
name="message_type"
attrs="{'required': [('ttype', '=', 'message')]}"
/>
<group col="4" invisible="ttype != 'message'">
<field name="message_type" required="ttype == 'message'" />
<field name="empty_subtype" />
</group>
<group
string="Message Subtypes"
attrs="{'invisible': [('ttype', '!=', 'message')]}"
>
<group string="Message Subtypes" invisible="ttype != 'message'">
<field name="message_subtype_ids" nolabel="1" colspan="4" />
</group>
<group attrs="{'invisible': [('ttype', '!=', 'attachment')]}">
<group invisible="ttype != 'attachment'">
<field name="filename_pattern" />
<field name="inheriting_model" />
<field
name="empty_model"
attrs="{'invisible': ['|', ('model_ids', '!=', []), ('filename_pattern', '=', False)]}"
invisible="model_ids != [] or not filename_pattern"
/>
</group>
<group string="Models">
Expand All @@ -52,7 +43,7 @@
<field name="model" invisible="1" />
<field
name="model_filter_domain"
attrs="{'invisible': [('model_id', '=', False)]}"
invisible="not model_id"
widget="domain"
options="{'model': 'model'}"
/>
Expand Down

0 comments on commit 1f5f226

Please sign in to comment.