diff --git a/setup/support_branding/odoo/__init__.py b/setup/support_branding/odoo/__init__.py deleted file mode 100644 index de40ea7ca..000000000 --- a/setup/support_branding/odoo/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__('pkg_resources').declare_namespace(__name__) diff --git a/setup/support_branding/odoo/addons/__init__.py b/setup/support_branding/odoo/addons/__init__.py deleted file mode 100644 index de40ea7ca..000000000 --- a/setup/support_branding/odoo/addons/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__('pkg_resources').declare_namespace(__name__) diff --git a/support_branding/README.rst b/support_branding/README.rst index 588c3523f..18faf9ab0 100644 --- a/support_branding/README.rst +++ b/support_branding/README.rst @@ -1,92 +1,80 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License: AGPL-3 - -Support branding ================ +Support Branding +================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/14.0/support_branding + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-14-0/web-14-0-support_branding + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/162/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| If you run an Odoo support company and you support customers without an OPW, you can brand the Odoo instance accordingly using this module. This module will -add a line `Supported by $yourcompany` in the menu footer and add a button to -mail exception messages to your support email address. +add a support company url to profile menu under, `Support`. Moreover, +it will add a button to mail exception messages to your support email address. +**Table of contents** -Configuration -============= - -This module is controlled by config parameters: - -support_branding.company_name - Your company's name - -support_branding.company_url - Your company's website - -support_branding.company_color - The color to show your company's name in (CSS syntax) - -support_branding.support_email - The (optional) mailaddress to contact for support - -support_branding.release - The (optional) version number of your deployment - -You probably want to depend on this module in your customer specific module and -add the following XML:: - - - Your company - - - https://yourwebsite.com - - - #000 - - - support@yourwebsite.com - - - 42 - Configuration - -Note that the email button is only visible if you configure an email address, -the default is empty! +.. contents:: + :local: Bug Tracker =========== Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback -`here `_. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Therp BV +* Sunflower IT + Contributors ------------- +~~~~~~~~~~~~ * Holger Brunn * Stefan Rijnhart * Robert Rottermann +* Kevin Kamau -Icon ----- +Maintainers +~~~~~~~~~~~ -* https://commons.wikimedia.org/wiki/File:Crystal_Clear_app_khelpcenter.png - -Maintainer ----------- +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/support_branding/__init__.py b/support_branding/__init__.py index e69de29bb..9416c2a04 100644 --- a/support_branding/__init__.py +++ b/support_branding/__init__.py @@ -0,0 +1,7 @@ +# Copyright 2012-2015 Therp BV () +# Copyright 2016 - Tecnativa - Angel Moya +# Copyright 2017 - redO2oo - Robert Rottermann +# Copyright 2021 Sunflower IT +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/support_branding/__manifest__.py b/support_branding/__manifest__.py index 341ea4a44..94c4d76b4 100644 --- a/support_branding/__manifest__.py +++ b/support_branding/__manifest__.py @@ -1,25 +1,24 @@ # Copyright 2012-2015 Therp BV () # Copyright 2016 - Tecnativa - Angel Moya # Copyright 2017 - redO2oo - Robert Rottermann +# Copyright 2021 Sunflower IT () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - "name": "Support branding", + "name": "Support Branding", "summary": "Adds your branding to an Odoo instance", - "category": "Dependecy/Hidden", - "version": "10.0.1.0.0", + "category": "Hidden/Tools", + "version": "14.0.1.0.0", "license": "AGPL-3", - "author": "Therp BV,Odoo Community Association (OCA)", + "author": "Therp BV,Sunflower IT,Odoo Community Association (OCA)", "website": "https://github.com/OCA/web", - "depends": [ - "web", - ], + "depends": ["web", "base_setup"], "qweb": [ "static/src/xml/base.xml", ], - "data": [ - "data/ir_config_parameter.xml", - "views/qweb.xml", + "data": ["views/asset.xml", "views/res_config_settings.xml"], + "demo": [ + "demo/ir_config_parameter_data.xml", ], "installable": True, } diff --git a/support_branding/data/ir_config_parameter.xml b/support_branding/data/ir_config_parameter.xml deleted file mode 100644 index 73bd8bf35..000000000 --- a/support_branding/data/ir_config_parameter.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - support_branding.company_name - Odoo Community Association (OCA) - - - support_branding.company_url - https://odoo-community.org - - - support_branding.company_color - #b163a3 - - - support_branding.support_email - - - - support_branding.release - - - - diff --git a/support_branding/demo/ir_config_parameter_data.xml b/support_branding/demo/ir_config_parameter_data.xml new file mode 100644 index 000000000..df026f89d --- /dev/null +++ b/support_branding/demo/ir_config_parameter_data.xml @@ -0,0 +1,25 @@ + + + + + support_company + Sunflower IT + + + support_company_url + https://www.sunflowerweb.nl + + + support_branding_color + #fff + + + support_email + info@sunflowerweb.nl + + + support_release + 14.0 + + + diff --git a/support_branding/models/__init__.py b/support_branding/models/__init__.py new file mode 100644 index 000000000..4124bd743 --- /dev/null +++ b/support_branding/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2021 Sunflower IT +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import res_config_settings diff --git a/support_branding/models/res_config_settings.py b/support_branding/models/res_config_settings.py new file mode 100644 index 000000000..a07ecccea --- /dev/null +++ b/support_branding/models/res_config_settings.py @@ -0,0 +1,36 @@ +# Copyright 2021 Sunflower IT +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + def get_values(self): + res = super(ResConfigSettings, self).get_values() + param_obj = self.env["ir.config_parameter"].sudo() + res.update( + support_company=param_obj.get_param("support_company"), + support_company_url=param_obj.get_param("support_company_url"), + support_email=param_obj.get_param("support_email"), + support_release=param_obj.get_param("support_release"), + support_branding_color=param_obj.get_param("support_branding_color"), + ) + return res + + def set_values(self): + res = super(ResConfigSettings, self).set_values() + param_obj = self.env["ir.config_parameter"].sudo() + param_obj.set_param("support_company", self.support_company) + param_obj.set_param("support_company_url", self.support_company_url) + param_obj.set_param("support_email", self.support_email) + param_obj.set_param("support_release", self.support_release) + param_obj.set_param("support_branding_color", self.support_branding_color) + return res + + support_company = fields.Char(string="Company Name") + support_company_url = fields.Char(string="Company URL") + support_branding_color = fields.Char(string="Branding color") + support_email = fields.Char(string="Support email") + support_release = fields.Char(string="Support release") diff --git a/support_branding/readme/CONTRIBUTORS.rst b/support_branding/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..697abcab5 --- /dev/null +++ b/support_branding/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Holger Brunn +* Stefan Rijnhart +* Robert Rottermann +* Kevin Kamau diff --git a/support_branding/readme/DESCRIPTION.rst b/support_branding/readme/DESCRIPTION.rst new file mode 100644 index 000000000..1191583f6 --- /dev/null +++ b/support_branding/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +If you run an Odoo support company and you support customers without an OPW, +you can brand the Odoo instance accordingly using this module. This module will +add a support company url to profile menu under, `Support`. Moreover, +it will add a button to mail exception messages to your support email address. diff --git a/support_branding/static/description/icon.png b/support_branding/static/description/icon.png index f181838db..3a0328b51 100644 Binary files a/support_branding/static/description/icon.png and b/support_branding/static/description/icon.png differ diff --git a/support_branding/static/description/index.html b/support_branding/static/description/index.html new file mode 100644 index 000000000..def712433 --- /dev/null +++ b/support_branding/static/description/index.html @@ -0,0 +1,426 @@ + + + + + + +Support Branding + + + +
+

Support Branding

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

If you run an Odoo support company and you support customers without an OPW, +you can brand the Odoo instance accordingly using this module. This module will +add a support company url to profile menu under, Support. Moreover, +it will add a button to mail exception messages to your support email address.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Therp BV
  • +
  • Sunflower IT
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/support_branding/static/src/css/support_branding.css b/support_branding/static/src/css/support_branding.css index 21b25d33d..68a68a8e5 100644 --- a/support_branding/static/src/css/support_branding.css +++ b/support_branding/static/src/css/support_branding.css @@ -2,3 +2,7 @@ display: inline; margin: 0px; } + +.support-statement { + margin: 10px 0 10px 0; +} diff --git a/support_branding/static/src/js/res_config_edition.js b/support_branding/static/src/js/res_config_edition.js new file mode 100644 index 000000000..48ac99cc3 --- /dev/null +++ b/support_branding/static/src/js/res_config_edition.js @@ -0,0 +1,33 @@ +odoo.define("support_branding.ResConfigEdition", function (require) { + "use strict"; + + var ResConfigEdition = require("base_setup.ResConfigEdition"); + + ResConfigEdition.include({ + willStart: function () { + var self = this; + var def_1 = this._rpc({ + model: "ir.config_parameter", + method: "get_param", + args: ["support_company"], + }).then(function (name) { + self.support_cp_name = name; + }); + var def_2 = this._rpc({ + model: "ir.config_parameter", + method: "get_param", + args: ["support_company_url"], + }).then(function (url) { + self.support_cp_url = url; + }); + var def_3 = this._rpc({ + model: "ir.config_parameter", + method: "get_param", + args: ["support_email"], + }).then(function (email) { + self.support_cp_email = email; + }); + return $.when(this._super.apply(this, arguments), def_1, def_2, def_3); + }, + }); +}); diff --git a/support_branding/static/src/js/support_branding.js b/support_branding/static/src/js/support_branding.js index c567cfd00..0aa4f558e 100644 --- a/support_branding/static/src/js/support_branding.js +++ b/support_branding/static/src/js/support_branding.js @@ -2,105 +2,169 @@ * Copyright 2016 - Tecnativa - Angel Moya * Copyright 2017 - redO2oo - Robert Rottermann * Copyright 2018 - Therp BV + * Copyright 2021 - Sunflower IT * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ -odoo.define("web.support_branding", function (require) { - var CrashManager = require("web.CrashManager"); - var core = require("web.core"); - var Model = require("web.Model"); +odoo.define("support_branding.CrashManager", function (require) { + "use strict"; + var CrashManager = require("web.CrashManager").CrashManager; var session = require("web.session"); + var core = require("web.core"); + var _t = core._t; + CrashManager.include({ init: function () { - var self = this, - ir_config_parameter = new Model("ir.config_parameter"); - ir_config_parameter - .call("get_param", ["support_branding.support_email"]) - .then(function (email) { - self.support_branding_support_email = email; + var self = this; + $.when(this._super.apply(this, arguments)).then(function () { + self._rpc({ + model: "ir.config_parameter", + method: "get_param", + args: ["support_company"], + }).then(function (name) { + self.support_cp_name = name; }); - ir_config_parameter - .call("get_param", ["support_branding.company_name"]) - .then(function (name) { - self.support_branding_company_name = name; + + self._rpc({ + model: "ir.config_parameter", + method: "get_param", + args: ["support_company_url"], + }).then(function (url) { + self.support_cp_url = url; }); - return this._super(this, arguments); + + self._rpc({ + model: "ir.config_parameter", + method: "get_param", + args: ["support_email"], + }).then(function (email) { + self.support_cp_email = email; + }); + + self._rpc({ + model: "ir.config_parameter", + method: "get_param", + args: ["support_release"], + }).then(function (release) { + self.support_cp_release = release; + }); + + self._rpc({ + model: "ir.config_parameter", + method: "get_param", + args: ["support_branding_color"], + }).then(function (color) { + self.support_cp_color = color; + }); + }); }, show_error: function (error) { var self = this; - error._session = session; - this._super.apply(this, arguments); - jQuery(".support-branding-submit-form").each(function () { - var $form = jQuery(this), - $button = $form.find("button"), - $description = $form.find('textarea[name="description"]'), - $subject = $form.find('input[name="subject"]'), - $body = $form.find('input[name="body"]'); - if (self.support_branding_support_email) { - $form.attr( - "action", - "mailto:" + self.support_branding_support_email - ); + var dialog = this._super.apply(this, arguments); + var subject = + session.username + + "@" + + session.db + + "[" + + session.server + + "]:" + + error.message; + var body = error.data.debug; + var inputs = + "" + + '"; + dialog.opened(function () { + var $form = $(".support-branding-submit-form"); + var $statement = $(".support-statement"); + var $description = $(".support-desc"); + var $button = $(".support-btn"); + var $body = $(".sp-body"); + var $header = $form.parents(".modal-dialog").find(".modal-header"); + var $footer = $form.parents(".modal-dialog").find(".modal-footer"); + + $statement.prepend(inputs); + if (self.support_cp_email) { + if (self.support_cp_name) { + var title = "Support By " + self.support_cp_name; + $('

' + title + "

").insertBefore( + ".support-branding-submit-form" + ); + $button.text( + _.str.sprintf(_t("Email to %s"), self.support_cp_name) + ); + } + $form.attr("action", "mailto:" + self.support_cp_email); $form .parents(".modal") .find(".modal-body") .css("max-height", "70vh"); - $button.click(function (ev) { - var mail_mail = new Model("mail.mail"); + $button.on("click", function (ev) { + var $btn = $(this); if (!$description.val()) { $description.parent().addClass("oe_form_invalid"); ev.preventDefault(); return; } - mail_mail - .call("create", [ - { - state: "outgoing", - auto_delete: true, - email_to: self.support_branding_support_email, - subject: $subject.val(), - body_html: jQuery("
") - .append( - jQuery("
").text($description.val()), - jQuery("
").text($body.val())
-                                        )
-                                        .html(),
-                                },
-                            ])
-                            .then(
-                                function (mail_id) {
-                                    return mail_mail.call("send", [[mail_id]]);
-                                },
-                                function () {
-                                    // If the call failed, fire the mailto link
-                                    // hoping there is a properly configured email
-                                    // client
-                                    $body.val($description.val() + "\n" + $body.val());
-                                    $button.unbind("click");
-                                    $button.click();
-                                }
-                            )
-                            .then(function () {
-                                $form.parents(".modal").modal("hide");
-                            });
                         ev.preventDefault();
+                        var desc = $description.val();
+                        var params = {
+                            state: "outgoing",
+                            auto_delete: true,
+                            email_to: self.support_cp_email,
+                            subject: subject,
+                            body_html: jQuery("
") + .append( + jQuery("
").text(desc), + jQuery("
").text(body)
+                                )
+                                .html(),
+                        };
+                        self._rpc({
+                            model: "mail.mail",
+                            method: "create",
+                            args: [params],
+                        }).then(
+                            function (mail_id) {
+                                if (mail_id) {
+                                    self._rpc({
+                                        model: "mail.mail",
+                                        method: "send",
+                                        args: [mail_id],
+                                    }).then(function (res) {
+                                        if (res) {
+                                            self.do_notify(
+                                                "Success",
+                                                "Support mail created!"
+                                            );
+                                        }
+                                    });
+                                }
+                            },
+                            function () {
+                                $body.val(desc + "\n" + $body.val());
+                                $btn.unbind("click");
+                                $btn.click();
+                            }
+                        );
                     });
                 } else {
-                    $description.hide();
-                    $button.hide();
+                    $description.css({display: "none"});
+                    $button.css({display: "none"});
                 }
-                if (self.support_branding_company_name) {
-                    $button.text(
-                        _.str.sprintf(
-                            _t("Email to %s"),
-                            self.support_branding_company_name
-                        )
-                    );
+                $form.prependTo($footer);
+                if (self.support_cp_color) {
+                    $header.css({background: self.support_cp_color});
+                    $footer.css({background: self.support_cp_color});
+                } else {
+                    $header.css({background: ""});
+                    $footer.css({background: ""});
                 }
-                $form.prependTo($form.parents(".modal-dialog").find(".modal-footer"));
             });
         },
     });
-    // This is already instantiated, so we need to call init manually
-    require("web.crash_manager").init();
 });
diff --git a/support_branding/static/src/js/user_menu.js b/support_branding/static/src/js/user_menu.js
new file mode 100644
index 000000000..f0c76ba45
--- /dev/null
+++ b/support_branding/static/src/js/user_menu.js
@@ -0,0 +1,27 @@
+odoo.define("support_branding.UserMenu", function (require) {
+    "use strict";
+
+    var user_menu = require("web.UserMenu");
+
+    user_menu.include({
+        _onMenuSupport: function () {
+            var url = this.support_url || "https://www.odoo.com/buy";
+            window.open(url, "_blank");
+        },
+        willStart: function () {
+            var self = this;
+            var def = self
+                ._rpc({
+                    model: "ir.config_parameter",
+                    method: "get_param",
+                    args: ["support_company_url"],
+                })
+                .then(function (site) {
+                    if (site && site !== "") {
+                        self.support_url = site;
+                    }
+                });
+            return $.when(this._super.apply(this, arguments), def);
+        },
+    });
+});
diff --git a/support_branding/static/src/xml/base.xml b/support_branding/static/src/xml/base.xml
index bdc0f6528..416f3afc9 100644
--- a/support_branding/static/src/xml/base.xml
+++ b/support_branding/static/src/xml/base.xml
@@ -1,36 +1,64 @@
 
 
     
-        
-            
+ +
- - -
+