Browse Source

publish muk_web_utils - 12.0

pull/48/head
MuK IT GmbH 5 years ago
parent
commit
ba890c615a
  1. 3
      muk_web_utils/__init__.py
  2. 3
      muk_web_utils/__manifest__.py
  3. 20
      muk_web_utils/controllers/__init__.py
  4. 34
      muk_web_utils/controllers/backend.py
  5. 29
      muk_web_utils/models/res_config_settings.py
  6. 52
      muk_web_utils/static/src/js/fields/binary.js
  7. 1
      muk_web_utils/template/assets.xml
  8. 44
      muk_web_utils/views/res_config_settings_view.xml

3
muk_web_utils/__init__.py

@ -17,4 +17,5 @@
#
###################################################################################
from . import models
from . import models
from . import controllers

3
muk_web_utils/__manifest__.py

@ -20,7 +20,7 @@
{
"name": "MuK Web Utils",
"summary": """Utility Features""",
"version": "12.0.2.8.0",
"version": "12.0.2.8.1",
"category": "Extra Tools",
"license": "AGPL-3",
"author": "MuK IT",
@ -35,6 +35,7 @@
],
"data": [
"template/assets.xml",
"views/res_config_settings_view.xml",
],
"qweb": [
"static/src/xml/*.xml",

20
muk_web_utils/controllers/__init__.py

@ -0,0 +1,20 @@
###################################################################################
#
# Copyright (C) 2017 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 . import backend

34
muk_web_utils/controllers/backend.py

@ -0,0 +1,34 @@
###################################################################################
#
# Copyright (C) 2017 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/>.
#
###################################################################################
import logging
from odoo import http
from odoo.http import request
_logger = logging.getLogger(__name__)
class BackendController(http.Controller):
@http.route('/params/muk_web_utils.binary_max_size', type='json', auth="user")
def max_upload_size(self, **kw):
params = request.env['ir.config_parameter'].sudo()
return {
'max_upload_size': int(params.get_param("muk_dms.max_upload_size", default=25))
}

29
muk_web_utils/models/res_config_settings.py

@ -30,11 +30,38 @@ _logger = logging.getLogger(__name__)
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
#----------------------------------------------------------
# Database
#----------------------------------------------------------
binary_max_size = fields.Integer(
string='File Size Limit',
required=True,
default=25,
help="""Maximum allowed file size in megabytes. Note that this setting only adjusts
the binary widgets accordingly. The maximum file size on your server can probably
be restricted in several places. Note that a large file size limit and therefore
large files in your system can significantly limit performance.""")
#----------------------------------------------------------
# Functions
#----------------------------------------------------------
@api.multi
def set_values(self):
res = super(ResConfigSettings, self).set_values()
param = self.env['ir.config_parameter'].sudo()
param.set_param('muk_web_utils.binary_max_size', self.binary_max_size)
return res
@api.model
def get_values(self):
res = super(ResConfigSettings, self).get_values()
params = self.env['ir.config_parameter'].sudo()
res.update(binary_max_size=int(params.get_param('muk_web_utils.binary_max_size', 25)))
return res
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
ret_val = super(ResConfigSettings, self).fields_view_get(

52
muk_web_utils/static/src/js/fields/binary.js

@ -0,0 +1,52 @@
/**********************************************************************************
*
* Copyright (C) 2017 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.define('muk_web_utils.binary', function(require) {
"use strict";
var core = require('web.core');
var session = require('web.session');
var fields = require('web.basic_fields');
var _t = core._t;
var QWeb = core.qweb;
fields.FieldBinaryFile.include({
willStart: function () {
var def = this._rpc({
route: '/params/muk_web_utils.binary_max_size',
}).done(function(result) {
this.max_upload_size = result.max_upload_size * 1024 * 1024;
}.bind(this));
return this._super.apply(this, arguments);
},
});
fields.FieldBinaryImage.include({
willStart: function () {
var def = this._rpc({
route: '/params/muk_web_utils.binary_max_size',
}).done(function(result) {
this.max_upload_size = result.max_upload_size * 1024 * 1024;
}.bind(this));
return this._super.apply(this, arguments);
},
});
});

1
muk_web_utils/template/assets.xml

@ -44,6 +44,7 @@
<script type="text/javascript" src="/muk_web_utils/static/src/js/fields/copy.js" />
<script type="text/javascript" src="/muk_web_utils/static/src/js/fields/share.js" />
<script type="text/javascript" src="/muk_web_utils/static/src/js/fields/path.js" />
<script type="text/javascript" src="/muk_web_utils/static/src/js/fields/binary.js" />
<script type="text/javascript" src="/muk_web_utils/static/src/js/fields/module.js" />
<script type="text/javascript" src="/muk_web_utils/static/src/js/views/form/renderer.js" />
</xpath>

44
muk_web_utils/views/res_config_settings_view.xml

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2017 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>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
<field name="arch" type="xml">
<div name="storage" position="inside">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane"></div>
<div class="o_setting_right_pane">
<label for="binary_max_size"/>
<div class="text-muted">
Maximum allowed file size in MB
</div>
<div class="mt8">
<field name="binary_max_size" class="o_light_label"/>
</div>
</div>
</div>
</div>
</field>
</record>
</odoo>
Loading…
Cancel
Save