Skip to content

Commit

Permalink
[ADD] survey_certification_sending: New module
Browse files Browse the repository at this point in the history
TT54988
  • Loading branch information
pilarvargas-tecnativa committed Feb 12, 2025
1 parent 74c4a0d commit 69f9f82
Show file tree
Hide file tree
Showing 19 changed files with 1,073 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/survey_certification_sending/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
104 changes: 104 additions & 0 deletions survey_certification_sending/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
============================
Survey Certification Sending
============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f803666c59351fa990677b0084dd6507d3b6297d5939d2beb5e834a095447262
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fsurvey-lightgray.png?logo=github
:target: https://github.com/OCA/survey/tree/15.0/survey_certification_sending
:alt: OCA/survey
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/survey-15-0/survey-15-0-survey_certification_sending
: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/survey&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the Odoo Survey application to allow automatic and manual sending
of certifications when a participant successfully completes a survey.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

#. Go to Survey > Surveys.
#. Create or edit a certification survey.
#. Configure whether you want to send certifications manually by checking the
"Skip Auto Email" option.
#. Participants who pass the survey will receive their certification automatically if
manual submission is not enabled.
#. If the automatic sending is disabled, passed certifications can be submitted manually
from the "Send certification email" action.
#. Certifications that have already been sent will be marked as "Certification sent".
#. Passed certifications can be sent as many times as necessary.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/survey/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 <https://github.com/OCA/survey/issues/new?body=module:%20survey_certification_sending%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_

* David Vidal
* Pilar Vargas

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.

.. |maintainer-pilarvargas-tecnativa| image:: https://github.com/pilarvargas-tecnativa.png?size=40px
:target: https://github.com/pilarvargas-tecnativa
:alt: pilarvargas-tecnativa

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-pilarvargas-tecnativa|

This module is part of the `OCA/survey <https://github.com/OCA/survey/tree/15.0/survey_certification_sending>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions survey_certification_sending/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions survey_certification_sending/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Survey Certification Sending",
"summary": "Controls the automatic sending of certifications in surveys.",
"version": "15.0.1.0.0",
"author": "Tecnativa, Odoo Community Association (OCA)",
"development_status": "Beta",
"category": "Marketing/Survey",
"website": "https://github.com/OCA/survey",
"maintainers": ["pilarvargas-tecnativa"],
"license": "AGPL-3",
"depends": ["survey"],
"data": [
"views/survey_survey_views.xml",
"views/survey_user_views.xml",
],
"installable": True,
}
74 changes: 74 additions & 0 deletions survey_certification_sending/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * survey_certification_sending
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-12 14:06+0000\n"
"PO-Revision-Date: 2025-02-12 15:11+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.4.2\n"

#. module: survey_certification_sending
#: code:addons/survey_certification_sending/models/survey_user_input.py:0
#, python-format
msgid "%s certification(s) successfully sent."
msgstr "%s certificación(es) enviada(s) con éxito."

#. module: survey_certification_sending
#: model:ir.model.fields,field_description:survey_certification_sending.field_survey_user_input__certification_sent
msgid "Certification Sent"
msgstr "Certificación enviada"

#. module: survey_certification_sending
#: model:ir.model,name:survey_certification_sending.model_mail_template
msgid "Email Templates"
msgstr ""

#. module: survey_certification_sending
#: model:ir.model.fields,help:survey_certification_sending.field_survey_user_input__certification_sent
msgid "It indicates if the certification has been sent."
msgstr "Indica si la certificación ha sido enviada."

#. module: survey_certification_sending
#: code:addons/survey_certification_sending/models/survey_user_input.py:0
#, python-format
msgid "No certifications sent. The survey does not meet the conditions."
msgstr "No se han enviado certificaciones. La encuesta no cumple las condiciones."

#. module: survey_certification_sending
#: model:ir.actions.server,name:survey_certification_sending.ir_actions_server_send_certification
msgid "Send Certification Email"
msgstr "Enviar certificación por correo electrónico"

#. module: survey_certification_sending
#: model:ir.model.fields,field_description:survey_certification_sending.field_survey_survey__skip_auto_email
msgid "Skip Auto Email"
msgstr "Omitir correo automático"

#. module: survey_certification_sending
#: model:ir.model.fields,help:survey_certification_sending.field_survey_survey__skip_auto_email
msgid ""
"Skip sending the certification automatically after successful completion of "
"the survey."
msgstr ""
"Omitir el envío automático de la certificación una vez completada con éxito la "
"la encuesta."

#. module: survey_certification_sending
#: model:ir.model,name:survey_certification_sending.model_survey_survey
msgid "Survey"
msgstr ""

#. module: survey_certification_sending
#: model:ir.model,name:survey_certification_sending.model_survey_user_input
msgid "Survey User Input"
msgstr ""
70 changes: 70 additions & 0 deletions survey_certification_sending/i18n/survey_certification_sending.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * survey_certification_sending
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-02-12 14:06+0000\n"
"PO-Revision-Date: 2025-02-12 14:06+0000\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: survey_certification_sending
#: code:addons/survey_certification_sending/models/survey_user_input.py:0
#, python-format
msgid "%s certification(s) successfully sent."
msgstr ""

#. module: survey_certification_sending
#: model:ir.model.fields,field_description:survey_certification_sending.field_survey_user_input__certification_sent
msgid "Certification Sent"
msgstr ""

#. module: survey_certification_sending
#: model:ir.model,name:survey_certification_sending.model_mail_template
msgid "Email Templates"
msgstr ""

#. module: survey_certification_sending
#: model:ir.model.fields,help:survey_certification_sending.field_survey_user_input__certification_sent
msgid "It indicates if the certification has been sent."
msgstr ""

#. module: survey_certification_sending
#: code:addons/survey_certification_sending/models/survey_user_input.py:0
#, python-format
msgid "No certifications sent. The survey does not meet the conditions."
msgstr ""

#. module: survey_certification_sending
#: model:ir.actions.server,name:survey_certification_sending.ir_actions_server_send_certification
msgid "Send Certification Email"
msgstr ""

#. module: survey_certification_sending
#: model:ir.model.fields,field_description:survey_certification_sending.field_survey_survey__skip_auto_email
msgid "Skip Auto Email"
msgstr ""

#. module: survey_certification_sending
#: model:ir.model.fields,help:survey_certification_sending.field_survey_survey__skip_auto_email
msgid ""
"Skip sending the certification automatically after successful completion of "
"the survey."
msgstr ""

#. module: survey_certification_sending
#: model:ir.model,name:survey_certification_sending.model_survey_survey
msgid "Survey"
msgstr ""

#. module: survey_certification_sending
#: model:ir.model,name:survey_certification_sending.model_survey_user_input
msgid "Survey User Input"
msgstr ""
3 changes: 3 additions & 0 deletions survey_certification_sending/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import mail_template
from . import survey_survey
from . import survey_user_input
21 changes: 21 additions & 0 deletions survey_certification_sending/models/mail_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models


class MailTemplate(models.Model):
_inherit = "mail.template"

def send_mail(
self,
res_id,
force_send=False,
raise_exception=False,
email_values=None,
notif_layout=False,
):
if self.env.context.get("skip_auto_email"):
return False
return super().send_mail(
res_id, force_send, raise_exception, email_values, notif_layout
)
12 changes: 12 additions & 0 deletions survey_certification_sending/models/survey_survey.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class Survey(models.Model):
_inherit = "survey.survey"

skip_auto_email = fields.Boolean(
help="Skip sending the certification automatically after successful completion "
"of the survey."
)
56 changes: 56 additions & 0 deletions survey_certification_sending/models/survey_user_input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import _, fields, models


class SurveyUserInput(models.Model):
_inherit = "survey.user_input"

certification_sent = fields.Boolean(
default=False, help="It indicates if the certification has been sent."
)

def _mark_done(self):
for user_input in self:
if (
not user_input.survey_id.skip_auto_email
and user_input.survey_id.certification
and user_input.scoring_success
):
if (
user_input.survey_id.certification_mail_template_id
and not user_input.test_entry
):
user_input.certification_sent = True

# Mark as completed and send email only if not deactivated.
return super(
SurveyUserInput,
self.with_context(
skip_auto_email=self.mapped("survey_id").filtered(
lambda s: s.skip_auto_email
)
),
)._mark_done()

def action_manual_send_certification(self):
# Send certifications manually only to those who passed the survey.
sent_count = 0
for user_input in self:
if (
user_input.survey_id.certification
and user_input.scoring_success
and not user_input.test_entry
):
template = user_input.survey_id.certification_mail_template_id
if template:
template.send_mail(
user_input.id, notif_layout="mail.mail_notification_light"
)
user_input.certification_sent = True
sent_count += 1

if sent_count:
return _("%s certification(s) successfully sent.", sent_count)
else:
return _("No certifications sent. The survey does not meet the conditions.")
4 changes: 4 additions & 0 deletions survey_certification_sending/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `Tecnativa <https://www.tecnativa.com>`_

* David Vidal
* Pilar Vargas
2 changes: 2 additions & 0 deletions survey_certification_sending/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends the Odoo Survey application to allow automatic and manual sending
of certifications when a participant successfully completes a survey.
12 changes: 12 additions & 0 deletions survey_certification_sending/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
To use this module, you need to:

#. Go to Survey > Surveys.
#. Create or edit a certification survey.
#. Configure whether you want to send certifications manually by checking the
"Skip Auto Email" option.
#. Participants who pass the survey will receive their certification automatically if
manual submission is not enabled.
#. If the automatic sending is disabled, passed certifications can be submitted manually
from the "Send certification email" action.
#. Certifications that have already been sent will be marked as "Certification sent".
#. Passed certifications can be sent as many times as necessary.
Loading

0 comments on commit 69f9f82

Please sign in to comment.