MuK IT GmbH
6 years ago
12 changed files with 297 additions and 30 deletions
-
2muk_web_utils/__init__.py
-
2muk_web_utils/__manifest__.py
-
5muk_web_utils/doc/changelog.rst
-
21muk_web_utils/models/__init__.py
-
51muk_web_utils/models/res_config_settings.py
-
BINmuk_web_utils/static/src/img/module.png
-
93muk_web_utils/static/src/js/fields/module.js
-
44muk_web_utils/static/src/js/views/form/renderer.js
-
30muk_web_utils/static/src/scss/module.scss
-
34muk_web_utils/static/src/xml/module.xml
-
40muk_web_utils/static/src/xml/switch.xml
-
3muk_web_utils/template/assets.xml
@ -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 |
||||
|
|
@ -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 |
After Width: 300 | Height: 150 | Size: 4.8 KiB |
@ -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(' ').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; |
||||
|
|
||||
|
}); |
@ -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); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
}); |
@ -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; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
@ -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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue