Skip to content
Permalink
Browse files

wip

  • Loading branch information...
qmo-odoo committed Apr 15, 2019
1 parent 6a75cd2 commit 0f1b16334fc9a64143c667d119ace27cd97565ff
@@ -529,7 +529,7 @@ def survey_get_certification(self, survey_id, **kwargs):

if not succeeded_attempt:
raise UserError(_("The user has not succeeded the certification"))
report_sudo = request.env.ref(survey.certification_template_id.certification_template_xml_id).sudo()
report_sudo = request.env.ref('survey.certification_report').sudo()
report = report_sudo.render_qweb_pdf([succeeded_attempt.id], data={'report_type': 'pdf'})[0]
reporthttpheaders = [
('Content-Type', 'application/pdf'),
@@ -24,31 +24,31 @@
<!-- Certification report templates -->
<record id="certification_report_view_modern_purple" model="survey.certification.template">
<field name="name">Modern</field>
<field name="certification_template_xml_id">survey.certification_report</field>
<field name="certification_template_xml_id">survey.certification_report_view_modern</field>
</record>
<record id="certification_report_view_modern_blue" model="survey.certification.template">
<field name="name">Modern blue</field>
<field name="color_theme">blue</field>
<field name="certification_template_xml_id">survey.certification_report</field>
<field name="certification_template_xml_id">survey.certification_report_view_modern</field>
</record>
<record id="certification_report_view_modern_gold" model="survey.certification.template">
<field name="name">Modern gold</field>
<field name="color_theme">gold</field>
<field name="certification_template_xml_id">survey.certification_report</field>
<field name="certification_template_xml_id">survey.certification_report_view_modern</field>
</record>
<record id="certification_report_view_classic_purple" model="survey.certification.template">
<field name="name">Classic</field>
<field name="certification_template_xml_id">survey.certification_report_classic</field>
<field name="certification_template_xml_id">survey.certification_report_view_classic</field>
</record>
<record id="certification_report_view_classic_blue" model="survey.certification.template">
<field name="name">Classic blue</field>
<field name="color_theme">blue</field>
<field name="certification_template_xml_id">survey.certification_report_classic</field>
<field name="certification_template_xml_id">survey.certification_report_view_classic</field>
</record>
<record id="certification_report_view_classic_gold" model="survey.certification.template">
<record id="certification_report_view_classic_gold" model="survey.certification.template">
<field name="name">Classic gold</field>
<field name="color_theme">gold</field>
<field name="certification_template_xml_id">survey.certification_report_classic</field>
<field name="certification_template_xml_id">survey.certification_report_view_classic</field>
</record>
</data>
</odoo>
@@ -19,6 +19,5 @@ class SurveyCertificationTemplate(models.Model):
_rec_name = "name"

name = fields.Char(required=True)
survey_id = fields.One2many('survey.survey', "certification_template_id")
certification_template_xml_id = fields.Char(required=True)
color_theme = fields.Char()
@@ -89,7 +89,7 @@ def _get_default_access_token(self):
'mail.template', 'Certification Email Template',
domain="[('model', '=', 'survey.user_input')]",
help="Automated email sent to the user when he succeeds the certification, containing his certification document.")
certification_template_id = fields.Many2one('survey.certification.template', string="Certification template ")
certification_template_id = fields.Many2one('survey.certification.template', string="Certification template", default=lambda self: self.env.ref('survey.certification_report_view_modern_purple'), required=True)

_sql_constraints = [
('access_token_unique', 'unique(access_token)', 'Access token should be unique'),
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="certification_report_view">
<template id="certification_report_view_modern">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="user_input">
<!-- Style classes to be applyed to '#o_survey_certification': [no class](purple), gold, blue -->
@@ -70,5 +70,13 @@
</t>
</t>
</template>

<template id="certification_report_view">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="user_input">
<t t-call="{{user_input.survey_id.certification_template_id.certification_template_xml_id}}"/>
</t>
</t>
</template>
</data>
</odoo>
@@ -12,16 +12,5 @@
attachment="'certification.pdf'"
print_report_name="'Certification - %s' % (object.survey_id.display_name)"
/>

<report
id="certification_report_classic"
model="survey.user_input"
string="Certifications"
report_type="qweb-pdf"
name="survey.certification_report_view_classic"
file="survey.certification_report_view_classic"
attachment="'certification.pdf'"
print_report_name="'Certification - %s' % (object.survey_id.display_name)"
/>
</data>
</odoo>

0 comments on commit 0f1b163

Please sign in to comment.
You can’t perform that action at this time.