Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][ADD] survey_certification_sending: New module #146

Open
wants to merge 1 commit into
base: 15.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 20 additions & 0 deletions survey_certification_sending/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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_templates.xml",
"views/survey_user_views.xml",
],
"installable": True,
}
82 changes: 82 additions & 0 deletions survey_certification_sending/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 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-21 06:59+0000\n"
"PO-Revision-Date: 2025-02-21 08:01+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
#: code:addons/survey_certification_sending/models/survey_user_input.py:0
#: model:ir.model.fields,field_description:survey_certification_sending.field_survey_user_input__certification_sent
#, python-format
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"
msgstr "Certificaciones no enviadas"

#. 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_certification_email
msgid "Skip Certification Email"
msgstr "Omitir correo de certificación"

#. module: survey_certification_sending
#: model:ir.model.fields,help:survey_certification_sending.field_survey_survey__skip_certification_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 ""

#. module: survey_certification_sending
#: code:addons/survey_certification_sending/models/survey_user_input.py:0
#, python-format
msgid "The survey does not meet the conditions."
msgstr "La encuesta no cumple las condiciones."
78 changes: 78 additions & 0 deletions survey_certification_sending/i18n/survey_certification_sending.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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-21 06:59+0000\n"
"PO-Revision-Date: 2025-02-21 06:59+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
#: code:addons/survey_certification_sending/models/survey_user_input.py:0
#: model:ir.model.fields,field_description:survey_certification_sending.field_survey_user_input__certification_sent
#, python-format
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"
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_certification_email
msgid "Skip Certification Email"
msgstr ""

#. module: survey_certification_sending
#: model:ir.model.fields,help:survey_certification_sending.field_survey_survey__skip_certification_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 ""

#. module: survey_certification_sending
#: code:addons/survey_certification_sending/models/survey_user_input.py:0
#, python-format
msgid "The survey does not meet the conditions."
msgstr ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
surveys = env["survey.survey"].search(
[
("certification", "=", True),
("certification_mail_template_id", "!=", False),
]
)
for survey in surveys:
template = survey.certification_mail_template_id
user_inputs = env["survey.user_input"].search(
[
("survey_id", "=", survey.id),
("scoring_success", "=", True),
("certification_sent", "=", False),
]
)
for user_input in user_inputs:
user_lang = user_input.partner_id.lang or env.user.lang
email_values = template.with_context(lang=user_lang).generate_email(
user_input.id, ["subject"]
)
subject_rendered = email_values.get("subject", "")
mail_exists = (
env["mail.message"].search_count(
[
("model", "=", "survey.user_input"),
("res_id", "=", user_input.id),
("subject", "ilike", subject_rendered),
]
)
> 0
)
if mail_exists:
user_input.write({"certification_sent": True})
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
24 changes: 24 additions & 0 deletions survey_certification_sending/models/mail_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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.model == "survey.user_input":
skip_ids = self.env.context.get("skip_certification_email_ids", [])
survey = self.env["survey.user_input"].browse(res_id).survey_id
if survey.id in skip_ids:
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_certification_email = fields.Boolean(
help="Skip sending the certification automatically after successful completion "
"of the survey."
)
Loading