From 73b928bfb52afaf074f84f3c15a6b9fead40e77b Mon Sep 17 00:00:00 2001 From: MuK IT GmbH Date: Sat, 20 Oct 2018 00:08:41 +0000 Subject: [PATCH] publish muk_web_utils - 12.0 --- muk_web_utils/__init__.py | 2 + muk_web_utils/__manifest__.py | 2 +- muk_web_utils/doc/changelog.rst | 5 + muk_web_utils/models/__init__.py | 21 ++++ muk_web_utils/models/res_config_settings.py | 51 ++++++++++ muk_web_utils/static/src/img/module.png | Bin 0 -> 4921 bytes muk_web_utils/static/src/js/fields/module.js | 93 ++++++++++++++++++ .../static/src/js/views/form/renderer.js | 44 +++++++++ muk_web_utils/static/src/scss/module.scss | 30 ++++++ muk_web_utils/static/src/xml/module.xml | 34 +++++++ muk_web_utils/static/src/xml/switch.xml | 42 +++----- muk_web_utils/template/assets.xml | 3 + 12 files changed, 297 insertions(+), 30 deletions(-) create mode 100644 muk_web_utils/models/__init__.py create mode 100644 muk_web_utils/models/res_config_settings.py create mode 100644 muk_web_utils/static/src/img/module.png create mode 100644 muk_web_utils/static/src/js/fields/module.js create mode 100644 muk_web_utils/static/src/js/views/form/renderer.js create mode 100644 muk_web_utils/static/src/scss/module.scss create mode 100644 muk_web_utils/static/src/xml/module.xml diff --git a/muk_web_utils/__init__.py b/muk_web_utils/__init__.py index 9bc0a69..3a0a7c9 100644 --- a/muk_web_utils/__init__.py +++ b/muk_web_utils/__init__.py @@ -16,3 +16,5 @@ # along with this program. If not, see . # ################################################################################### + +from . import models \ No newline at end of file diff --git a/muk_web_utils/__manifest__.py b/muk_web_utils/__manifest__.py index fc55344..2fd0830 100644 --- a/muk_web_utils/__manifest__.py +++ b/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", diff --git a/muk_web_utils/doc/changelog.rst b/muk_web_utils/doc/changelog.rst index f2ae21c..c659e2d 100644 --- a/muk_web_utils/doc/changelog.rst +++ b/muk_web_utils/doc/changelog.rst @@ -1,3 +1,8 @@ +`2.1.0` +------- + +- Automatic labels on settings + `2.0.0` ------- diff --git a/muk_web_utils/models/__init__.py b/muk_web_utils/models/__init__.py new file mode 100644 index 0000000..af61df3 --- /dev/null +++ b/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 . +# +################################################################################### + +from . import res_config_settings + diff --git a/muk_web_utils/models/res_config_settings.py b/muk_web_utils/models/res_config_settings.py new file mode 100644 index 0000000..f42a83b --- /dev/null +++ b/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 . +# +################################################################################### + +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 \ No newline at end of file diff --git a/muk_web_utils/static/src/img/module.png b/muk_web_utils/static/src/img/module.png new file mode 100644 index 0000000000000000000000000000000000000000..74ca4c7e2846629e520458daa42e4049c40ae41a GIT binary patch literal 4921 zcmeHL`9DsYEv6hm-bg*;xz0=cgG)r~~dkz@XN#V_8CmL}l zmu%%BOXK9G^X)g~gH+Y$GSgID4v`gk(P?|me}8E;XQf?qi9dDA3}Dd?O+0r>7iEg( zVbO-1(+2pB0r)HJySxBZw;w|~$4h_${2Kp zynXi4!ops~ExEJdoJk&TyQNV=4QOo^aZOPX5fSe+&Av|(k9dkvWD`^ej~;KVk9?k& zxuv$DG;5l%Ga{Q>CT3W-sW+jGmbCu0}3w1#n->!^Ca4kIAm^94Itc6 zlAOF|D1cV-oSlZ+;8fIsxU&FQfT&z4&dIx00ubQ1fGy6AtN(5f1y|A?6|9>dUrFf{ zIpn4~h ze3ZfRdyzRYF|p#aIl<5Q&s#I#-Y#84)bp5!glO5;-48{FoVUft-QhwJLN6*P=v=&r z_v`|&cxQkLAe81#3D`D2&hq&7j$FV%D3r3PvS)nQ;KeJ6Q2ON)Sf-n+-QVADs0d&U zD_KhCjsSoVwnVD#7Lx4Ik7A7rDD4Z3Z&anPNk3>1APkl{9-1D< zL9qC4owAOa@LO`naITwB(0JD>n=0M)rbgp4Fr4d>CBRDSyIXrVV$xLvX5^&KRuqo6 z`>$qJ*C33<4mgfXic~6%!TTGMoJFT4I-D!p)?9a>)KLsu?8<`}P{gc`9AH#??850b zCZpOp3BH6J?vi(x61a%z>;M8V>QeoPF$ZXUZVX4l7VDy~!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oHMw)Jjc{>Z^As#+1dH`moHzMPtHTYoT>R;#w3OUx0FbF zC5enb%6hV9lUj_t38Y=`%EWIsme0e8*lPTsXUEKjjt5?SIr{#nBN;uK+&Oatg8eQ{ zkj@ovABMVpdVYFy$i}lbUCC`0Kdn+wl7T--MUe+Q3zI_t>TDo0t>l3x6ib9q_A704 zEZJ!+C|moEqw3oJ*|d>(+;uF#Uli`g#)wk_hE~QK7B(09eOIsE6W)TG`UyaBUHy7E zL;qBy24wMD&}!kI-#f?^TV1;|s`q~YwsmHQbSPMhu;@boN(42VFrz_Y_7*`$Dd2Bk z{u(4iXQV=Z@;#%@!dOk2|A;ui?|f~Dd9690Akbz4$ z+Cg?3Peu!M%y`=?ll=Q1Vbz2>sr9Q(zvt-!_NBp}r@K_X7xZWyW=^ix#jjyo`^ets zsbEnvUp;I`5qz~zs6MsWcIIoHS3b{^p4Q1JC*!Q4&y|k!n4E`xe#iBt)dS^;oVwlJ z-GAqP4pJmb)W^d%*;BhjA8qy`7eEevbuE@3)3W~UePhs0-&3Bm&*G{sw19fLh0?Ds zICT=aLWC`b=?eV|Rk!8(X?=rBq&5Y$7RQ{XKiglc99km-#FY2I>f`QQcUIf?=1X1> zEQD;wiWt0bu=v47TrrK!#Msz>&k06FtG_qa%%@qu^H*pDlSPWT<<=J1fAsg8YMD$; zId}KKs8GdxG1{ab+i_71eXt)bOiJPk+?z?2&gr2H3DQuQ?xO=Hr6<IeJ&awP!gW$(dSil~_<&1ss{rhXHy3yhzwdL+~MSYM{ts1r5o*Va$D5P#Yj3N z=SK04OkSldHtO zK={xquB)OMz}e6;I2su}jnqB|z|njF6`gWb6I@ow0yx)HVMs2(YlZ. +* +**********************************************************************************/ + +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: $('
', { + 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($("", { + '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; + +}); \ No newline at end of file diff --git a/muk_web_utils/static/src/js/views/form/renderer.js b/muk_web_utils/static/src/js/views/form/renderer.js new file mode 100644 index 0000000..7236c80 --- /dev/null +++ b/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 . +* +**********************************************************************************/ + +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); + } +}); + +}); \ No newline at end of file diff --git a/muk_web_utils/static/src/scss/module.scss b/muk_web_utils/static/src/scss/module.scss new file mode 100644 index 0000000..cde97f4 --- /dev/null +++ b/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 . +* +**********************************************************************************/ + +.o_settings_container { + .o_setting_box { + .o_setting_left_pane { + .mk_module_label { + position: absolute; + top: 0px; + right: 40px; + } + } + } +} \ No newline at end of file diff --git a/muk_web_utils/static/src/xml/module.xml b/muk_web_utils/static/src/xml/module.xml new file mode 100644 index 0000000..b163902 --- /dev/null +++ b/muk_web_utils/static/src/xml/module.xml @@ -0,0 +1,34 @@ + + + + + + + +
+
+ Missing Module +
+
+

The module could not be found on the server.

+

Click on the download button to be redirected to the store and download the corresponding module.

+
+
+
+ +
\ No newline at end of file diff --git a/muk_web_utils/static/src/xml/switch.xml b/muk_web_utils/static/src/xml/switch.xml index 67e7054..1341ab2 100644 --- a/muk_web_utils/static/src/xml/switch.xml +++ b/muk_web_utils/static/src/xml/switch.xml @@ -1,38 +1,22 @@ + diff --git a/muk_web_utils/template/assets.xml b/muk_web_utils/template/assets.xml index a1a16b6..09d7c71 100644 --- a/muk_web_utils/template/assets.xml +++ b/muk_web_utils/template/assets.xml @@ -23,8 +23,11 @@ + + +