File cleanup
This commit is contained in:
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/testserver.iml" filepath="$PROJECT_DIR$/.idea/testserver.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
12
.idea/testserver.iml
generated
Normal file
12
.idea/testserver.iml
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="PyDocumentationSettings">
|
||||||
|
<option name="format" value="PLAIN" />
|
||||||
|
<option name="myDocStringFormat" value="Plain" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
68
.idea/workspace.xml
generated
Normal file
68
.idea/workspace.xml
generated
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="417d3a9a-dab7-4fec-b2a8-da7eae112104" name="Changes" comment="" />
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="EmbeddingIndexingInfo">
|
||||||
|
<option name="cachedIndexableFilesCount" value="36" />
|
||||||
|
<option name="fileBasedEmbeddingIndicesEnabled" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="McpProjectServerCommands">
|
||||||
|
<commands />
|
||||||
|
<urls />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectColorInfo"><![CDATA[{
|
||||||
|
"associatedIndex": 7,
|
||||||
|
"fromUser": false
|
||||||
|
}]]></component>
|
||||||
|
<component name="ProjectId" id="3GRtXrhb1Z1wz5HO20Plf2KjZjN" />
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
|
"keyToString": {
|
||||||
|
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
||||||
|
"RunOnceActivity.MCP Project settings loaded": "true",
|
||||||
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
|
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||||
|
"codeWithMe.voiceChat.enabledByDefault": "false",
|
||||||
|
"com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true",
|
||||||
|
"git-widget-placeholder": "19.0",
|
||||||
|
"junie.onboarding.icon.badge.shown": "true",
|
||||||
|
"last_opened_file_path": "/home/dochse/development/testserver",
|
||||||
|
"nodejs_package_manager_path": "npm",
|
||||||
|
"to.speed.mode.migration.done": "true",
|
||||||
|
"vue.rearranger.settings.migration": "true"
|
||||||
|
}
|
||||||
|
}]]></component>
|
||||||
|
<component name="SharedIndexes">
|
||||||
|
<attachedChunks>
|
||||||
|
<set>
|
||||||
|
<option value="bundled-python-sdk-50341a9f1f9c-c2ffad84badb-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-261.26222.68" />
|
||||||
|
</set>
|
||||||
|
</attachedChunks>
|
||||||
|
</component>
|
||||||
|
<component name="TaskManager">
|
||||||
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
<changelist id="417d3a9a-dab7-4fec-b2a8-da7eae112104" name="Changes" comment="" />
|
||||||
|
<created>1783946253712</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1783946253712</updated>
|
||||||
|
<workItem from="1783946254947" duration="22000" />
|
||||||
|
</task>
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
<option name="version" value="3" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import hooks
|
||||||
from . import models
|
from . import models
|
||||||
@@ -11,9 +11,10 @@
|
|||||||
'category': 'Tools',
|
'category': 'Tools',
|
||||||
'license': "AGPL-3",
|
'license': "AGPL-3",
|
||||||
'version': '19.0.1.0.0',
|
'version': '19.0.1.0.0',
|
||||||
'depends': ['mail','base','mailcatcher_menu',],
|
'depends': ['mail', 'base', 'mailcatcher_menu'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/templates.xml',
|
'views/templates.xml',
|
||||||
'data/ir_cron.xml',
|
'data/ir_cron.xml',
|
||||||
],
|
],
|
||||||
|
'post_init_hook': 'post_init_hook',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,28 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="ir_cron_set_db_parameter" model="ir.cron">
|
<data noupdate="1">
|
||||||
<field name="name">Testserver: Set Date (ONLY FOR TEST ENV.)</field>
|
<record id="ir_cron_set_db_parameter" model="ir.cron">
|
||||||
<field name="model_id" ref="base.model_ir_logging"/>
|
<field name="name">Testserver: Set Date (ONLY FOR TEST ENV.)</field>
|
||||||
<field name="state">code</field>
|
<field name="model_id" ref="base.model_ir_logging"/>
|
||||||
<field name="code">model.set_db_param()</field>
|
<field name="state">code</field>
|
||||||
<field name="interval_type">days</field>
|
<field name="code">model.set_db_param()</field>
|
||||||
</record>
|
<field name="interval_number">1</field>
|
||||||
|
<field name="interval_type">days</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="user_id" ref="base.user_root"/>
|
||||||
|
<field name="active">True</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="ir_cron_cleanup_filestore_attachments" model="ir.cron">
|
||||||
|
<field name="name">Testserver: Cleanup Unneeded Filestore</field>
|
||||||
|
<field name="model_id" ref="base.model_ir_logging"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.cleanup_unneeded_filestore_attachments(100)</field>
|
||||||
|
<field name="interval_number">15</field>
|
||||||
|
<field name="interval_type">minutes</field>
|
||||||
|
<field name="numbercall">-1</field>
|
||||||
|
<field name="user_id" ref="base.user_root"/>
|
||||||
|
<field name="active">True</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
8
testserver_o2b/hooks.py
Normal file
8
testserver_o2b/hooks.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from odoo import SUPERUSER_ID, api
|
||||||
|
|
||||||
|
|
||||||
|
def post_init_hook(cr, registry):
|
||||||
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
|
env['ir.logging'].sudo().cleanup_unneeded_filestore_attachments(limit=50)
|
||||||
@@ -21,6 +21,7 @@ class IrLogging(models.Model):
|
|||||||
EXPECTED_IP_PREFIX = '192.168.78.'
|
EXPECTED_IP_PREFIX = '192.168.78.'
|
||||||
REPORT_URL = 'http://127.0.0.1:8069'
|
REPORT_URL = 'http://127.0.0.1:8069'
|
||||||
ENTERPRISE_CODE = 'M160129258730'
|
ENTERPRISE_CODE = 'M160129258730'
|
||||||
|
FILESTORE_CLEANUP_BATCH_LIMIT = 100
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
database_uuid = str(uuid.uuid1())
|
database_uuid = str(uuid.uuid1())
|
||||||
@@ -80,6 +81,7 @@ class IrLogging(models.Model):
|
|||||||
"INSERT INTO ir_config_parameter(key, value) VALUES (%s, %s);",
|
"INSERT INTO ir_config_parameter(key, value) VALUES (%s, %s);",
|
||||||
(key, value),
|
(key, value),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _disable_web_push_notifications(self):
|
def _disable_web_push_notifications(self):
|
||||||
parameter = self.env['ir.config_parameter'].sudo()
|
parameter = self.env['ir.config_parameter'].sudo()
|
||||||
parameter.set_param('web_push.notification.enabled', '0')
|
parameter.set_param('web_push.notification.enabled', '0')
|
||||||
@@ -88,7 +90,7 @@ class IrLogging(models.Model):
|
|||||||
('key', 'in', ('mail.web_push_vapid_private_key', 'mail.web_push_vapid_public_key', 'mail.sfu_server_key'))])
|
('key', 'in', ('mail.web_push_vapid_private_key', 'mail.web_push_vapid_public_key', 'mail.sfu_server_key'))])
|
||||||
for parameter in parameters:
|
for parameter in parameters:
|
||||||
parameter.sudo().unlink()
|
parameter.sudo().unlink()
|
||||||
if self.env['ir.model'].search([('model','=','mail.partner.device')]):
|
if self.env['ir.model'].search([('model', '=', 'mail.partner.device')]):
|
||||||
self.env.cr.execute("""DELETE FROM mail_partner_device;""")
|
self.env.cr.execute("""DELETE FROM mail_partner_device;""")
|
||||||
|
|
||||||
def _model_has_field(self, model_name, field_name=None):
|
def _model_has_field(self, model_name, field_name=None):
|
||||||
@@ -163,6 +165,34 @@ class IrLogging(models.Model):
|
|||||||
if addon_path.endswith('testserver'):
|
if addon_path.endswith('testserver'):
|
||||||
_logger.error(os.system(f'./{addon_path}/testserver.sh'))
|
_logger.error(os.system(f'./{addon_path}/testserver.sh'))
|
||||||
|
|
||||||
|
def _get_unneeded_filestore_attachment_ids(self, limit):
|
||||||
|
self.env.cr.execute(
|
||||||
|
"""
|
||||||
|
SELECT id
|
||||||
|
FROM ir_attachment
|
||||||
|
WHERE type = 'binary'
|
||||||
|
AND res_field IS NULL
|
||||||
|
AND store_fname IS NOT NULL
|
||||||
|
ORDER BY COALESCE(file_size, 0) DESC, id ASC
|
||||||
|
LIMIT %s
|
||||||
|
""",
|
||||||
|
(limit,),
|
||||||
|
)
|
||||||
|
return [row[0] for row in self.env.cr.fetchall()]
|
||||||
|
|
||||||
|
def cleanup_unneeded_filestore_attachments(self, limit=FILESTORE_CLEANUP_BATCH_LIMIT):
|
||||||
|
limit = int(limit or 0)
|
||||||
|
if limit <= 0:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
attachment_ids = self._get_unneeded_filestore_attachment_ids(limit)
|
||||||
|
if not attachment_ids:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
self.env['ir.attachment'].sudo().browse(attachment_ids).unlink()
|
||||||
|
_logger.info('Deleted %s unneeded filestore attachments', len(attachment_ids))
|
||||||
|
return len(attachment_ids)
|
||||||
|
|
||||||
def set_db_param(self):
|
def set_db_param(self):
|
||||||
## Script to set database expiration date, when enterprise and test env.
|
## Script to set database expiration date, when enterprise and test env.
|
||||||
parameter = self.env['ir.config_parameter'].search(
|
parameter = self.env['ir.config_parameter'].search(
|
||||||
|
|||||||
Reference in New Issue
Block a user