Browse Source

Migrate autovacuum_mail_message to version 12 and rename it

12.0-mig-module_prototyper_last
Florian da Costa 5 years ago
parent
commit
1a59591ec9
  1. 0
      autovacuum_message_attachment/README.rst
  2. 0
      autovacuum_message_attachment/__init__.py
  3. 6
      autovacuum_message_attachment/__manifest__.py
  4. 6
      autovacuum_message_attachment/data/data.xml
  5. 0
      autovacuum_message_attachment/i18n/autovacuum_mail_message.pot
  6. 0
      autovacuum_message_attachment/i18n/fr.po
  7. 0
      autovacuum_message_attachment/models/__init__.py
  8. 7
      autovacuum_message_attachment/models/mail_message.py
  9. 9
      autovacuum_message_attachment/models/message_vacuum_rule.py
  10. 6
      autovacuum_message_attachment/readme/CONFIGURE.rst
  11. 1
      autovacuum_message_attachment/readme/CONTRIBUTORS.rst
  12. 3
      autovacuum_message_attachment/readme/DESCRIPTION.rst
  13. 0
      autovacuum_message_attachment/security/ir.model.access.csv
  14. 0
      autovacuum_message_attachment/static/description/icon.png
  15. 1
      autovacuum_message_attachment/tests/__init__.py
  16. 12
      autovacuum_message_attachment/tests/test_message_vacuum_rule.py
  17. 2
      autovacuum_message_attachment/views/message_rule_vacuum.xml

0
autovacuum_mail_message/README.rst → autovacuum_message_attachment/README.rst

0
autovacuum_mail_message/__init__.py → autovacuum_message_attachment/__init__.py

6
autovacuum_mail_message/__openerp__.py → autovacuum_message_attachment/__manifest__.py

@ -1,17 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2018 Akretion # Copyright (C) 2018 Akretion
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{ {
"name": "AutoVacuum Mail Message", "name": "AutoVacuum Mail Message",
"version": "9.0.1.1.0",
"version": "12.0.1.0.0",
"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)",
"license": "LGPL-3", "license": "LGPL-3",
"installable": True, "installable": True,
"application": False,
"summary": "Automatic Delete old mail message to clean database",
"summary": "Automatically delete old mail messages to clean database",
"depends": [ "depends": [
"mail", "mail",
], ],

6
autovacuum_mail_message/data/data.xml → autovacuum_message_attachment/data/data.xml

@ -9,10 +9,10 @@
<field name="interval_number">1</field> <field name="interval_number">1</field>
<field name="interval_type">days</field> <field name="interval_type">days</field>
<field name="numbercall">-1</field> <field name="numbercall">-1</field>
<field name="state">code</field>
<field name="code">model.autovacuum_mail_message()</field>
<field eval="False" name="doall"/> <field eval="False" name="doall"/>
<field eval="'mail.message'" name="model"/>
<field eval="'autovacuum_mail_message'" name="function"/>
<field eval="'()'" name="args"/>
<field name="model_id" ref="mail.model_mail_message"/>
</record> </record>
</odoo> </odoo>

0
autovacuum_mail_message/i18n/autovacuum_mail_message.pot → autovacuum_message_attachment/i18n/autovacuum_mail_message.pot

0
autovacuum_mail_message/i18n/fr.po → autovacuum_message_attachment/i18n/fr.po

0
autovacuum_mail_message/models/__init__.py → autovacuum_message_attachment/models/__init__.py

7
autovacuum_mail_message/models/mail_message.py → autovacuum_message_attachment/models/mail_message.py

@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2018 Akretion # Copyright (C) 2018 Akretion
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
import logging import logging
import openerp
from openerp import api, models
import odoo
from odoo import api, models
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@ -16,7 +15,7 @@ class MailMessage(models.Model):
@api.multi @api.multi
def batch_unlink(self): def batch_unlink(self):
with api.Environment.manage(): with api.Environment.manage():
with openerp.registry(
with odoo.registry(
self.env.cr.dbname).cursor() as new_cr: self.env.cr.dbname).cursor() as new_cr:
new_env = api.Environment(new_cr, self.env.uid, new_env = api.Environment(new_cr, self.env.uid,
self.env.context) self.env.context)

9
autovacuum_mail_message/models/message_vacuum_rule.py → autovacuum_message_attachment/models/message_vacuum_rule.py

@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2018 Akretion # Copyright (C) 2018 Akretion
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from datetime import date, timedelta from datetime import date, timedelta
from openerp import _, api, exceptions, fields, models
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
from openerp.tools.safe_eval import safe_eval
from odoo import _, api, exceptions, fields, models
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
from odoo.tools.safe_eval import safe_eval
import datetime import datetime
@ -56,7 +55,7 @@ class MessageVacuumRule(models.Model):
help="Number of days the messages concerned by this rule will be " help="Number of days the messages concerned by this rule will be "
"keeped in the database after creation. Once the delay is " "keeped in the database after creation. Once the delay is "
"passed, they will be automatically deleted.") "passed, they will be automatically deleted.")
active = fields.Boolean()
active = fields.Boolean(default=True)
description = fields.Text() description = fields.Text()
@api.multi @api.multi

6
autovacuum_message_attachment/readme/CONFIGURE.rst

@ -0,0 +1,6 @@
* Go to the menu configuration => Technical => Email => Message 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).
* Activate the cron AutoVacuum Mails and Messages
It is recommanded to run it frequently and when the system is not very loaded.
(For instance : once a day, during the night.)

1
autovacuum_message_attachment/readme/CONTRIBUTORS.rst

@ -0,0 +1 @@
* Florian da Costa <florian.dacosta@akretion.com>

3
autovacuum_message_attachment/readme/DESCRIPTION.rst

@ -0,0 +1,3 @@
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.
You can choose various criterias manage which messages you want to delete automatically.

0
autovacuum_mail_message/security/ir.model.access.csv → autovacuum_message_attachment/security/ir.model.access.csv

0
autovacuum_mail_message/static/description/icon.png → autovacuum_message_attachment/static/description/icon.png

Before

Width: 128  |  Height: 128  |  Size: 9.2 KiB

After

Width: 128  |  Height: 128  |  Size: 9.2 KiB

1
autovacuum_mail_message/tests/__init__.py → autovacuum_message_attachment/tests/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2018 Akretion (Florian da Costa) # © 2018 Akretion (Florian da Costa)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

12
autovacuum_mail_message/tests/test_message_vacuum_rule.py → autovacuum_message_attachment/tests/test_message_vacuum_rule.py

@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-
# © 2018 Akretion (Florian da Costa) # © 2018 Akretion (Florian da Costa)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import date, timedelta from datetime import date, timedelta
from openerp import api, exceptions
from openerp.tests import common
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
from odoo import api, exceptions
from odoo.tests import common
class TestMessageVacuumRule(common.TransactionCase): class TestMessageVacuumRule(common.TransactionCase):
@ -29,16 +27,14 @@ class TestMessageVacuumRule(common.TransactionCase):
def setUp(self): def setUp(self):
super(TestMessageVacuumRule, self).setUp() super(TestMessageVacuumRule, self).setUp()
self.registry.enter_test_mode()
self.registry.enter_test_mode(self.env.cr)
self.env = api.Environment(self.registry.test_cr, self.env.uid, self.env = api.Environment(self.registry.test_cr, self.env.uid,
self.env.context) self.env.context)
self.subtype = self.env.ref('mail.mt_comment') self.subtype = self.env.ref('mail.mt_comment')
self.message_obj = self.env['mail.message'] self.message_obj = self.env['mail.message']
self.channel_model = self.env.ref('mail.model_mail_channel') self.channel_model = self.env.ref('mail.model_mail_channel')
today = date.today() today = date.today()
before_400_days = today - timedelta(days=400)
self.before_400_days = before_400_days.strftime(
DEFAULT_SERVER_DATE_FORMAT)
self.before_400_days = today - timedelta(days=400)
def test_mail_vacuum_rules(self): def test_mail_vacuum_rules(self):
rule_vals = { rule_vals = {

2
autovacuum_mail_message/views/message_rule_vacuum.xml → autovacuum_message_attachment/views/message_rule_vacuum.xml

@ -46,7 +46,7 @@
</record> </record>
<record model="ir.actions.act_window" id="action_message_vacuum_rule"> <record model="ir.actions.act_window" id="action_message_vacuum_rule">
<field name="name">Message Vacuum Rule</field>
<field name="name">Message Vacuum Rules</field>
<field name="res_model">message.vacuum.rule</field> <field name="res_model">message.vacuum.rule</field>
<field name="view_type">form</field> <field name="view_type">form</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
Loading…
Cancel
Save