Skip to content
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
88 changes: 88 additions & 0 deletions website_sale_slides_survey_multi_qty/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
====================================
Website Sale Slides Survey Multi Qty
====================================

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

.. |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%2Fe--learning-lightgray.png?logo=github
:target: https://github.com/OCA/e-learning/tree/17.0/website_sale_slides_survey_multi_qty
:alt: OCA/e-learning
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/e-learning-17-0/e-learning-17-0-website_sale_slides_survey_multi_qty
: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/e-learning&target_branch=17.0
:alt: Try me on Runboat

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



**Table of contents**

.. contents::
:local:

Configuration
=============



Usage
=====



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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-learning/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/e-learning/issues/new?body=module:%20website_sale_slides_survey_multi_qty%0Aversion:%2017.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/):

- 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.

This module is part of the `OCA/e-learning <https://github.com/OCA/e-learning/tree/17.0/website_sale_slides_survey_multi_qty>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions website_sale_slides_survey_multi_qty/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import controllers
from . import models
21 changes: 21 additions & 0 deletions website_sale_slides_survey_multi_qty/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Website Sale Slides Survey Multi Qty",
"version": "17.0.1.0.0",
"category": "Website/eLearning",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/e-learning",
"license": "AGPL-3",
"depends": ["website_sale_slides_multi_qty", "website_slides_survey"],
"data": [
"report/survey_templates.xml",
"views/survey_templates.xml",
"views/survey_user_views.xml",
],
"assets": {
"web.assets_frontend": [
"website_sale_slides_survey_multi_qty/static/src/xml/website_slides_fullscreen.xml",
],
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import slides
25 changes: 25 additions & 0 deletions website_sale_slides_survey_multi_qty/controllers/slides.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import http
from odoo.http import request

from odoo.addons.website_slides_survey.controllers.slides import WebsiteSlidesSurvey


class WebsiteSlidesSurvey(WebsiteSlidesSurvey):
@http.route(
["/slides_survey/slide/get_certification_url"],
type="http",
auth="public",
website=True,
)
def slide_get_certification_url(self, slide_id, **kw):
invite_hash = request.session.get("invite_hash", False)
identification_number = (request.session.get("identification_number", False),)
invite_partner_id = request.session.get("invite_partner_id", False)
res = super().slide_get_certification_url(slide_id=slide_id, **kw)
if request.env.user._is_public() and not (
identification_number and invite_partner_id and invite_hash
):
return request.redirect("/web/login")
return res
2 changes: 2 additions & 0 deletions website_sale_slides_survey_multi_qty/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import slide_slide
from . import survey_user
65 changes: 65 additions & 0 deletions website_sale_slides_survey_multi_qty/models/slide_slide.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class Slide(models.Model):
_inherit = "slide.slide"

def _generate_certification_url(self):
self = self.sudo()
certifications_with_key = self.filtered(
lambda slide: slide.slide_category == "certification"
and slide.survey_id
and slide.user_membership_id
and slide.user_membership_id.identification_number
)
certifications = self - certifications_with_key
certification_urls = {}
if certifications:
certification_urls.update(
super(Slide, certifications)._generate_certification_url()
)
for slide in certifications_with_key:
if slide.channel_id.is_member:
user_membership_id_sudo = slide.user_membership_id.sudo()
channel_partner = slide.channel_id.channel_partner_ids.filtered(
lambda cp,
user_membership_id_sudo=user_membership_id_sudo,
slide=slide: cp.partner_id.id
== user_membership_id_sudo.partner_id.id
and cp.identification_number
== slide.user_membership_id.identification_number
)[:1]
if user_membership_id_sudo.user_input_ids:
last_user_input = next(
user_input
for user_input in user_membership_id_sudo.user_input_ids.sorted(
lambda user_input: user_input.create_date, reverse=True
)
)
certification_urls[slide.id] = last_user_input.get_start_url()
else:
user_input = slide.survey_id.sudo()._create_answer(
partner=user_membership_id_sudo.partner_id,
check_attempts=False,
**{
"slide_id": slide.id,
"slide_partner_id": user_membership_id_sudo.id,
"channel_partner_id": channel_partner.id,
},
invite_token=self.env[
"survey.user_input"
]._generate_invite_token(),
)
certification_urls[slide.id] = user_input.get_start_url()
else:
user_input = slide.survey_id.sudo()._create_answer(
partner=self.env.user.partner_id,
check_attempts=False,
test_entry=True,
**{"slide_id": slide.id},
)
certification_urls[slide.id] = user_input.get_start_url()
return certification_urls
18 changes: 18 additions & 0 deletions website_sale_slides_survey_multi_qty/models/survey_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models


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

channel_partner_id = fields.Many2one("slide.channel.partner")
slide_channel_partner_name = fields.Char(
related="channel_partner_id.slide_channel_partner_name"
)
slide_channel_partner_email = fields.Char(
related="channel_partner_id.slide_channel_partner_email"
)
slide_channel_partner_phone = fields.Char(
related="channel_partner_id.slide_channel_partner_phone"
)
3 changes: 3 additions & 0 deletions website_sale_slides_survey_multi_qty/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Empty file.
2 changes: 2 additions & 0 deletions website_sale_slides_survey_multi_qty/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- \[Tecnativa\](<https://www.tecnativa.com/>):
- Pilar Vargas
Empty file.
Empty file.
15 changes: 15 additions & 0 deletions website_sale_slides_survey_multi_qty/report/survey_templates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2025 Tecnativa - Pilar Vargas
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<template
id="certification_report_view_general"
inherit_id="survey.certification_report_view_general"
>
<xpath expr="//t[@t-set='certified_name']" position="attributes">
<attribute name="t-value">
(user_input.slide_channel_partner_name or user_input.slide_channel_partner_email or user_input.partner_id.name or user_input.email or '').upper()
</attribute>
</xpath>
</template>
</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading