[IMP] autovacuum_message_attachment: pre-commit auto fixes

pull/3183/head
GabbasovDinar 2025-02-03 14:03:24 +05:00
parent a0f922d807
commit 338a478056
No known key found for this signature in database
GPG Key ID: 29C4D35381B4C360
14 changed files with 96 additions and 66 deletions

View File

@ -17,21 +17,22 @@ AutoVacuum Mail Message and Attachment
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3 :alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/16.0/autovacuum_message_attachment :target: https://github.com/OCA/server-tools/tree/17.0/autovacuum_message_attachment
:alt: OCA/server-tools :alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-autovacuum_message_attachment :target: https://translation.odoo-community.org/projects/server-tools-17-0/server-tools-17-0-autovacuum_message_attachment
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png .. |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=16.0 :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=17.0
:alt: Try me on Runboat :alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
Odoo create a lot of message and/or mails. With time it can slow the system or take a lot of disk space. Odoo create a lot of message and/or mails. With time it can slow the
The goal of this module is to clean these message once they are obsolete. system or take a lot of disk space. The goal of this module is to clean
The same may happen with attachment that we store. these message once they are obsolete. The same may happen with
You can choose various criterias manage which messages you want to delete automatically. attachment that we store. You can choose various criterias manage which
messages you want to delete automatically.
**Table of contents** **Table of contents**
@ -41,18 +42,26 @@ You can choose various criterias manage which messages you want to delete automa
Configuration Configuration
============= =============
* Go to the menu configuration => Technical => Email => Message And Attachment Vacuum Rules - Go to the menu configuration => Technical => Email => Message And
* 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. Attachment Vacuum Rules
* Activate the cron AutoVacuum Mails and Messages and/or AutoVacuum Attachments - 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. It is recommanded to run it frequently and when the system is not very
(For instance : once a day, during the night.) loaded. (For instance : once a day, during the night.)
Known issues / Roadmap Known issues / Roadmap
====================== ======================
You have to be careful with rules regarding attachment deletion because Odoo find the attachment to delete with their name. You have to be careful with rules regarding attachment deletion because
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. 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.
Bug Tracker Bug Tracker
=========== ===========
@ -60,7 +69,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_. 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. 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 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:%20autovacuum_message_attachment%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <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**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -68,20 +77,20 @@ Credits
======= =======
Authors Authors
~~~~~~~ -------
* Akretion * Akretion
Contributors Contributors
~~~~~~~~~~~~ ------------
* Florian da Costa <florian.dacosta@akretion.com> - Florian da Costa <florian.dacosta@akretion.com>
* Enric Tobella <etobella@creublanca.es> - Enric Tobella <etobella@creublanca.es>
* Helly kapatel <helly.kapatel@initos.com> - Helly kapatel <helly.kapatel@initos.com>
* Akim Juillerat <akim.juillerat@camptocamp.com> - Akim Juillerat <akim.juillerat@camptocamp.com>
Maintainers Maintainers
~~~~~~~~~~~ -----------
This module is maintained by the OCA. This module is maintained by the OCA.
@ -101,6 +110,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-florian-dacosta| |maintainer-florian-dacosta|
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/16.0/autovacuum_message_attachment>`_ project on GitHub. This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/17.0/autovacuum_message_attachment>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -3,7 +3,7 @@
{ {
"name": "AutoVacuum Mail Message and Attachment", "name": "AutoVacuum Mail Message and Attachment",
"version": "16.0.1.0.1", "version": "17.0.1.0.1",
"category": "Tools", "category": "Tools",
"website": "https://github.com/OCA/server-tools", "website": "https://github.com/OCA/server-tools",
"author": "Akretion, Odoo Community Association (OCA)", "author": "Akretion, Odoo Community Association (OCA)",

View File

@ -29,9 +29,7 @@ class AutovacuumMixin(models.AbstractModel):
batch_delete.with_env(new_env).unlink() batch_delete.with_env(new_env).unlink()
new_env.cr.commit() new_env.cr.commit()
except Exception as e: except Exception as e:
_logger.exception( _logger.exception(f"Failed to delete Ms : {self._name} - {str(e)}")
"Failed to delete Ms : {} - {}".format(self._name, str(e))
)
# Call by cron # Call by cron
@api.model @api.model
@ -56,12 +54,10 @@ class AutovacuumMixin(models.AbstractModel):
) )
autovacuum_relation = self._autovacuum_relation autovacuum_relation = self._autovacuum_relation
for leaf in domain: for leaf in domain:
if not isinstance(leaf, (tuple, list)): if not isinstance(leaf, (tuple | list)):
record_domain.append(leaf) record_domain.append(leaf)
continue continue
field, operator, value = leaf field, operator, value = leaf
record_domain.append( record_domain.append((f"{autovacuum_relation}.{field}", operator, value))
("{}.{}".format(autovacuum_relation, field), operator, value)
)
records = self.env[rule.model_id.model].search(record_domain) records = self.env[rule.model_id.model].search(record_domain)
return self.search(domain + [("res_id", "in", records.ids)]) return self.search(domain + [("res_id", "in", records.ids)])

View File

@ -98,7 +98,8 @@ class VacuumRule(models.Model):
if rule.ttype != "attachment": if rule.ttype != "attachment":
raise exceptions.ValidationError( raise exceptions.ValidationError(
_( _(
"Inheriting model cannot be used on rule where type is not attachment" "Inheriting model cannot be used on rule where "
"type is not attachment"
) )
) )
if ( if (

View File

@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

@ -0,0 +1,11 @@
- 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.)

View File

@ -1,6 +0,0 @@
* 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.)

View File

@ -0,0 +1,4 @@
- Florian da Costa \<florian.dacosta@akretion.com\>
- Enric Tobella \<etobella@creublanca.es\>
- Helly kapatel \<helly.kapatel@initos.com\>
- Akim Juillerat \<akim.juillerat@camptocamp.com\>

View File

@ -1,4 +0,0 @@
* Florian da Costa <florian.dacosta@akretion.com>
* Enric Tobella <etobella@creublanca.es>
* Helly kapatel <helly.kapatel@initos.com>
* Akim Juillerat <akim.juillerat@camptocamp.com>

View File

@ -0,0 +1,5 @@
Odoo create a lot of message and/or mails. With time it can slow the
system or take a lot of disk space. The goal of this module is to clean
these message once they are obsolete. The same may happen with
attachment that we store. You can choose various criterias manage which
messages you want to delete automatically.

View File

@ -1,4 +0,0 @@
Odoo create a lot of message and/or mails. With time it can slow the system or take a lot of disk space.
The goal of this module is to clean these message once they are obsolete.
The same may happen with attachment that we store.
You can choose various criterias manage which messages you want to delete automatically.

View File

@ -0,0 +1,5 @@
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.

View File

@ -1,2 +0,0 @@
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.

View File

@ -8,10 +8,11 @@
/* /*
:Author: David Goodger (goodger@python.org) :Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ :Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain. :Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils. Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet. customize this style sheet.
@ -274,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ; margin-left: 2em ;
margin-right: 2em } margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */ pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee } pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 } pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@ -300,7 +301,7 @@ span.option {
span.pre { span.pre {
white-space: pre } white-space: pre }
span.problematic { span.problematic, pre.problematic {
color: red } color: red }
span.section-subtitle { span.section-subtitle {
@ -368,11 +369,12 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:491db966d4262d620005377d57d6255ffa65095cbcc96229a46efad5d6dec593 !! source digest: sha256:491db966d4262d620005377d57d6255ffa65095cbcc96229a46efad5d6dec593
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-tools/tree/16.0/autovacuum_message_attachment"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-autovacuum_message_attachment"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-tools&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p> <p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-tools/tree/17.0/autovacuum_message_attachment"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-tools-17-0/server-tools-17-0-autovacuum_message_attachment"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-tools&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Odoo create a lot of message and/or mails. With time it can slow the system or take a lot of disk space. <p>Odoo create a lot of message and/or mails. With time it can slow the
The goal of this module is to clean these message once they are obsolete. system or take a lot of disk space. The goal of this module is to clean
The same may happen with attachment that we store. these message once they are obsolete. The same may happen with
You can choose various criterias manage which messages you want to delete automatically.</p> attachment that we store. You can choose various criterias manage which
messages you want to delete automatically.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
<ul class="simple"> <ul class="simple">
@ -390,24 +392,32 @@ You can choose various criterias manage which messages you want to delete automa
<div class="section" id="configuration"> <div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1> <h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<ul class="simple"> <ul class="simple">
<li>Go to the menu configuration =&gt; Technical =&gt; Email =&gt; Message And Attachment Vacuum Rules</li> <li>Go to the menu configuration =&gt; Technical =&gt; Email =&gt; Message And
<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> Attachment Vacuum Rules</li>
<li>Activate the cron AutoVacuum Mails and Messages and/or AutoVacuum Attachments</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>
</ul> </ul>
<p>It is recommanded to run it frequently and when the system is not very loaded. <p>It is recommanded to run it frequently and when the system is not very
(For instance : once a day, during the night.)</p> loaded. (For instance : once a day, during the night.)</p>
</div> </div>
<div class="section" id="known-issues-roadmap"> <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-2">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. <p>You have to be careful with rules regarding attachment deletion because
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> 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>
<div class="section" id="bug-tracker"> <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-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>. <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. 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 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:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -430,13 +440,15 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<div class="section" id="maintainers"> <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-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p> <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" /></a> <a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p> <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/florian-dacosta"><img alt="florian-dacosta" src="https://github.com/florian-dacosta.png?size=40px" /></a></p> <p><a class="reference external image-reference" href="https://github.com/florian-dacosta"><img alt="florian-dacosta" src="https://github.com/florian-dacosta.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/16.0/autovacuum_message_attachment">OCA/server-tools</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/17.0/autovacuum_message_attachment">OCA/server-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>