Browse Source

update

pull/6/head
Mathias Markl 7 years ago
parent
commit
e4fafa4861
  1. 4
      muk_converter/__manifest__.py
  2. 32
      muk_converter/data/autovacuum.xml
  3. 3
      muk_converter/models/__init__.py
  4. 29
      muk_converter/models/ir_autovacuum.py
  5. 8
      muk_converter/models/store.py

4
muk_converter/__manifest__.py

@ -20,7 +20,7 @@
{
"name": "MuK Converter",
"summary": """Universal Converter""",
"version": '11.0.1.1.4',
"version": '11.0.1.1.5',
"category": 'Extra Tools',
"license": "AGPL-3",
"website": "https://www.mukit.at",
@ -31,12 +31,14 @@
],
"depends": [
"muk_utils",
"muk_autovacuum",
"muk_fields_lobject",
],
"data": [
"security/ir.model.access.csv",
"views/convert.xml",
"data/params.xml",
"data/autovacuum.xml",
],
"qweb": [
"static/src/xml/*.xml",

32
muk_converter/data/autovacuum.xml

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2018 MuK IT GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<odoo noupdate="1">
<record id="converter_store_autovacuum_rule" model="muk_autovacuum.rules">
<field name="name">Delete all converted files that exceed the store size</field>
<field name="state">size</field>
<field name="model" ref="model_muk_converter_store"/>
<field name="size_type">parameter</field>
<field name="size_parameter" ref="muk_converter.muk_converter_max_store"/>
<field name="size_order">used_date desc</field>
<field name="protect_starred" eval="False"/>
</record>
</odoo>

3
muk_converter/models/__init__.py

@ -18,5 +18,4 @@
###################################################################################
from . import converter
from . import store
from . import ir_autovacuum
from . import store

29
muk_converter/models/ir_autovacuum.py

@ -1,29 +0,0 @@
###################################################################################
#
# Copyright (C) 2018 MuK IT GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
from odoo import api, models
class AutoVacuum(models.AbstractModel):
_inherit = 'ir.autovacuum'
@api.model
def power_on(self, *args, **kwargs):
self.env['muk_converter.store'].garbage_collector()
return super(AutoVacuum, self).power_on(*args, **kwargs)

8
muk_converter/models/store.py

@ -59,11 +59,3 @@ class Store(models.Model):
def _compute_name(self):
for record in self:
record.name = "%s (%s)" % (record.content_fname, record.checksum)
@api.model
def garbage_collector(self):
param = self.env['ir.config_parameter'].sudo()
max_store = param.get_param("muk_converter.max_store", default=20)
records = self.search([], order='used_date asc')
if len(records) > int(max_store):
records[max_store:].unlink()
Loading…
Cancel
Save