Browse Source

publish muk_web_utils - 12.0

pull/35/head
MuK IT GmbH 6 years ago
parent
commit
73b928bfb5
  1. 2
      muk_web_utils/__init__.py
  2. 2
      muk_web_utils/__manifest__.py
  3. 5
      muk_web_utils/doc/changelog.rst
  4. 21
      muk_web_utils/models/__init__.py
  5. 51
      muk_web_utils/models/res_config_settings.py
  6. BIN
      muk_web_utils/static/src/img/module.png
  7. 93
      muk_web_utils/static/src/js/fields/module.js
  8. 44
      muk_web_utils/static/src/js/views/form/renderer.js
  9. 30
      muk_web_utils/static/src/scss/module.scss
  10. 34
      muk_web_utils/static/src/xml/module.xml
  11. 40
      muk_web_utils/static/src/xml/switch.xml
  12. 3
      muk_web_utils/template/assets.xml

2
muk_web_utils/__init__.py

@ -16,3 +16,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
from . import models

2
muk_web_utils/__manifest__.py

@ -20,7 +20,7 @@
{
"name": "MuK Web Utils",
"summary": """Utility Features""",
"version": "12.0.2.0.19",
"version": "12.0.2.1.0",
"category": "Extra Tools",
"license": "AGPL-3",
"author": "MuK IT",

5
muk_web_utils/doc/changelog.rst

@ -1,3 +1,8 @@
`2.1.0`
-------
- Automatic labels on settings
`2.0.0`
-------

21
muk_web_utils/models/__init__.py

@ -0,0 +1,21 @@
###################################################################################
#
# 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 . import res_config_settings

51
muk_web_utils/models/res_config_settings.py

@ -0,0 +1,51 @@
###################################################################################
#
# 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 re
import json
import logging
from lxml import etree
from odoo import api, fields, models
_logger = logging.getLogger(__name__)
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
#----------------------------------------------------------
# Functions
#----------------------------------------------------------
@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(
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
modules = self.env['ir.module.module'].sudo().search([]).mapped('name')
print(modules)
document = etree.XML(ret_val['arch'])
for field in ret_val['fields']:
if field.startswith("module_") and field[len("module_"):] not in modules:
for node in document.xpath("//field[@name='%s']" % field):
if node.get("widget") != 'upgrade_boolean':
node.set("widget", "module_boolean")
ret_val['arch'] = etree.tostring(document, encoding='unicode')
return ret_val

BIN
muk_web_utils/static/src/img/module.png

After

Width: 300  |  Height: 150  |  Size: 4.8 KiB

93
muk_web_utils/static/src/js/fields/module.js

@ -0,0 +1,93 @@
/**********************************************************************************
*
* 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.ModuleBoolean', function (require) {
"use strict";
var core = require('web.core');
var fields = require('web.basic_fields');
var registry = require('web.field_registry');
var framework = require('web.framework');
var Dialog = require('web.Dialog');
var AbstractField = require('web.AbstractField');
var _t = core._t;
var QWeb = core.qweb;
var ModuleBoolean = fields.FieldBoolean.extend({
supportedFieldTypes: [],
events: _.extend({}, AbstractField.prototype.events, {
'click input': '_onInputClicked',
}),
renderWithLabel: function ($label) {
this.$label = $label;
this._render();
},
_openDialog: function () {
var buttons = [{
text: _t("Download"),
classes: 'btn-primary',
close: true,
click: this._confirmRedirect.bind(this),
}, {
text: _t("Cancel"),
close: true,
}];
return new Dialog(this, {
size: 'medium',
buttons: buttons,
$content: $('<div>', {
html: $(QWeb.render('muk_web_utils.MissingModuleDialog')),
}),
title: _t("Missing Module"),
}).open();
},
_confirmRedirect: function () {
if(this.nodeOptions.url) {
framework.redirect(this.nodeOptions.url);
} else {
var module = this.name.replace("module_", "");
framework.redirect("https://apps.odoo.com/apps/modules/browse?search=" + module);
}
},
_render: function () {
this._super.apply(this, arguments);
var $element = this.$label || this.$el;
$element.append('&nbsp;').append($("<span>", {
'text': _t("Store"),
'class': "badge badge-primary oe_inline mk_module_label"
}));
},
_onInputClicked: function (event) {
if ($(event.currentTarget).prop("checked")) {
var dialog = this._openDialog();
dialog.on('closed', this, this._resetValue.bind(this));
}
},
_resetValue: function () {
this.$input.prop("checked", false).change();
},
});
registry.add('module_boolean', ModuleBoolean);
return ModuleBoolean;
});

44
muk_web_utils/static/src/js/views/form/renderer.js

@ -0,0 +1,44 @@
/**********************************************************************************
*
* 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.FormRenderer', function (require) {
"use strict";
var core = require('web.core');
var FormRenderer = require('web.FormRenderer');
var _t = core._t;
var QWeb = core.qweb;
FormRenderer.include({
_updateView: function ($newContent) {
this._super.apply(this, arguments);
_.each(this.allFieldWidgets[this.state.id], function (widget) {
if (widget.attrs.widget === 'module_boolean') {
var inputID = this.idsForLabels[widget.name];
var $widgets = this.$('.o_field_widget[name=' + widget.name + ']');
var $label = inputID ? this.$('.o_form_label[for=' + inputID + ']') : $();
widget.renderWithLabel($label.eq($widgets.index(widget.$el)));
}
}, this);
}
});
});

30
muk_web_utils/static/src/scss/module.scss

@ -0,0 +1,30 @@
/**********************************************************************************
*
* 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/>.
*
**********************************************************************************/
.o_settings_container {
.o_setting_box {
.o_setting_left_pane {
.mk_module_label {
position: absolute;
top: 0px;
right: 40px;
}
}
}
}

34
muk_web_utils/static/src/xml/module.xml

@ -0,0 +1,34 @@
<?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/>.
-->
<templates id="template" xml:space="preserve">
<t t-name="muk_web_utils.MissingModuleDialog">
<div class="row" role="status">
<div class="col-6">
<img class="img-fluid" t-att-src='_s + "/muk_web_utils/static/src/img/module.png"' alt="Missing Module" />
</div>
<div class="col-6">
<p><strong>The module could not be found on the server.</strong></p>
<p>Click on the download button to be redirected to the store and download the corresponding module.</p>
</div>
</div>
</t>
</templates>

40
muk_web_utils/static/src/xml/switch.xml

@ -1,38 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2017 MuK IT GmbH
Copyright (C) 2018 MuK IT GmbH
Odoo Proprietary License v1.0
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 software and associated files (the "Software") may only be used
(executed, modified, executed after modifications) if you have
purchased a valid license from the authors, typically via Odoo Apps,
or if you have received a written agreement from the authors of the
Software (see the COPYRIGHT file).
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 may develop Odoo modules that use the Software as a library
(typically by depending on it, importing it and using its resources),
but without copying any source code or material from the Software.
You may distribute those modules under the license of your choice,
provided that this license is compatible with the terms of the Odoo
Proprietary License (For example: LGPL, MIT, or proprietary licenses
similar to this one).
It is forbidden to publish, distribute, sublicense, or sell copies of
the Software or modified copies of the Software.
The above copyright notice and this permission notice must be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
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/>.
-->
<templates id="template" xml:space="preserve">
<t t-name="muk_web_utils.switch">

3
muk_web_utils/template/assets.xml

@ -23,8 +23,11 @@
<xpath expr="//link[last()]" position="after">
<link rel="stylesheet" type="text/scss" href="/muk_web_utils/static/src/scss/variables.scss" />
<link rel="stylesheet" type="text/scss" href="/muk_web_utils/static/src/scss/switch.scss" />
<link rel="stylesheet" type="text/scss" href="/muk_web_utils/static/src/scss/module.scss" />
</xpath>
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/muk_web_utils/static/src/js/fields/module.js"></script>
<script type="text/javascript" src="/muk_web_utils/static/src/js/views/form/renderer.js"></script>
</xpath>
</template>
Loading…
Cancel
Save