7 Commits

Author SHA1 Message Date
root
880106128a Geen publieke attachments 2026-07-15 05:25:37 +00:00
root
1a39a5a68c Cron base.autovacuum_job verwijdert de files daadwerkelijk op het systeem 2026-07-15 05:20:48 +00:00
root
fe6b724bb5 sign modellen uitsluiten geven errors en per 5000 actie werkt snel 2026-07-15 05:15:42 +00:00
1983913340 typo 2026-07-13 15:11:33 +02:00
833d5e0298 Odoo 19 syntaxing 2026-07-13 15:00:04 +02:00
bf4049382e Odoo 19 syntaxing 2026-07-13 14:58:34 +02:00
f2d4064c5e File cleanup 2026-07-13 14:52:53 +02:00
10 changed files with 171 additions and 11 deletions

View 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
View 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
View 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
View 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
View 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>

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from .hooks import post_init_hook
from . import models from . import models

View File

@@ -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',
} }

View File

@@ -1,10 +1,29 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<data noupdate="1">
<record id="ir_cron_set_db_parameter" model="ir.cron"> <record id="ir_cron_set_db_parameter" model="ir.cron">
<field name="name">Testserver: Set Date (ONLY FOR TEST ENV.)</field> <field name="name">Testserver: Set Date (ONLY FOR TEST ENV.)</field>
<field name="model_id" ref="base.model_ir_logging"/> <field name="model_id" ref="base.model_ir_logging"/>
<field name="state">code</field> <field name="state">code</field>
<field name="code">model.set_db_param()</field> <field name="code">model.set_db_param()</field>
<field name="interval_number">1</field>
<field name="interval_type">days</field> <field name="interval_type">days</field>
<field name="user_id" ref="base.user_root"/>
<field name="active">True</field>
</record> </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(5000)</field>
<field name="interval_number">15</field>
<field name="interval_type">minutes</field>
<field name="user_id" ref="base.user_root"/>
<field name="active">True</field>
</record>
<record id="base.autovacuum_job" model="ir.cron">
<field name="active">True</field>
</record>
</data>
</odoo> </odoo>

7
testserver_o2b/hooks.py Normal file
View File

@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
from odoo import api
def post_init_hook(env):
env['ir.logging'].sudo().cleanup_unneeded_filestore_attachments(limit=50)

View File

@@ -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')
@@ -163,6 +165,36 @@ 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
AND res_model not in ('sign.document','sign.request')
AND public = 'f'
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(