From efd9e2eb7e671c57f75f5c21d6ebb76fc02c08f3 Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Tue, 11 Feb 2025 23:38:57 +0100 Subject: [PATCH 01/16] [ADD] survey_certification_sending: New module TT54988 --- survey_certification_sending/README.rst | 104 ++++ survey_certification_sending/__init__.py | 1 + survey_certification_sending/__manifest__.py | 20 + survey_certification_sending/i18n/es.po | 82 ++++ .../i18n/survey_certification_sending.pot | 76 +++ .../migrations/15.0.1.0.0/post-migration.py | 38 ++ .../models/__init__.py | 3 + .../models/mail_template.py | 24 + .../models/survey_survey.py | 12 + .../models/survey_user_input.py | 67 +++ .../readme/CONTRIBUTORS.rst | 4 + .../readme/DESCRIPTION.rst | 2 + survey_certification_sending/readme/USAGE.rst | 12 + .../static/description/icon.png | Bin 0 -> 10254 bytes .../static/description/index.html | 447 ++++++++++++++++++ .../tests/__init__.py | 1 + .../test_survey_certification_sending.py | 185 ++++++++ .../views/survey_survey_views.xml | 15 + .../views/survey_templates.xml | 15 + .../views/survey_user_views.xml | 29 ++ 20 files changed, 1137 insertions(+) create mode 100644 survey_certification_sending/README.rst create mode 100644 survey_certification_sending/__init__.py create mode 100644 survey_certification_sending/__manifest__.py create mode 100644 survey_certification_sending/i18n/es.po create mode 100644 survey_certification_sending/i18n/survey_certification_sending.pot create mode 100644 survey_certification_sending/migrations/15.0.1.0.0/post-migration.py create mode 100644 survey_certification_sending/models/__init__.py create mode 100644 survey_certification_sending/models/mail_template.py create mode 100644 survey_certification_sending/models/survey_survey.py create mode 100644 survey_certification_sending/models/survey_user_input.py create mode 100644 survey_certification_sending/readme/CONTRIBUTORS.rst create mode 100644 survey_certification_sending/readme/DESCRIPTION.rst create mode 100644 survey_certification_sending/readme/USAGE.rst create mode 100644 survey_certification_sending/static/description/icon.png create mode 100644 survey_certification_sending/static/description/index.html create mode 100644 survey_certification_sending/tests/__init__.py create mode 100644 survey_certification_sending/tests/test_survey_certification_sending.py create mode 100644 survey_certification_sending/views/survey_survey_views.xml create mode 100644 survey_certification_sending/views/survey_templates.xml create mode 100644 survey_certification_sending/views/survey_user_views.xml diff --git a/survey_certification_sending/README.rst b/survey_certification_sending/README.rst new file mode 100644 index 00000000..57d539bd --- /dev/null +++ b/survey_certification_sending/README.rst @@ -0,0 +1,104 @@ +============================ +Survey Certification Sending +============================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:8ea8829eaa6afec788b8dd41ab8bdc3a46a0f15d833bcc75a3feaccea4f1def7 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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 `_. +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 +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_ + + * 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 `__: + +|maintainer-pilarvargas-tecnativa| + +This module is part of the `OCA/survey `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/survey_certification_sending/__init__.py b/survey_certification_sending/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/survey_certification_sending/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/survey_certification_sending/__manifest__.py b/survey_certification_sending/__manifest__.py new file mode 100644 index 00000000..6a41d1c1 --- /dev/null +++ b/survey_certification_sending/__manifest__.py @@ -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, +} diff --git a/survey_certification_sending/i18n/es.po b/survey_certification_sending/i18n/es.po new file mode 100644 index 00000000..4fd310db --- /dev/null +++ b/survey_certification_sending/i18n/es.po @@ -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." diff --git a/survey_certification_sending/i18n/survey_certification_sending.pot b/survey_certification_sending/i18n/survey_certification_sending.pot new file mode 100644 index 00000000..5378b8e1 --- /dev/null +++ b/survey_certification_sending/i18n/survey_certification_sending.pot @@ -0,0 +1,76 @@ +# 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" +"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 "" diff --git a/survey_certification_sending/migrations/15.0.1.0.0/post-migration.py b/survey_certification_sending/migrations/15.0.1.0.0/post-migration.py new file mode 100644 index 00000000..43a2fb65 --- /dev/null +++ b/survey_certification_sending/migrations/15.0.1.0.0/post-migration.py @@ -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}) diff --git a/survey_certification_sending/models/__init__.py b/survey_certification_sending/models/__init__.py new file mode 100644 index 00000000..2cff3554 --- /dev/null +++ b/survey_certification_sending/models/__init__.py @@ -0,0 +1,3 @@ +from . import mail_template +from . import survey_survey +from . import survey_user_input diff --git a/survey_certification_sending/models/mail_template.py b/survey_certification_sending/models/mail_template.py new file mode 100644 index 00000000..50372ce7 --- /dev/null +++ b/survey_certification_sending/models/mail_template.py @@ -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 + ) diff --git a/survey_certification_sending/models/survey_survey.py b/survey_certification_sending/models/survey_survey.py new file mode 100644 index 00000000..87f0973e --- /dev/null +++ b/survey_certification_sending/models/survey_survey.py @@ -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." + ) diff --git a/survey_certification_sending/models/survey_user_input.py b/survey_certification_sending/models/survey_user_input.py new file mode 100644 index 00000000..73df6f45 --- /dev/null +++ b/survey_certification_sending/models/survey_user_input.py @@ -0,0 +1,67 @@ +# 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: + # The response is marked as sent in anticipation that it will be sent safely. + if ( + user_input.survey_id.certification + and user_input.scoring_success + and not user_input.survey_id.skip_certification_email + and user_input.survey_id.certification_mail_template_id + and not user_input.test_entry + ): + user_input.certification_sent = True + # Add ids of surveys that have to skip automatic sending to the context + return super( + SurveyUserInput, + self.with_context( + skip_certification_email_ids=self.mapped("survey_id") + .filtered(lambda s: s.skip_certification_email) + .ids + ), + )._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: + title = _("Certification Sent") + message = _("%s certification(s) successfully sent.") % sent_count + notif_type = "success" + else: + title = _("No Certifications Sent") + message = _("The survey does not meet the conditions.") + notif_type = "warning" + return { + "type": "ir.actions.client", + "tag": "display_notification", + "params": { + "title": title, + "message": message, + "type": notif_type, + "sticky": False, + }, + } diff --git a/survey_certification_sending/readme/CONTRIBUTORS.rst b/survey_certification_sending/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..a926d758 --- /dev/null +++ b/survey_certification_sending/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_ + + * David Vidal + * Pilar Vargas diff --git a/survey_certification_sending/readme/DESCRIPTION.rst b/survey_certification_sending/readme/DESCRIPTION.rst new file mode 100644 index 00000000..9758a292 --- /dev/null +++ b/survey_certification_sending/readme/DESCRIPTION.rst @@ -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. diff --git a/survey_certification_sending/readme/USAGE.rst b/survey_certification_sending/readme/USAGE.rst new file mode 100644 index 00000000..4df4dd76 --- /dev/null +++ b/survey_certification_sending/readme/USAGE.rst @@ -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. diff --git a/survey_certification_sending/static/description/icon.png b/survey_certification_sending/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1dcc49c24f364e9adf0afbc6fc0bac6dbecdeb11 GIT binary patch literal 10254 zcmbt)WmufcvhH9Zc!C8B?l8#UE&&o;gF7=g3=D(IAOS+K1lK^25Zv7%L4sRw_uvvF z*qyAk?>c**=lnR&y+1yw{;I3Hy6Ua2{<d0kcR+VvBo; zA_X`>;1;xAPL9rQqFxd#f5{a^zW*uaW+r3+U{|fRunu`GZhy$X z8_|Zi{zd#vIokczl8Xh*4Wi@i0+C?Rg1AB5VOEg8B>buLFCi~r5DPd2ED7QP2>^LO zKpr7+?*I1bPaFSLLEa0l2$tj*;u8Qtc=&(RUc*VK@ zjIN{I--GfO@vl+&r^eqy_BZ3dndN_PDzMc*W^!?dIsWAWU@LBjBg6^f4F6*!-hUYh zY$Xb}gF8b0%S1Ac@c%Rs()UCiEu3v6SiFE>h_!{gBb-H2{e=wB5o!YkT0>#LKZFw$ z?CuD0Gvfsb(|XbVxx0AL0%`gG2X+6|f;jiTHU9shtjoW-{2!| zMN*WuOj6elhD4zqgjNpX>F#JP{)hAbenX<+FPr>7jXM&q{|x+pbj8cU<=>Ej zWE1_%qoFVzDAZB%g@v<+1ud%<#2E~ML11jOV5pUZoXktGmzB38%te^i-3o9i$lge>z>tBcK|P2K0H9w{l#|i%$~egM)Ys{q>p<9yaE*%v2cy1wXE{AXqG1_b znfyg@Fq*e@yC)^(@$R*j^E;skyEM6pmL$1ct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!k;&$`h8!)$uS=}d-fPddfIdMDUW@%3y1LI(1Q=e$)sz(QC*E;Nfl99YTgk+|@jl`+iF?<_D?4YqV0Zl)lO8YWC@1ZWW^mi{5ePQN<~FQ2NMG$|K{py5akJa zkezmqhN)>MGMp$7=sOo2(7ppv``dCIwf&MaQQis7S596kkiw8Do(jO?EY4iJ4Hec6 z4Hymzu`w)cI9Pbq6GPtTP)x&Lmk;FT=ZCB4>(5}c0?;2l`p&?>&<;2(P8a3lOTNP# zdEzF5qDpkRR&PZC&cS{7xD@qV;(g5X%xI?m$9Q + + + + +Survey Certification Sending + + + +
+

Survey Certification Sending

+ + +

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

+

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

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Survey > Surveys.
  2. +
  3. Create or edit a certification survey.
  4. +
  5. Configure whether you want to send certifications manually by checking the +“Skip Auto Email” option.
  6. +
  7. Participants who pass the survey will receive their certification automatically if +manual submission is not enabled.
  8. +
  9. If the automatic sending is disabled, passed certifications can be submitted manually +from the “Send certification email” action.
  10. +
  11. Certifications that have already been sent will be marked as “Certification sent”.
  12. +
  13. Passed certifications can be sent as many times as necessary.
  14. +
+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

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.

+

Current maintainer:

+

pilarvargas-tecnativa

+

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

+

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

+
+
+
+ + diff --git a/survey_certification_sending/tests/__init__.py b/survey_certification_sending/tests/__init__.py new file mode 100644 index 00000000..e2466bc3 --- /dev/null +++ b/survey_certification_sending/tests/__init__.py @@ -0,0 +1 @@ +from . import test_survey_certification_sending diff --git a/survey_certification_sending/tests/test_survey_certification_sending.py b/survey_certification_sending/tests/test_survey_certification_sending.py new file mode 100644 index 00000000..85995a16 --- /dev/null +++ b/survey_certification_sending/tests/test_survey_certification_sending.py @@ -0,0 +1,185 @@ +from odoo.tests import tagged + +from odoo.addons.survey.tests.common import TestSurveyCommon + + +@tagged("-at_install", "post_install", "functional") +class TestCertificationsending(TestSurveyCommon): + def test_certification_auto_sending(self): + test_certification = self.env["survey.survey"].create( + { + "title": "Test Certification Sending", + "access_mode": "public", + "users_login_required": True, + "questions_layout": "page_per_question", + "users_can_go_back": True, + "scoring_type": "scoring_with_answers", + "scoring_success_min": 85.0, + "certification": True, + "certification_mail_template_id": self.env.ref( + "survey.mail_template_certification" + ).id, + "is_time_limited": True, + "time_limit": 10, + } + ) + q_01 = self._add_question( + None, + "2+2", + "simple_choice", + sequence=1, + constr_mandatory=True, + constr_error_msg="Please select an answer", + survey_id=test_certification.id, + labels=[ + {"value": "2"}, + {"value": "3"}, + {"value": "4", "is_correct": True, "answer_score": 50.0}, + {"value": "5"}, + ], + ) + q_02 = self._add_question( + None, + "2x2", + "simple_choice", + sequence=2, + constr_mandatory=True, + constr_error_msg="Please select an answer", + survey_id=test_certification.id, + labels=[ + {"value": "2"}, + {"value": "3"}, + {"value": "4", "is_correct": True, "answer_score": 50.0}, + {"value": "5"}, + ], + ) + answer = self._add_answer(test_certification, self.env.user) + self._add_answer_line(q_01, answer, q_01.suggested_answer_ids[2].id) + self._add_answer_line(q_02, answer, q_02.suggested_answer_ids[2].id) + answer.with_user(self.env.user).write({"state": "done"}) + answer._mark_done() + # Verify that the certification has been sent automatically. + self.assertTrue(answer.scoring_success) + self.assertTrue(answer.certification_sent) + + def test_certification_skip_auto_sending(self): + test_certification = self.env["survey.survey"].create( + { + "title": "Test Certification Skip Auto Sending", + "access_mode": "public", + "users_login_required": True, + "questions_layout": "page_per_question", + "users_can_go_back": True, + "scoring_type": "scoring_with_answers", + "scoring_success_min": 85.0, + "certification": True, + "skip_certification_email": True, + "certification_mail_template_id": self.env.ref( + "survey.mail_template_certification" + ).id, + "is_time_limited": True, + "time_limit": 10, + } + ) + q_01 = self._add_question( + None, + "2+2", + "simple_choice", + sequence=1, + constr_mandatory=True, + constr_error_msg="Please select an answer", + survey_id=test_certification.id, + labels=[ + {"value": "2"}, + {"value": "3"}, + {"value": "4", "is_correct": True, "answer_score": 50.0}, + {"value": "5"}, + ], + ) + q_02 = self._add_question( + None, + "2x2", + "simple_choice", + sequence=2, + constr_mandatory=True, + constr_error_msg="Please select an answer", + survey_id=test_certification.id, + labels=[ + {"value": "2"}, + {"value": "3"}, + {"value": "4", "is_correct": True, "answer_score": 50.0}, + {"value": "5"}, + ], + ) + answer = self._add_answer(test_certification, self.env.user) + self._add_answer_line(q_01, answer, q_01.suggested_answer_ids[2].id) + self._add_answer_line(q_02, answer, q_02.suggested_answer_ids[2].id) + answer.with_user(self.env.user).write({"state": "done"}) + answer._mark_done() + # Verify that the certification has not been sent automatically + self.assertTrue(answer.scoring_success) + self.assertFalse(answer.certification_sent) + # Verify that the certification has been sent manually + answer.action_manual_send_certification() + self.assertTrue(answer.certification_sent) + + def test_no_passed_certification_skip_auto_sending(self): + test_certification = self.env["survey.survey"].create( + { + "title": "Test No Passed Certification Skip Auto Sending", + "access_mode": "public", + "users_login_required": True, + "questions_layout": "page_per_question", + "users_can_go_back": True, + "scoring_type": "scoring_with_answers", + "scoring_success_min": 85.0, + "certification": True, + "skip_certification_email": True, + "certification_mail_template_id": self.env.ref( + "survey.mail_template_certification" + ).id, + "is_time_limited": True, + "time_limit": 10, + } + ) + q_01 = self._add_question( + None, + "2+2", + "simple_choice", + sequence=1, + constr_mandatory=True, + constr_error_msg="Please select an answer", + survey_id=test_certification.id, + labels=[ + {"value": "2"}, + {"value": "3"}, + {"value": "4", "is_correct": True, "answer_score": 50.0}, + {"value": "5"}, + ], + ) + q_02 = self._add_question( + None, + "2x2", + "simple_choice", + sequence=2, + constr_mandatory=True, + constr_error_msg="Please select an answer", + survey_id=test_certification.id, + labels=[ + {"value": "2"}, + {"value": "3"}, + {"value": "4", "is_correct": True, "answer_score": 50.0}, + {"value": "5"}, + ], + ) + answer = self._add_answer(test_certification, self.env.user) + self._add_answer_line(q_01, answer, q_01.suggested_answer_ids[0].id) + self._add_answer_line(q_02, answer, q_02.suggested_answer_ids[3].id) + answer.with_user(self.env.user).write({"state": "done"}) + answer._mark_done() + # Verify that the certification has not been sent automatically + self.assertFalse(answer.scoring_success) + self.assertFalse(answer.certification_sent) + # Verify that the certification has not been sent manually + answer.action_manual_send_certification() + self.assertFalse(answer.certification_sent) diff --git a/survey_certification_sending/views/survey_survey_views.xml b/survey_certification_sending/views/survey_survey_views.xml new file mode 100644 index 00000000..6cd380bc --- /dev/null +++ b/survey_certification_sending/views/survey_survey_views.xml @@ -0,0 +1,15 @@ + + + + survey.survey + + + + + + + + diff --git a/survey_certification_sending/views/survey_templates.xml b/survey_certification_sending/views/survey_templates.xml new file mode 100644 index 00000000..c79ca64d --- /dev/null +++ b/survey_certification_sending/views/survey_templates.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/survey_certification_sending/views/survey_user_views.xml b/survey_certification_sending/views/survey_user_views.xml new file mode 100644 index 00000000..c6bfc101 --- /dev/null +++ b/survey_certification_sending/views/survey_user_views.xml @@ -0,0 +1,29 @@ + + + + survey.user_input + + + + + + + + + + + Send Certification Email + ir.actions.server + + code + + action = records.action_manual_send_certification() + + + list,form + + From e434423f0cbf45025ce08b0fe2ec519c2e8aa058 Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Wed, 14 May 2025 18:28:24 +0200 Subject: [PATCH 02/16] [IMP] survey_certification_sending: pre-commit auto fixes --- survey_certification_sending/README.rst | 48 ++++++++++--------- survey_certification_sending/pyproject.toml | 3 ++ .../readme/CONTRIBUTORS.md | 3 ++ .../readme/CONTRIBUTORS.rst | 4 -- .../readme/DESCRIPTION.md | 3 ++ .../readme/DESCRIPTION.rst | 2 - survey_certification_sending/readme/USAGE.md | 13 +++++ survey_certification_sending/readme/USAGE.rst | 12 ----- .../static/description/index.html | 26 +++++----- 9 files changed, 61 insertions(+), 53 deletions(-) create mode 100644 survey_certification_sending/pyproject.toml create mode 100644 survey_certification_sending/readme/CONTRIBUTORS.md delete mode 100644 survey_certification_sending/readme/CONTRIBUTORS.rst create mode 100644 survey_certification_sending/readme/DESCRIPTION.md delete mode 100644 survey_certification_sending/readme/DESCRIPTION.rst create mode 100644 survey_certification_sending/readme/USAGE.md delete mode 100644 survey_certification_sending/readme/USAGE.rst diff --git a/survey_certification_sending/README.rst b/survey_certification_sending/README.rst index 57d539bd..90ba3ce0 100644 --- a/survey_certification_sending/README.rst +++ b/survey_certification_sending/README.rst @@ -17,19 +17,20 @@ Survey Certification Sending :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 + :target: https://github.com/OCA/survey/tree/17.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 + :target: https://translation.odoo-community.org/projects/survey-17-0/survey-17-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 + :target: https://runboat.odoo-community.org/builds?repo=OCA/survey&target_branch=17.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. +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** @@ -41,16 +42,17 @@ 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. +1. Go to Survey > Surveys. +2. Create or edit a certification survey. +3. Configure whether you want to send certifications manually by + checking the "Skip Auto Email" option. +4. Participants who pass the survey will receive their certification + automatically if manual submission is not enabled. +5. If the automatic sending is disabled, passed certifications can be + submitted manually from the "Send certification email" action. +6. Certifications that have already been sent will be marked as + "Certification sent". +7. Passed certifications can be sent as many times as necessary. Bug Tracker =========== @@ -58,7 +60,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -66,20 +68,20 @@ Credits ======= Authors -~~~~~~~ +------- * Tecnativa Contributors -~~~~~~~~~~~~ +------------ -* `Tecnativa `_ +- `Tecnativa `__ - * David Vidal - * Pilar Vargas + - David Vidal + - Pilar Vargas Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -99,6 +101,6 @@ Current `maintainer `__: |maintainer-pilarvargas-tecnativa| -This module is part of the `OCA/survey `_ project on GitHub. +This module is part of the `OCA/survey `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/survey_certification_sending/pyproject.toml b/survey_certification_sending/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/survey_certification_sending/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/survey_certification_sending/readme/CONTRIBUTORS.md b/survey_certification_sending/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..68e9227d --- /dev/null +++ b/survey_certification_sending/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Tecnativa](https://www.tecnativa.com) + - David Vidal + - Pilar Vargas diff --git a/survey_certification_sending/readme/CONTRIBUTORS.rst b/survey_certification_sending/readme/CONTRIBUTORS.rst deleted file mode 100644 index a926d758..00000000 --- a/survey_certification_sending/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,4 +0,0 @@ -* `Tecnativa `_ - - * David Vidal - * Pilar Vargas diff --git a/survey_certification_sending/readme/DESCRIPTION.md b/survey_certification_sending/readme/DESCRIPTION.md new file mode 100644 index 00000000..b377912b --- /dev/null +++ b/survey_certification_sending/readme/DESCRIPTION.md @@ -0,0 +1,3 @@ +This module extends the Odoo Survey application to allow automatic and +manual sending of certifications when a participant successfully +completes a survey. diff --git a/survey_certification_sending/readme/DESCRIPTION.rst b/survey_certification_sending/readme/DESCRIPTION.rst deleted file mode 100644 index 9758a292..00000000 --- a/survey_certification_sending/readme/DESCRIPTION.rst +++ /dev/null @@ -1,2 +0,0 @@ -This module extends the Odoo Survey application to allow automatic and manual sending -of certifications when a participant successfully completes a survey. diff --git a/survey_certification_sending/readme/USAGE.md b/survey_certification_sending/readme/USAGE.md new file mode 100644 index 00000000..a5744530 --- /dev/null +++ b/survey_certification_sending/readme/USAGE.md @@ -0,0 +1,13 @@ +To use this module, you need to: + +1. Go to Survey \> Surveys. +2. Create or edit a certification survey. +3. Configure whether you want to send certifications manually by + checking the "Skip Auto Email" option. +4. Participants who pass the survey will receive their certification + automatically if manual submission is not enabled. +5. If the automatic sending is disabled, passed certifications can be + submitted manually from the "Send certification email" action. +6. Certifications that have already been sent will be marked as + "Certification sent". +7. Passed certifications can be sent as many times as necessary. diff --git a/survey_certification_sending/readme/USAGE.rst b/survey_certification_sending/readme/USAGE.rst deleted file mode 100644 index 4df4dd76..00000000 --- a/survey_certification_sending/readme/USAGE.rst +++ /dev/null @@ -1,12 +0,0 @@ -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. diff --git a/survey_certification_sending/static/description/index.html b/survey_certification_sending/static/description/index.html index e6788a71..55696ba7 100644 --- a/survey_certification_sending/static/description/index.html +++ b/survey_certification_sending/static/description/index.html @@ -369,9 +369,10 @@

Survey Certification Sending

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:8ea8829eaa6afec788b8dd41ab8bdc3a46a0f15d833bcc75a3feaccea4f1def7 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

-

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

+

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

+

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

    @@ -391,13 +392,14 @@

    Usage

    1. Go to Survey > Surveys.
    2. Create or edit a certification survey.
    3. -
    4. Configure whether you want to send certifications manually by checking the -“Skip Auto Email” option.
    5. -
    6. Participants who pass the survey will receive their certification automatically if -manual submission is not enabled.
    7. -
    8. If the automatic sending is disabled, passed certifications can be submitted manually -from the “Send certification email” action.
    9. -
    10. Certifications that have already been sent will be marked as “Certification sent”.
    11. +
    12. Configure whether you want to send certifications manually by +checking the “Skip Auto Email” option.
    13. +
    14. Participants who pass the survey will receive their certification +automatically if manual submission is not enabled.
    15. +
    16. If the automatic sending is disabled, passed certifications can be +submitted manually from the “Send certification email” action.
    17. +
    18. Certifications that have already been sent will be marked as +“Certification sent”.
    19. Passed certifications can be sent as many times as necessary.
@@ -406,7 +408,7 @@

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.

+feedback.

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

@@ -438,7 +440,7 @@

Maintainers

promote its widespread use.

Current maintainer:

pilarvargas-tecnativa

-

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

+

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

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

From e907dccdd9280b37d2593b45f9d6a03c87600bab Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Wed, 14 May 2025 18:39:53 +0200 Subject: [PATCH 03/16] [MIG] survey_certification_sending: Migration to version 17.0 TT56327 --- survey_certification_sending/__manifest__.py | 2 +- .../migrations/15.0.1.0.0/post-migration.py | 38 ------------------- .../models/mail_template.py | 4 +- .../models/survey_user_input.py | 5 ++- .../views/survey_survey_views.xml | 9 ++--- .../views/survey_user_views.xml | 2 +- 6 files changed, 10 insertions(+), 50 deletions(-) delete mode 100644 survey_certification_sending/migrations/15.0.1.0.0/post-migration.py diff --git a/survey_certification_sending/__manifest__.py b/survey_certification_sending/__manifest__.py index 6a41d1c1..70265b0c 100644 --- a/survey_certification_sending/__manifest__.py +++ b/survey_certification_sending/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Survey Certification Sending", "summary": "Controls the automatic sending of certifications in surveys.", - "version": "15.0.1.0.0", + "version": "17.0.1.0.0", "author": "Tecnativa, Odoo Community Association (OCA)", "development_status": "Beta", "category": "Marketing/Survey", diff --git a/survey_certification_sending/migrations/15.0.1.0.0/post-migration.py b/survey_certification_sending/migrations/15.0.1.0.0/post-migration.py deleted file mode 100644 index 43a2fb65..00000000 --- a/survey_certification_sending/migrations/15.0.1.0.0/post-migration.py +++ /dev/null @@ -1,38 +0,0 @@ -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}) diff --git a/survey_certification_sending/models/mail_template.py b/survey_certification_sending/models/mail_template.py index 50372ce7..b7bff695 100644 --- a/survey_certification_sending/models/mail_template.py +++ b/survey_certification_sending/models/mail_template.py @@ -12,7 +12,7 @@ def send_mail( force_send=False, raise_exception=False, email_values=None, - notif_layout=False, + email_layout_xmlid=False, ): if self.model == "survey.user_input": skip_ids = self.env.context.get("skip_certification_email_ids", []) @@ -20,5 +20,5 @@ def send_mail( if survey.id in skip_ids: return False return super().send_mail( - res_id, force_send, raise_exception, email_values, notif_layout + res_id, force_send, raise_exception, email_values, email_layout_xmlid ) diff --git a/survey_certification_sending/models/survey_user_input.py b/survey_certification_sending/models/survey_user_input.py index 73df6f45..60cdd073 100644 --- a/survey_certification_sending/models/survey_user_input.py +++ b/survey_certification_sending/models/survey_user_input.py @@ -12,7 +12,8 @@ class SurveyUserInput(models.Model): def _mark_done(self): for user_input in self: - # The response is marked as sent in anticipation that it will be sent safely. + # The response is marked as sent in anticipation that it will be sent + # safely. if ( user_input.survey_id.certification and user_input.scoring_success @@ -43,7 +44,7 @@ def action_manual_send_certification(self): 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.id, email_layout_xmlid="mail.mail_notification_light" ) user_input.certification_sent = True sent_count += 1 diff --git a/survey_certification_sending/views/survey_survey_views.xml b/survey_certification_sending/views/survey_survey_views.xml index 6cd380bc..4e408612 100644 --- a/survey_certification_sending/views/survey_survey_views.xml +++ b/survey_certification_sending/views/survey_survey_views.xml @@ -2,13 +2,10 @@ survey.survey - + - - + + diff --git a/survey_certification_sending/views/survey_user_views.xml b/survey_certification_sending/views/survey_user_views.xml index c6bfc101..70fd9555 100644 --- a/survey_certification_sending/views/survey_user_views.xml +++ b/survey_certification_sending/views/survey_user_views.xml @@ -8,7 +8,7 @@ From a8cec1abcddf07df528c8ec598d64123f02c2a94 Mon Sep 17 00:00:00 2001 From: oca-ci Date: Sat, 17 May 2025 09:27:31 +0000 Subject: [PATCH 04/16] [UPD] Update survey_certification_sending.pot --- .../i18n/survey_certification_sending.pot | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/survey_certification_sending/i18n/survey_certification_sending.pot b/survey_certification_sending/i18n/survey_certification_sending.pot index 5378b8e1..59496b89 100644 --- a/survey_certification_sending/i18n/survey_certification_sending.pot +++ b/survey_certification_sending/i18n/survey_certification_sending.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 15.0\n" +"Project-Id-Version: Odoo Server 17.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -14,12 +14,14 @@ msgstr "" "Plural-Forms: \n" #. module: survey_certification_sending +#. odoo-python #: code:addons/survey_certification_sending/models/survey_user_input.py:0 #, python-format msgid "%s certification(s) successfully sent." msgstr "" #. module: survey_certification_sending +#. odoo-python #: 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 @@ -37,6 +39,7 @@ msgid "It indicates if the certification has been sent." msgstr "" #. module: survey_certification_sending +#. odoo-python #: code:addons/survey_certification_sending/models/survey_user_input.py:0 #, python-format msgid "No Certifications Sent" @@ -70,6 +73,7 @@ msgid "Survey User Input" msgstr "" #. module: survey_certification_sending +#. odoo-python #: code:addons/survey_certification_sending/models/survey_user_input.py:0 #, python-format msgid "The survey does not meet the conditions." From f1cb8f1932b5c38f429d65eaefd6fb0d481b208d Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Sat, 17 May 2025 09:32:35 +0000 Subject: [PATCH 05/16] [BOT] post-merge updates --- survey_certification_sending/README.rst | 8 ++++---- .../static/description/index.html | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/survey_certification_sending/README.rst b/survey_certification_sending/README.rst index 90ba3ce0..14512968 100644 --- a/survey_certification_sending/README.rst +++ b/survey_certification_sending/README.rst @@ -7,7 +7,7 @@ Survey Certification Sending !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:8ea8829eaa6afec788b8dd41ab8bdc3a46a0f15d833bcc75a3feaccea4f1def7 + !! source digest: sha256:f0bf5bcff450d9457f8148b239d9a362b6c34d3600e37e125f7f800a5854b0b5 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -75,10 +75,10 @@ Authors Contributors ------------ -- `Tecnativa `__ +- `Tecnativa `__ - - David Vidal - - Pilar Vargas + - David Vidal + - Pilar Vargas Maintainers ----------- diff --git a/survey_certification_sending/static/description/index.html b/survey_certification_sending/static/description/index.html index 55696ba7..828c6c3a 100644 --- a/survey_certification_sending/static/description/index.html +++ b/survey_certification_sending/static/description/index.html @@ -367,7 +367,7 @@

Survey Certification Sending

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:8ea8829eaa6afec788b8dd41ab8bdc3a46a0f15d833bcc75a3feaccea4f1def7 +!! source digest: sha256:f0bf5bcff450d9457f8148b239d9a362b6c34d3600e37e125f7f800a5854b0b5 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

This module extends the Odoo Survey application to allow automatic and From ca4317b377f206382a154a6961afd685da9a3b3a Mon Sep 17 00:00:00 2001 From: mymage Date: Sun, 18 May 2025 06:47:02 +0000 Subject: [PATCH 06/16] Added translation using Weblate (Italian) --- survey_certification_sending/i18n/it.po | 81 +++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 survey_certification_sending/i18n/it.po diff --git a/survey_certification_sending/i18n/it.po b/survey_certification_sending/i18n/it.po new file mode 100644 index 00000000..a9a77a8d --- /dev/null +++ b/survey_certification_sending/i18n/it.po @@ -0,0 +1,81 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_certification_sending +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\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" + +#. module: survey_certification_sending +#. odoo-python +#: code:addons/survey_certification_sending/models/survey_user_input.py:0 +#, python-format +msgid "%s certification(s) successfully sent." +msgstr "" + +#. module: survey_certification_sending +#. odoo-python +#: 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 +#. odoo-python +#: 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 +#. odoo-python +#: code:addons/survey_certification_sending/models/survey_user_input.py:0 +#, python-format +msgid "The survey does not meet the conditions." +msgstr "" From b43ef2baa618e1b53e8a7e365a157b6f10bcdbaa Mon Sep 17 00:00:00 2001 From: mymage Date: Sun, 18 May 2025 06:49:15 +0000 Subject: [PATCH 07/16] Translated using Weblate (Italian) Currently translated at 100.0% (11 of 11 strings) Translation: survey-17.0/survey-17.0-survey_certification_sending Translate-URL: https://translation.odoo-community.org/projects/survey-17-0/survey-17-0-survey_certification_sending/it/ --- survey_certification_sending/i18n/it.po | 26 ++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/survey_certification_sending/i18n/it.po b/survey_certification_sending/i18n/it.po index a9a77a8d..8c86bc91 100644 --- a/survey_certification_sending/i18n/it.po +++ b/survey_certification_sending/i18n/it.po @@ -6,20 +6,22 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 17.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2025-05-18 09:27+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 5.10.4\n" #. module: survey_certification_sending #. odoo-python #: code:addons/survey_certification_sending/models/survey_user_input.py:0 #, python-format msgid "%s certification(s) successfully sent." -msgstr "" +msgstr "%s certificazioni spedite correttamente." #. module: survey_certification_sending #. odoo-python @@ -27,34 +29,34 @@ msgstr "" #: model:ir.model.fields,field_description:survey_certification_sending.field_survey_user_input__certification_sent #, python-format msgid "Certification Sent" -msgstr "" +msgstr "Certificazione spedita" #. module: survey_certification_sending #: model:ir.model,name:survey_certification_sending.model_mail_template msgid "Email Templates" -msgstr "" +msgstr "Modelli e-mail" #. 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 "" +msgstr "Indica se la certificazione è stata spedita." #. module: survey_certification_sending #. odoo-python #: code:addons/survey_certification_sending/models/survey_user_input.py:0 #, python-format msgid "No Certifications Sent" -msgstr "" +msgstr "Nessuna certificazione spedita" #. module: survey_certification_sending #: model:ir.actions.server,name:survey_certification_sending.ir_actions_server_send_certification msgid "Send Certification Email" -msgstr "" +msgstr "Invia e-mail certificazione" #. module: survey_certification_sending #: model:ir.model.fields,field_description:survey_certification_sending.field_survey_survey__skip_certification_email msgid "Skip Certification Email" -msgstr "" +msgstr "Salta e-mail certificazione" #. module: survey_certification_sending #: model:ir.model.fields,help:survey_certification_sending.field_survey_survey__skip_certification_email @@ -62,20 +64,22 @@ msgid "" "Skip sending the certification automatically after successful completion of " "the survey." msgstr "" +"Evita di inviare automaticamente la certificazione al completamento corretto " +"del sondaggio." #. module: survey_certification_sending #: model:ir.model,name:survey_certification_sending.model_survey_survey msgid "Survey" -msgstr "" +msgstr "Sondaggio" #. module: survey_certification_sending #: model:ir.model,name:survey_certification_sending.model_survey_user_input msgid "Survey User Input" -msgstr "" +msgstr "Risposta utente al sondaggio" #. module: survey_certification_sending #. odoo-python #: code:addons/survey_certification_sending/models/survey_user_input.py:0 #, python-format msgid "The survey does not meet the conditions." -msgstr "" +msgstr "Il sondaggio non soddisfa le condizioni." From 02dfc63b3202d49bfbf8191b9d1a3bbbfdc88856 Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Mon, 26 May 2025 11:20:13 +0200 Subject: [PATCH 08/16] [IMP] survey_certification_sending: authorise certificate download at contact level TT56428 --- survey_certification_sending/README.rst | 6 +- survey_certification_sending/__manifest__.py | 1 + .../models/__init__.py | 1 + .../models/mail_template.py | 8 ++- .../models/res_partner.py | 12 ++++ .../models/survey_user_input.py | 11 +--- .../test_survey_certification_sending.py | 63 +++++++++++++++++++ .../views/res_partner_views.xml | 16 +++++ .../views/survey_templates.xml | 2 +- 9 files changed, 104 insertions(+), 16 deletions(-) create mode 100644 survey_certification_sending/models/res_partner.py create mode 100644 survey_certification_sending/views/res_partner_views.xml diff --git a/survey_certification_sending/README.rst b/survey_certification_sending/README.rst index 14512968..2897a8d1 100644 --- a/survey_certification_sending/README.rst +++ b/survey_certification_sending/README.rst @@ -75,10 +75,10 @@ Authors Contributors ------------ -- `Tecnativa `__ +- `Tecnativa `__ - - David Vidal - - Pilar Vargas + - David Vidal + - Pilar Vargas Maintainers ----------- diff --git a/survey_certification_sending/__manifest__.py b/survey_certification_sending/__manifest__.py index 70265b0c..b5e1d388 100644 --- a/survey_certification_sending/__manifest__.py +++ b/survey_certification_sending/__manifest__.py @@ -12,6 +12,7 @@ "license": "AGPL-3", "depends": ["survey"], "data": [ + "views/res_partner_views.xml", "views/survey_survey_views.xml", "views/survey_templates.xml", "views/survey_user_views.xml", diff --git a/survey_certification_sending/models/__init__.py b/survey_certification_sending/models/__init__.py index 2cff3554..53cdf28a 100644 --- a/survey_certification_sending/models/__init__.py +++ b/survey_certification_sending/models/__init__.py @@ -1,3 +1,4 @@ from . import mail_template +from . import res_partner from . import survey_survey from . import survey_user_input diff --git a/survey_certification_sending/models/mail_template.py b/survey_certification_sending/models/mail_template.py index b7bff695..5b943488 100644 --- a/survey_certification_sending/models/mail_template.py +++ b/survey_certification_sending/models/mail_template.py @@ -15,9 +15,11 @@ def send_mail( email_layout_xmlid=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: + survey_input = self.env["survey.user_input"].browse(res_id) + if ( + survey_input.survey_id.skip_certification_email + or survey_input.partner_id.skip_certification_email + ): return False return super().send_mail( res_id, force_send, raise_exception, email_values, email_layout_xmlid diff --git a/survey_certification_sending/models/res_partner.py b/survey_certification_sending/models/res_partner.py new file mode 100644 index 00000000..17f1358a --- /dev/null +++ b/survey_certification_sending/models/res_partner.py @@ -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 = "res.partner" + + skip_certification_email = fields.Boolean( + help="Skip sending the certification automatically after successful completion " + "of the survey." + ) diff --git a/survey_certification_sending/models/survey_user_input.py b/survey_certification_sending/models/survey_user_input.py index 60cdd073..058f19a2 100644 --- a/survey_certification_sending/models/survey_user_input.py +++ b/survey_certification_sending/models/survey_user_input.py @@ -18,19 +18,12 @@ def _mark_done(self): user_input.survey_id.certification and user_input.scoring_success and not user_input.survey_id.skip_certification_email + and not user_input.partner_id.skip_certification_email and user_input.survey_id.certification_mail_template_id and not user_input.test_entry ): user_input.certification_sent = True - # Add ids of surveys that have to skip automatic sending to the context - return super( - SurveyUserInput, - self.with_context( - skip_certification_email_ids=self.mapped("survey_id") - .filtered(lambda s: s.skip_certification_email) - .ids - ), - )._mark_done() + return super()._mark_done() def action_manual_send_certification(self): # Send certifications manually only to those who passed the survey. diff --git a/survey_certification_sending/tests/test_survey_certification_sending.py b/survey_certification_sending/tests/test_survey_certification_sending.py index 85995a16..526bd7bc 100644 --- a/survey_certification_sending/tests/test_survey_certification_sending.py +++ b/survey_certification_sending/tests/test_survey_certification_sending.py @@ -183,3 +183,66 @@ def test_no_passed_certification_skip_auto_sending(self): # Verify that the certification has not been sent manually answer.action_manual_send_certification() self.assertFalse(answer.certification_sent) + + def test_certification_partner_skip_auto_sending(self): + test_certification = self.env["survey.survey"].create( + { + "title": "Test Partner Skip Auto Sending", + "access_mode": "public", + "users_login_required": True, + "questions_layout": "page_per_question", + "users_can_go_back": True, + "scoring_type": "scoring_with_answers", + "scoring_success_min": 85.0, + "certification": True, + "certification_mail_template_id": self.env.ref( + "survey.mail_template_certification" + ).id, + "is_time_limited": True, + "time_limit": 10, + } + ) + q_01 = self._add_question( + None, + "2+2", + "simple_choice", + sequence=1, + constr_mandatory=True, + constr_error_msg="Please select an answer", + survey_id=test_certification.id, + labels=[ + {"value": "2"}, + {"value": "3"}, + {"value": "4", "is_correct": True, "answer_score": 50.0}, + {"value": "5"}, + ], + ) + q_02 = self._add_question( + None, + "2x2", + "simple_choice", + sequence=2, + constr_mandatory=True, + constr_error_msg="Please select an answer", + survey_id=test_certification.id, + labels=[ + {"value": "2"}, + {"value": "3"}, + {"value": "4", "is_correct": True, "answer_score": 50.0}, + {"value": "5"}, + ], + ) + answer = self._add_answer(test_certification, self.env.user) + self._add_answer_line(q_01, answer, q_01.suggested_answer_ids[2].id) + self._add_answer_line(q_02, answer, q_02.suggested_answer_ids[2].id) + # Set on answer.partner_id to ensure it applies to the actual partner + # used in the test + answer.partner_id.write({"skip_certification_email": True}) + answer.with_user(self.env.user).write({"state": "done"}) + answer._mark_done() + # Verify that the certification has not been sent automatically + self.assertTrue(answer.scoring_success) + self.assertFalse(answer.certification_sent) + # Verify that the certification has been sent manually + answer.action_manual_send_certification() + self.assertTrue(answer.certification_sent) diff --git a/survey_certification_sending/views/res_partner_views.xml b/survey_certification_sending/views/res_partner_views.xml new file mode 100644 index 00000000..1d339f1a --- /dev/null +++ b/survey_certification_sending/views/res_partner_views.xml @@ -0,0 +1,16 @@ + + + + res.partner.form.view + res.partner + + + + + + + + diff --git a/survey_certification_sending/views/survey_templates.xml b/survey_certification_sending/views/survey_templates.xml index c79ca64d..602b16a1 100644 --- a/survey_certification_sending/views/survey_templates.xml +++ b/survey_certification_sending/views/survey_templates.xml @@ -9,7 +9,7 @@ > survey.certification and not survey.skip_certification_email + >survey.certification and (not survey.skip_certification_email and not answer.partner_id.skip_certification_email) From 291ca0ba5994b52d187d2768e5d98fcef8919fd3 Mon Sep 17 00:00:00 2001 From: oca-ci Date: Wed, 28 May 2025 17:32:01 +0000 Subject: [PATCH 09/16] [UPD] Update survey_certification_sending.pot --- .../i18n/survey_certification_sending.pot | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/survey_certification_sending/i18n/survey_certification_sending.pot b/survey_certification_sending/i18n/survey_certification_sending.pot index 59496b89..abbb8e68 100644 --- a/survey_certification_sending/i18n/survey_certification_sending.pot +++ b/survey_certification_sending/i18n/survey_certification_sending.pot @@ -28,6 +28,11 @@ msgstr "" msgid "Certification Sent" msgstr "" +#. module: survey_certification_sending +#: model:ir.model,name:survey_certification_sending.model_res_partner +msgid "Contact" +msgstr "" + #. module: survey_certification_sending #: model:ir.model,name:survey_certification_sending.model_mail_template msgid "Email Templates" @@ -51,11 +56,15 @@ msgid "Send Certification Email" msgstr "" #. module: survey_certification_sending +#: model:ir.model.fields,field_description:survey_certification_sending.field_res_partner__skip_certification_email +#: model:ir.model.fields,field_description:survey_certification_sending.field_res_users__skip_certification_email #: 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_res_partner__skip_certification_email +#: model:ir.model.fields,help:survey_certification_sending.field_res_users__skip_certification_email #: model:ir.model.fields,help:survey_certification_sending.field_survey_survey__skip_certification_email msgid "" "Skip sending the certification automatically after successful completion of " From 5a3cbfd88ff82fafe0320a1fb1fba4d037c962c1 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 28 May 2025 17:37:31 +0000 Subject: [PATCH 10/16] [BOT] post-merge updates --- survey_certification_sending/README.rst | 8 ++++---- survey_certification_sending/__manifest__.py | 2 +- .../static/description/index.html | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/survey_certification_sending/README.rst b/survey_certification_sending/README.rst index 2897a8d1..0753acf9 100644 --- a/survey_certification_sending/README.rst +++ b/survey_certification_sending/README.rst @@ -7,7 +7,7 @@ Survey Certification Sending !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:f0bf5bcff450d9457f8148b239d9a362b6c34d3600e37e125f7f800a5854b0b5 + !! source digest: sha256:c5f109a08427b3d4f7164cea5270e751d710901ab2c9cfaf54f8ec485bcc9547 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -75,10 +75,10 @@ Authors Contributors ------------ -- `Tecnativa `__ +- `Tecnativa `__ - - David Vidal - - Pilar Vargas + - David Vidal + - Pilar Vargas Maintainers ----------- diff --git a/survey_certification_sending/__manifest__.py b/survey_certification_sending/__manifest__.py index b5e1d388..7f72d2a4 100644 --- a/survey_certification_sending/__manifest__.py +++ b/survey_certification_sending/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Survey Certification Sending", "summary": "Controls the automatic sending of certifications in surveys.", - "version": "17.0.1.0.0", + "version": "17.0.1.1.0", "author": "Tecnativa, Odoo Community Association (OCA)", "development_status": "Beta", "category": "Marketing/Survey", diff --git a/survey_certification_sending/static/description/index.html b/survey_certification_sending/static/description/index.html index 828c6c3a..f7691c27 100644 --- a/survey_certification_sending/static/description/index.html +++ b/survey_certification_sending/static/description/index.html @@ -367,7 +367,7 @@

Survey Certification Sending

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:f0bf5bcff450d9457f8148b239d9a362b6c34d3600e37e125f7f800a5854b0b5 +!! source digest: sha256:c5f109a08427b3d4f7164cea5270e751d710901ab2c9cfaf54f8ec485bcc9547 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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

This module extends the Odoo Survey application to allow automatic and From da4c814935d3aa69170c343e2b891ec4245590ac Mon Sep 17 00:00:00 2001 From: Weblate Date: Wed, 28 May 2025 17:37:40 +0000 Subject: [PATCH 11/16] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: survey-17.0/survey-17.0-survey_certification_sending Translate-URL: https://translation.odoo-community.org/projects/survey-17-0/survey-17-0-survey_certification_sending/ --- survey_certification_sending/i18n/es.po | 13 +++++++++++++ survey_certification_sending/i18n/it.po | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/survey_certification_sending/i18n/es.po b/survey_certification_sending/i18n/es.po index 4fd310db..5daab8ac 100644 --- a/survey_certification_sending/i18n/es.po +++ b/survey_certification_sending/i18n/es.po @@ -18,18 +18,25 @@ msgstr "" "X-Generator: Poedit 3.4.2\n" #. module: survey_certification_sending +#. odoo-python #: 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 +#. odoo-python #: 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_res_partner +msgid "Contact" +msgstr "" + #. module: survey_certification_sending #: model:ir.model,name:survey_certification_sending.model_mail_template msgid "Email Templates" @@ -41,6 +48,7 @@ msgid "It indicates if the certification has been sent." msgstr "Indica si la certificación ha sido enviada." #. module: survey_certification_sending +#. odoo-python #: code:addons/survey_certification_sending/models/survey_user_input.py:0 #, python-format msgid "No Certifications Sent" @@ -52,11 +60,15 @@ 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_res_partner__skip_certification_email +#: model:ir.model.fields,field_description:survey_certification_sending.field_res_users__skip_certification_email #: 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_res_partner__skip_certification_email +#: model:ir.model.fields,help:survey_certification_sending.field_res_users__skip_certification_email #: model:ir.model.fields,help:survey_certification_sending.field_survey_survey__skip_certification_email msgid "" "Skip sending the certification automatically after successful completion of " @@ -76,6 +88,7 @@ msgid "Survey User Input" msgstr "" #. module: survey_certification_sending +#. odoo-python #: code:addons/survey_certification_sending/models/survey_user_input.py:0 #, python-format msgid "The survey does not meet the conditions." diff --git a/survey_certification_sending/i18n/it.po b/survey_certification_sending/i18n/it.po index 8c86bc91..2065ac64 100644 --- a/survey_certification_sending/i18n/it.po +++ b/survey_certification_sending/i18n/it.po @@ -31,6 +31,11 @@ msgstr "%s certificazioni spedite correttamente." msgid "Certification Sent" msgstr "Certificazione spedita" +#. module: survey_certification_sending +#: model:ir.model,name:survey_certification_sending.model_res_partner +msgid "Contact" +msgstr "" + #. module: survey_certification_sending #: model:ir.model,name:survey_certification_sending.model_mail_template msgid "Email Templates" @@ -54,11 +59,15 @@ msgid "Send Certification Email" msgstr "Invia e-mail certificazione" #. module: survey_certification_sending +#: model:ir.model.fields,field_description:survey_certification_sending.field_res_partner__skip_certification_email +#: model:ir.model.fields,field_description:survey_certification_sending.field_res_users__skip_certification_email #: model:ir.model.fields,field_description:survey_certification_sending.field_survey_survey__skip_certification_email msgid "Skip Certification Email" msgstr "Salta e-mail certificazione" #. module: survey_certification_sending +#: model:ir.model.fields,help:survey_certification_sending.field_res_partner__skip_certification_email +#: model:ir.model.fields,help:survey_certification_sending.field_res_users__skip_certification_email #: model:ir.model.fields,help:survey_certification_sending.field_survey_survey__skip_certification_email msgid "" "Skip sending the certification automatically after successful completion of " From d114702eff4f4f6328041479db1b18d237e3a892 Mon Sep 17 00:00:00 2001 From: mymage Date: Thu, 29 May 2025 07:49:58 +0000 Subject: [PATCH 12/16] Translated using Weblate (Italian) Currently translated at 100.0% (12 of 12 strings) Translation: survey-17.0/survey-17.0-survey_certification_sending Translate-URL: https://translation.odoo-community.org/projects/survey-17-0/survey-17-0-survey_certification_sending/it/ --- survey_certification_sending/i18n/it.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/survey_certification_sending/i18n/it.po b/survey_certification_sending/i18n/it.po index 2065ac64..b0dce44e 100644 --- a/survey_certification_sending/i18n/it.po +++ b/survey_certification_sending/i18n/it.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 17.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2025-05-18 09:27+0000\n" +"PO-Revision-Date: 2025-05-29 10:26+0000\n" "Last-Translator: mymage \n" "Language-Team: none\n" "Language: it\n" @@ -34,7 +34,7 @@ msgstr "Certificazione spedita" #. module: survey_certification_sending #: model:ir.model,name:survey_certification_sending.model_res_partner msgid "Contact" -msgstr "" +msgstr "Contatto" #. module: survey_certification_sending #: model:ir.model,name:survey_certification_sending.model_mail_template From 7850b2e9ef0707e5d0850c1147989d36935f5b7d Mon Sep 17 00:00:00 2001 From: Laya Rabasa Date: Wed, 17 Jun 2026 10:45:21 +0000 Subject: [PATCH 13/16] [MIG] survey_certification_sending: Migration to 18.0 --- survey_certification_sending/README.rst | 12 ++++++------ survey_certification_sending/__manifest__.py | 2 +- .../static/description/index.html | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/survey_certification_sending/README.rst b/survey_certification_sending/README.rst index 0753acf9..15530516 100644 --- a/survey_certification_sending/README.rst +++ b/survey_certification_sending/README.rst @@ -7,7 +7,7 @@ Survey Certification Sending !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:c5f109a08427b3d4f7164cea5270e751d710901ab2c9cfaf54f8ec485bcc9547 + !! source digest: sha256:f65da06bc4263b39b955284f983d99eece46675b15b14d82fa35db2528e31372 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -17,13 +17,13 @@ Survey Certification Sending :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/17.0/survey_certification_sending + :target: https://github.com/OCA/survey/tree/18.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-17-0/survey-17-0-survey_certification_sending + :target: https://translation.odoo-community.org/projects/survey-18-0/survey-18-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=17.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/survey&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -60,7 +60,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -101,6 +101,6 @@ Current `maintainer `__: |maintainer-pilarvargas-tecnativa| -This module is part of the `OCA/survey `_ project on GitHub. +This module is part of the `OCA/survey `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/survey_certification_sending/__manifest__.py b/survey_certification_sending/__manifest__.py index 7f72d2a4..f4850d61 100644 --- a/survey_certification_sending/__manifest__.py +++ b/survey_certification_sending/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Survey Certification Sending", "summary": "Controls the automatic sending of certifications in surveys.", - "version": "17.0.1.1.0", + "version": "18.0.1.0.0", "author": "Tecnativa, Odoo Community Association (OCA)", "development_status": "Beta", "category": "Marketing/Survey", diff --git a/survey_certification_sending/static/description/index.html b/survey_certification_sending/static/description/index.html index f7691c27..5c298cbd 100644 --- a/survey_certification_sending/static/description/index.html +++ b/survey_certification_sending/static/description/index.html @@ -367,9 +367,9 @@

Survey Certification Sending

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:c5f109a08427b3d4f7164cea5270e751d710901ab2c9cfaf54f8ec485bcc9547 +!! source digest: sha256:f65da06bc4263b39b955284f983d99eece46675b15b14d82fa35db2528e31372 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

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

@@ -408,7 +408,7 @@

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.

+feedback.

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

@@ -440,7 +440,7 @@

Maintainers

promote its widespread use.

Current maintainer:

pilarvargas-tecnativa

-

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

+

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

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

From 3260b6a7b5aa95be9d5dcbff2b76f19638d24b52 Mon Sep 17 00:00:00 2001 From: Laya Rabasa Date: Thu, 18 Jun 2026 11:54:17 +0000 Subject: [PATCH 14/16] [IMP] survey_certification_sending: improve test coverage for mail_template and survey_user_input Add 7 new tests covering previously uncovered branches in: - models/mail_template.py: send_mail skip logic (survey-level, partner-level, and no-skip paths) - models/survey_user_input.py: _mark_done branches (test_entry, no template) and action_manual_send_certification return notifications (success/warning) --- .../test_survey_certification_sending.py | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/survey_certification_sending/tests/test_survey_certification_sending.py b/survey_certification_sending/tests/test_survey_certification_sending.py index 526bd7bc..5c77b633 100644 --- a/survey_certification_sending/tests/test_survey_certification_sending.py +++ b/survey_certification_sending/tests/test_survey_certification_sending.py @@ -1,3 +1,7 @@ +# Copyright 2022 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from unittest.mock import patch + from odoo.tests import tagged from odoo.addons.survey.tests.common import TestSurveyCommon @@ -246,3 +250,114 @@ def test_certification_partner_skip_auto_sending(self): # Verify that the certification has been sent manually answer.action_manual_send_certification() self.assertTrue(answer.certification_sent) + + # --- shared helper --- + + def _make_passing_certification(self, title, extra_vals=None): + vals = { + "title": title, + "access_mode": "public", + "users_login_required": True, + "questions_layout": "page_per_question", + "users_can_go_back": True, + "scoring_type": "scoring_with_answers", + "scoring_success_min": 85.0, + "certification": True, + "certification_mail_template_id": self.env.ref( + "survey.mail_template_certification" + ).id, + } + if extra_vals: + vals.update(extra_vals) + survey = self.env["survey.survey"].create(vals) + q = self._add_question( + None, + "1+1", + "simple_choice", + sequence=1, + constr_mandatory=True, + constr_error_msg="Please select an answer", + survey_id=survey.id, + labels=[ + {"value": "1"}, + {"value": "2", "is_correct": True, "answer_score": 100.0}, + ], + ) + return survey, q + + # --- survey_user_input.py coverage --- + + def test_mark_done_test_entry_skips_certification(self): + survey, q = self._make_passing_certification("Test Entry No Cert") + answer = self._add_answer(survey, self.env.user) + self._add_answer_line(q, answer, q.suggested_answer_ids[1].id) + answer.write({"test_entry": True, "state": "done"}) + answer._mark_done() + self.assertTrue(answer.scoring_success) + self.assertFalse(answer.certification_sent) + + def test_mark_done_no_template_skips_certification(self): + survey, q = self._make_passing_certification( + "No Template No Cert", + extra_vals={"certification_mail_template_id": False}, + ) + answer = self._add_answer(survey, self.env.user) + self._add_answer_line(q, answer, q.suggested_answer_ids[1].id) + answer.write({"state": "done"}) + answer._mark_done() + self.assertTrue(answer.scoring_success) + self.assertFalse(answer.certification_sent) + + def test_manual_send_success_notification(self): + survey, q = self._make_passing_certification( + "Manual Send Success", extra_vals={"skip_certification_email": True} + ) + answer = self._add_answer(survey, self.env.user) + self._add_answer_line(q, answer, q.suggested_answer_ids[1].id) + answer.write({"state": "done"}) + answer._mark_done() + result = answer.action_manual_send_certification() + self.assertEqual(result["type"], "ir.actions.client") + self.assertEqual(result["params"]["type"], "success") + self.assertTrue(answer.certification_sent) + + def test_manual_send_warning_when_not_passed(self): + survey, q = self._make_passing_certification("Manual Send Warning") + answer = self._add_answer(survey, self.env.user) + self._add_answer_line(q, answer, q.suggested_answer_ids[0].id) + answer.write({"state": "done"}) + answer._mark_done() + result = answer.action_manual_send_certification() + self.assertEqual(result["type"], "ir.actions.client") + self.assertEqual(result["params"]["type"], "warning") + self.assertFalse(answer.certification_sent) + + # --- mail_template.py coverage --- + + def test_send_mail_returns_false_when_survey_skip(self): + survey, _q = self._make_passing_certification( + "Send Mail Survey Skip", + extra_vals={"skip_certification_email": True}, + ) + answer = self._add_answer(survey, self.env.user) + template = self.env.ref("survey.mail_template_certification") + self.assertFalse(template.send_mail(answer.id)) + + def test_send_mail_returns_false_when_partner_skip(self): + survey, _q = self._make_passing_certification("Send Mail Partner Skip") + answer = self._add_answer(survey, self.env.user) + answer.partner_id.write({"skip_certification_email": True}) + template = self.env.ref("survey.mail_template_certification") + self.assertFalse(template.send_mail(answer.id)) + + def test_send_mail_proceeds_when_no_skip(self): + survey, _q = self._make_passing_certification("Send Mail Proceeds") + answer = self._add_answer(survey, self.env.user) + template = self.env.ref("survey.mail_template_certification") + with patch( + "odoo.addons.mail.models.mail_template.MailTemplate.send_mail", + return_value=True, + ) as mock_send: + result = template.send_mail(answer.id) + mock_send.assert_called_once() + self.assertTrue(result) From f9b10463973fdaa7389152c0113447827d1245fd Mon Sep 17 00:00:00 2001 From: Laya Rabasa Date: Thu, 18 Jun 2026 12:37:12 +0000 Subject: [PATCH 15/16] [IMP] survey_certification_sending: improve code coverage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add test for action_manual_send_certification when answer passes but certification_mail_template_id is unset — inner if template: block is skipped, sent_count stays 0, warning notification is returned. --- .../tests/test_survey_certification_sending.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/survey_certification_sending/tests/test_survey_certification_sending.py b/survey_certification_sending/tests/test_survey_certification_sending.py index 5c77b633..cf0ecda3 100644 --- a/survey_certification_sending/tests/test_survey_certification_sending.py +++ b/survey_certification_sending/tests/test_survey_certification_sending.py @@ -332,6 +332,21 @@ def test_manual_send_warning_when_not_passed(self): self.assertEqual(result["params"]["type"], "warning") self.assertFalse(answer.certification_sent) + def test_manual_send_no_template_returns_warning(self): + # covers: if template: False branch — answer passed but no template set + survey, q = self._make_passing_certification( + "Manual Send No Template", + extra_vals={"certification_mail_template_id": False}, + ) + answer = self._add_answer(survey, self.env.user) + self._add_answer_line(q, answer, q.suggested_answer_ids[1].id) + answer.write({"state": "done"}) + answer._mark_done() + result = answer.action_manual_send_certification() + self.assertEqual(result["type"], "ir.actions.client") + self.assertEqual(result["params"]["type"], "warning") + self.assertFalse(answer.certification_sent) + # --- mail_template.py coverage --- def test_send_mail_returns_false_when_survey_skip(self): From cdf3af2def00f64314dd2bdd4eb55744a44eb987 Mon Sep 17 00:00:00 2001 From: Laya Rabasa Date: Thu, 18 Jun 2026 14:37:41 +0000 Subject: [PATCH 16/16] [IMP] survey_certification_sending: cover send_mail guard for non-survey models The module overrides send_mail on all mail.template records. The guard "if self.model == 'survey.user_input'" ensures skip logic never affects templates for other models. Add test to cover the False branch of that guard and prove the override is transparent to non-survey templates. --- .../test_survey_certification_sending.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/survey_certification_sending/tests/test_survey_certification_sending.py b/survey_certification_sending/tests/test_survey_certification_sending.py index cf0ecda3..883ace94 100644 --- a/survey_certification_sending/tests/test_survey_certification_sending.py +++ b/survey_certification_sending/tests/test_survey_certification_sending.py @@ -349,6 +349,30 @@ def test_manual_send_no_template_returns_warning(self): # --- mail_template.py coverage --- + def test_send_mail_non_survey_model_calls_super(self): + # This module overrides send_mail on ALL mail.template records. + # The guard "if self.model == 'survey.user_input'" ensures the skip + # logic never interferes with templates for other models. + # This test covers the False branch of that guard. + model_id = ( + self.env["ir.model"].search([("model", "=", "res.partner")], limit=1).id + ) + partner_template = self.env["mail.template"].create( + { + "name": "Test Non Survey Template", + "model_id": model_id, + "subject": "Test", + "body_html": "

Test

", + } + ) + with patch( + "odoo.addons.mail.models.mail_template.MailTemplate.send_mail", + return_value=True, + ) as mock_send: + result = partner_template.send_mail(self.env.user.partner_id.id) + mock_send.assert_called_once() + self.assertTrue(result) + def test_send_mail_returns_false_when_survey_skip(self): survey, _q = self._make_passing_certification( "Send Mail Survey Skip",