diff --git a/website_membership_gamification/README.rst b/website_membership_gamification/README.rst new file mode 100644 index 000000000..8c9f1ac9a --- /dev/null +++ b/website_membership_gamification/README.rst @@ -0,0 +1,98 @@ +=============================== +Website Membership Gamification +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:be652f131e2377a9183b1bd5e2a853d7e8a6e4bfe8ff2bbade6b38724735b500 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fvertical--association-lightgray.png?logo=github + :target: https://github.com/OCA/vertical-association/tree/17.0/website_membership_gamification + :alt: OCA/vertical-association +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/vertical-association-17-0/vertical-association-17-0-website_membership_gamification + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/vertical-association&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to see badges assigned to users on the Members page +in website. It also allows to set badges straight from contacts view. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +1. Go to *Settings > Gamification Tools > Badges*. +2. Open or create a new badge. +3. Set an URL in Badge URL field if you want to link the badge on the + website to a webpage. +4. Set a 'Website Expiration Date' so the badge is not shown on the + website after that date. + +Usage +===== + +You can assign a badge to a contact from the contact form view. Only +contacts related to a user are allowed. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Sygel + +Contributors +------------ + +- Manuel Regidor +- Valentín Vinagre +- `Tecnativa `__: + + - Stefan Ungureanu + - Carolina Fernandez + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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/vertical-association `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_membership_gamification/__init__.py b/website_membership_gamification/__init__.py new file mode 100644 index 000000000..18143cb95 --- /dev/null +++ b/website_membership_gamification/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/website_membership_gamification/__manifest__.py b/website_membership_gamification/__manifest__.py new file mode 100644 index 000000000..57970a9c8 --- /dev/null +++ b/website_membership_gamification/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2022 Manuel Regidor +# Copyright 2023 Tecnativa - Pedro M. Baeza +# Copyright 2023 Tecnativa - Carolina Fernandez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Website Membership Gamification", + "summary": "Show badges assigned to users on website", + "version": "17.0.1.0.0", + "category": "Website", + "author": "Sygel, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/vertical-association", + "license": "AGPL-3", + "application": False, + "installable": True, + "development_status": "Beta", + "depends": ["gamification", "website_membership"], + "data": [ + "wizard/gamification_badge_user_wizard.xml", + "views/badge.xml", + "views/res_partner_views.xml", + "views/website_partner_template.xml", + ], +} diff --git a/website_membership_gamification/i18n/es.po b/website_membership_gamification/i18n/es.po new file mode 100644 index 000000000..cffbdfd22 --- /dev/null +++ b/website_membership_gamification/i18n/es.po @@ -0,0 +1,110 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_membership_gamification +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-10-15 20:36+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.website_membership_gamification_badge_user_kanban_view +msgid "Assigned to" +msgstr "Asignado/a a" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__badge_url +msgid "Badge URL" +msgstr "URL del distintivo" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_partner__gamification_badge_ids +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_users__gamification_badge_ids +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.website_membership_gamification_view_partner_form +msgid "Badges" +msgstr "Distintivos" + +#. module: website_membership_gamification +#. odoo-python +#: code:addons/website_membership_gamification/models/res_partner.py:0 +#, python-format +msgid "" +"Both hr_gamification and website_membership_gamification modules are " +"installed. You need to install user_hr_gamification in order to use both." +msgstr "" +"Se instalan los módulos hr_gamification y website_membership_gamification. " +"Necesitas instalar user_hr_gamification para poder usar ambos." + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.partner_view_badge_wizard_reward +msgid "Cancel" +msgstr "Cancelar" + +#. module: website_membership_gamification +#: model:ir.model,name:website_membership_gamification.model_res_partner +msgid "Contact" +msgstr "Contacto" + +#. module: website_membership_gamification +#: model:ir.model,name:website_membership_gamification.model_gamification_badge +msgid "Gamification Badge" +msgstr "Distintivo de Gamificación" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.partner_view_badge_wizard_reward +msgid "Grant Badge" +msgstr "Distintivo de subvención" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.website_membership_gamification_view_partner_form +msgid "Grant a Badge" +msgstr "Conceder un distintivo" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_partner__has_related_users +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_users__has_related_users +msgid "Has Related Users" +msgstr "Tiene Usuarios Relacionados" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__new_tab_url +msgid "Open URL in new tab" +msgstr "Abrir URL en una nueva pestaña" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__website_member_published +msgid "Published in member directory" +msgstr "Publicado en el directorio de miembros" + +#. module: website_membership_gamification +#. odoo-python +#: code:addons/website_membership_gamification/models/res_partner.py:0 +#, python-format +msgid "Reward" +msgstr "Recompensa" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.partner_view_badge_wizard_reward +msgid "Reward with" +msgstr "Recompensa con" + +#. module: website_membership_gamification +#. odoo-python +#: code:addons/website_membership_gamification/models/res_partner.py:0 +#, python-format +msgid "The partner has no related users." +msgstr "El socio no tiene usuarios relacionados." + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__website_expiration_date +msgid "Website Expiration Date" +msgstr "Fecha de Caducidad del Sitio Web" diff --git a/website_membership_gamification/i18n/fr.po b/website_membership_gamification/i18n/fr.po new file mode 100644 index 000000000..573118778 --- /dev/null +++ b/website_membership_gamification/i18n/fr.po @@ -0,0 +1,111 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_membership_gamification +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-10 12:37+0000\n" +"Last-Translator: LESTRAT21 \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.website_membership_gamification_badge_user_kanban_view +msgid "Assigned to" +msgstr "Assigné à" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__badge_url +msgid "Badge URL" +msgstr "URL du badge" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_partner__gamification_badge_ids +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_users__gamification_badge_ids +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.website_membership_gamification_view_partner_form +msgid "Badges" +msgstr "Badges" + +#. module: website_membership_gamification +#. odoo-python +#: code:addons/website_membership_gamification/models/res_partner.py:0 +#, python-format +msgid "" +"Both hr_gamification and website_membership_gamification modules are " +"installed. You need to install user_hr_gamification in order to use both." +msgstr "" +"Les modules hr_gamification and website_membership_gamification sont " +"installés. Mais il faut également installer user_hr_gamification pour les " +"utiliser." + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.partner_view_badge_wizard_reward +msgid "Cancel" +msgstr "Annule" + +#. module: website_membership_gamification +#: model:ir.model,name:website_membership_gamification.model_res_partner +msgid "Contact" +msgstr "Contact" + +#. module: website_membership_gamification +#: model:ir.model,name:website_membership_gamification.model_gamification_badge +msgid "Gamification Badge" +msgstr "" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.partner_view_badge_wizard_reward +msgid "Grant Badge" +msgstr "" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.website_membership_gamification_view_partner_form +msgid "Grant a Badge" +msgstr "" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_partner__has_related_users +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_users__has_related_users +msgid "Has Related Users" +msgstr "" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__new_tab_url +msgid "Open URL in new tab" +msgstr "" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__website_member_published +msgid "Published in member directory" +msgstr "" + +#. module: website_membership_gamification +#. odoo-python +#: code:addons/website_membership_gamification/models/res_partner.py:0 +#, python-format +msgid "Reward" +msgstr "" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.partner_view_badge_wizard_reward +msgid "Reward with" +msgstr "" + +#. module: website_membership_gamification +#. odoo-python +#: code:addons/website_membership_gamification/models/res_partner.py:0 +#, python-format +msgid "The partner has no related users." +msgstr "" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__website_expiration_date +msgid "Website Expiration Date" +msgstr "" diff --git a/website_membership_gamification/i18n/it.po b/website_membership_gamification/i18n/it.po new file mode 100644 index 000000000..ea9573b6a --- /dev/null +++ b/website_membership_gamification/i18n/it.po @@ -0,0 +1,110 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_membership_gamification +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-05-12 13:34+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.14.1\n" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.website_membership_gamification_badge_user_kanban_view +msgid "Assigned to" +msgstr "Assegnato a" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__badge_url +msgid "Badge URL" +msgstr "URL tesserino" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_partner__gamification_badge_ids +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_users__gamification_badge_ids +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.website_membership_gamification_view_partner_form +msgid "Badges" +msgstr "Tesserini" + +#. module: website_membership_gamification +#. odoo-python +#: code:addons/website_membership_gamification/models/res_partner.py:0 +#, python-format +msgid "" +"Both hr_gamification and website_membership_gamification modules are " +"installed. You need to install user_hr_gamification in order to use both." +msgstr "" +"I moduli hr_gamification e website_membership_gamification sono installati. " +"Serve installare user_hr_gamification pe usarli entrambi." + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.partner_view_badge_wizard_reward +msgid "Cancel" +msgstr "Annulla" + +#. module: website_membership_gamification +#: model:ir.model,name:website_membership_gamification.model_res_partner +msgid "Contact" +msgstr "Contatto" + +#. module: website_membership_gamification +#: model:ir.model,name:website_membership_gamification.model_gamification_badge +msgid "Gamification Badge" +msgstr "Tesserino gamification" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.partner_view_badge_wizard_reward +msgid "Grant Badge" +msgstr "Concessione tesserino" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.website_membership_gamification_view_partner_form +msgid "Grant a Badge" +msgstr "Concedi un tesserino" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_partner__has_related_users +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_users__has_related_users +msgid "Has Related Users" +msgstr "Ha utenti collegati" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__new_tab_url +msgid "Open URL in new tab" +msgstr "Apri URL in nuova scheda" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__website_member_published +msgid "Published in member directory" +msgstr "Pubblicato nella cartella membri" + +#. module: website_membership_gamification +#. odoo-python +#: code:addons/website_membership_gamification/models/res_partner.py:0 +#, python-format +msgid "Reward" +msgstr "Ricompensa" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.partner_view_badge_wizard_reward +msgid "Reward with" +msgstr "Ricompensa con" + +#. module: website_membership_gamification +#. odoo-python +#: code:addons/website_membership_gamification/models/res_partner.py:0 +#, python-format +msgid "The partner has no related users." +msgstr "Il partner non ha un utente collegato." + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__website_expiration_date +msgid "Website Expiration Date" +msgstr "Data scadenza sito web" diff --git a/website_membership_gamification/i18n/website_membership_gamification.pot b/website_membership_gamification/i18n/website_membership_gamification.pot new file mode 100644 index 000000000..fc178ad36 --- /dev/null +++ b/website_membership_gamification/i18n/website_membership_gamification.pot @@ -0,0 +1,105 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_membership_gamification +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.website_membership_gamification_badge_user_kanban_view +msgid "Assigned to" +msgstr "" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__badge_url +msgid "Badge URL" +msgstr "" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_partner__gamification_badge_ids +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_users__gamification_badge_ids +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.website_membership_gamification_view_partner_form +msgid "Badges" +msgstr "" + +#. module: website_membership_gamification +#. odoo-python +#: code:addons/website_membership_gamification/models/res_partner.py:0 +#, python-format +msgid "" +"Both hr_gamification and website_membership_gamification modules are " +"installed. You need to install user_hr_gamification in order to use both." +msgstr "" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.partner_view_badge_wizard_reward +msgid "Cancel" +msgstr "" + +#. module: website_membership_gamification +#: model:ir.model,name:website_membership_gamification.model_res_partner +msgid "Contact" +msgstr "" + +#. module: website_membership_gamification +#: model:ir.model,name:website_membership_gamification.model_gamification_badge +msgid "Gamification Badge" +msgstr "" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.partner_view_badge_wizard_reward +msgid "Grant Badge" +msgstr "" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.website_membership_gamification_view_partner_form +msgid "Grant a Badge" +msgstr "" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_partner__has_related_users +#: model:ir.model.fields,field_description:website_membership_gamification.field_res_users__has_related_users +msgid "Has Related Users" +msgstr "" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__new_tab_url +msgid "Open URL in new tab" +msgstr "" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__website_member_published +msgid "Published in member directory" +msgstr "" + +#. module: website_membership_gamification +#. odoo-python +#: code:addons/website_membership_gamification/models/res_partner.py:0 +#, python-format +msgid "Reward" +msgstr "" + +#. module: website_membership_gamification +#: model_terms:ir.ui.view,arch_db:website_membership_gamification.partner_view_badge_wizard_reward +msgid "Reward with" +msgstr "" + +#. module: website_membership_gamification +#. odoo-python +#: code:addons/website_membership_gamification/models/res_partner.py:0 +#, python-format +msgid "The partner has no related users." +msgstr "" + +#. module: website_membership_gamification +#: model:ir.model.fields,field_description:website_membership_gamification.field_gamification_badge__website_expiration_date +msgid "Website Expiration Date" +msgstr "" diff --git a/website_membership_gamification/models/__init__.py b/website_membership_gamification/models/__init__.py new file mode 100644 index 000000000..2670e03d5 --- /dev/null +++ b/website_membership_gamification/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import gamification_badge +from . import res_partner diff --git a/website_membership_gamification/models/gamification_badge.py b/website_membership_gamification/models/gamification_badge.py new file mode 100644 index 000000000..d0fb8d5f8 --- /dev/null +++ b/website_membership_gamification/models/gamification_badge.py @@ -0,0 +1,13 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class GamificationBadge(models.Model): + _inherit = "gamification.badge" + + badge_url = fields.Char(string="Badge URL") + website_member_published = fields.Boolean(string="Published in member directory") + new_tab_url = fields.Boolean(string="Open URL in new tab") + website_expiration_date = fields.Date() diff --git a/website_membership_gamification/models/res_partner.py b/website_membership_gamification/models/res_partner.py new file mode 100644 index 000000000..178aed065 --- /dev/null +++ b/website_membership_gamification/models/res_partner.py @@ -0,0 +1,63 @@ +# Copyright 2022 Manuel Regidor +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError + + +class ResPartner(models.Model): + _inherit = "res.partner" + + gamification_badge_ids = fields.Many2many( + string="Badges", + comodel_name="gamification.badge.user", + compute="_compute_gamification_badge_ids", + store=True, + recursive=True, + ) + has_related_users = fields.Boolean(compute="_compute_has_related_users") + + @api.depends("user_ids.badge_ids", "child_ids", "child_ids.gamification_badge_ids") + def _compute_gamification_badge_ids(self): + for sel in self: + sel.gamification_badge_ids = ( + sel.user_ids.mapped("badge_ids") if sel.user_ids else False + ) + if sel.user_ids and sel != sel.commercial_partner_id: + badges = [(4, badge) for badge in sel.user_ids.mapped("badge_ids").ids] + sel.commercial_partner_id.gamification_badge_ids = badges + + def _compute_has_related_users(self): + for sel in self: + sel.has_related_users = any(a.active for a in sel.user_ids) + + def action_grant_badge_wizard(self): + user_hr_gamification_module = self.env["ir.module.module"].search( + [("name", "=", "user_hr_gamification")] + ) + if ( + not user_hr_gamification_module + or user_hr_gamification_module.state != "installed" + ) and "employee_id" in self.env["gamification.badge.user.wizard"]._fields: + raise ValidationError( + _( + "Both hr_gamification and website_membership_gamification " + "modules are installed. You need to install " + "user_hr_gamification in order to use both." + ) + ) + if not self.has_related_users: + raise ValidationError(_("The partner has no related users.")) + user_id = self.user_ids.filtered(lambda a: a.active)[0] + view_id = self.env.ref( + "website_membership_gamification.partner_view_badge_wizard_reward" + ) + return { + "name": _("Reward"), + "view_mode": "form", + "res_model": "gamification.badge.user.wizard", + "view_id": view_id.id, + "type": "ir.actions.act_window", + "target": "new", + "context": {"default_user_id": user_id.id}, + } diff --git a/website_membership_gamification/pyproject.toml b/website_membership_gamification/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/website_membership_gamification/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/website_membership_gamification/readme/CONFIGURE.md b/website_membership_gamification/readme/CONFIGURE.md new file mode 100644 index 000000000..dccc5eb7f --- /dev/null +++ b/website_membership_gamification/readme/CONFIGURE.md @@ -0,0 +1,6 @@ +1. Go to *Settings \> Gamification Tools \> Badges*. +2. Open or create a new badge. +3. Set an URL in Badge URL field if you want to link the badge on the + website to a webpage. +4. Set a 'Website Expiration Date' so the badge is not shown on the + website after that date. diff --git a/website_membership_gamification/readme/CONTRIBUTORS.md b/website_membership_gamification/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..7f894897f --- /dev/null +++ b/website_membership_gamification/readme/CONTRIBUTORS.md @@ -0,0 +1,5 @@ +- Manuel Regidor \<\> +- Valentín Vinagre \<\> +- [Tecnativa](https://www.tecnativa.com): + - Stefan Ungureanu + - Carolina Fernandez diff --git a/website_membership_gamification/readme/DESCRIPTION.md b/website_membership_gamification/readme/DESCRIPTION.md new file mode 100644 index 000000000..41f5add61 --- /dev/null +++ b/website_membership_gamification/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module allows to see badges assigned to users on the Members page +in website. It also allows to set badges straight from contacts view. diff --git a/website_membership_gamification/readme/USAGE.md b/website_membership_gamification/readme/USAGE.md new file mode 100644 index 000000000..661d98407 --- /dev/null +++ b/website_membership_gamification/readme/USAGE.md @@ -0,0 +1,2 @@ +You can assign a badge to a contact from the contact form view. Only +contacts related to a user are allowed. diff --git a/website_membership_gamification/static/description/icon.png b/website_membership_gamification/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/website_membership_gamification/static/description/icon.png differ diff --git a/website_membership_gamification/static/description/index.html b/website_membership_gamification/static/description/index.html new file mode 100644 index 000000000..45cee4479 --- /dev/null +++ b/website_membership_gamification/static/description/index.html @@ -0,0 +1,448 @@ + + + + + +Website Membership Gamification + + + +
+

Website Membership Gamification

+ + +

Beta License: AGPL-3 OCA/vertical-association Translate me on Weblate Try me on Runboat

+

This module allows to see badges assigned to users on the Members page +in website. It also allows to set badges straight from contacts view.

+

Table of contents

+ +
+

Configuration

+
    +
  1. Go to Settings > Gamification Tools > Badges.
  2. +
  3. Open or create a new badge.
  4. +
  5. Set an URL in Badge URL field if you want to link the badge on the +website to a webpage.
  6. +
  7. Set a ‘Website Expiration Date’ so the badge is not shown on the +website after that date.
  8. +
+
+
+

Usage

+

You can assign a badge to a contact from the contact form view. Only +contacts related to a user are allowed.

+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Sygel
  • +
+
+
+

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/vertical-association project on GitHub.

+

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

+
+
+
+ + diff --git a/website_membership_gamification/views/badge.xml b/website_membership_gamification/views/badge.xml new file mode 100644 index 000000000..4c8310e0a --- /dev/null +++ b/website_membership_gamification/views/badge.xml @@ -0,0 +1,18 @@ + + + + + website.membership.gamification.badge.form.view + gamification.badge + + + + + + + + + + + diff --git a/website_membership_gamification/views/res_partner_views.xml b/website_membership_gamification/views/res_partner_views.xml new file mode 100644 index 000000000..2d6525d38 --- /dev/null +++ b/website_membership_gamification/views/res_partner_views.xml @@ -0,0 +1,41 @@ + + + + + website.membership.gamification.badge.user.kanban.view + gamification.badge.user + + + +
+

Assigned to

+
+
+
+
+ + website.membership.gamification.view.partner.form + res.partner + + + + + +