Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[15.0][FIX] survey_crm_generation: support all answers for lead description #100

Merged
Merged
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
2 changes: 1 addition & 1 deletion survey_crm_generation/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Survey leads generation
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:72ceb1068020aaec4baba6df86a6b1b024793db57bdfc2cec8374da9cac8d031
!! source digest: sha256:3c14b21a1363731430f9e53e7807eaf968281704b615c20415cb371e6dfdf709
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion survey_crm_generation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "Tecnativa, Odoo Community Association (OCA)",
"maintainers": ["chienandalu"],
"license": "AGPL-3",
"depends": ["survey", "crm"],
"depends": ["survey_result_mail", "crm"],
"data": [
"views/survey_survey_views.xml",
"views/survey_question_views.xml",
Expand Down
19 changes: 11 additions & 8 deletions survey_crm_generation/models/survey_user_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
opportunity_id = fields.Many2one(comodel_name="crm.lead")

def _prepare_opportunity(self):
return {
vals = {
"name": self.survey_id.title,
"tag_ids": [(6, 0, self.survey_id.crm_tag_ids.ids)],
"partner_id": self.partner_id.id,
Expand All @@ -19,21 +19,24 @@
"survey_user_input_id": self.id,
"description": self._prepare_lead_description(),
}
if not self.partner_id:
vals.update(

Check warning on line 23 in survey_crm_generation/models/survey_user_input.py

View check run for this annotation

Codecov / codecov/patch

survey_crm_generation/models/survey_user_input.py#L23

Added line #L23 was not covered by tests
{
"email_from": self.email,
"contact_name": self.nickname,
}
)
return vals

def _prepare_lead_description(self):
"""We can have surveys without partner. It's handy to have some relevant info
in the description although the answers are linked themselves.

:return str: description for the lead
"""
relevant_answers = self.user_input_line_ids.filtered(
lambda x: not x.skipped and x.question_id.show_in_lead_description
return self._build_answers_html(
self.user_input_line_ids.filtered("question_id.show_in_lead_description")
)
description = "\n".join(
f"{answer.question_id.title}: {answer[f'value_{answer.answer_type}']}"
for answer in relevant_answers
)
return description

def _create_opportunity_post_process(self):
"""After creating the lead send an internal message with the input link"""
Expand Down
2 changes: 1 addition & 1 deletion survey_crm_generation/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Survey leads generation</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:72ceb1068020aaec4baba6df86a6b1b024793db57bdfc2cec8374da9cac8d031
!! source digest: sha256:3c14b21a1363731430f9e53e7807eaf968281704b615c20415cb371e6dfdf709
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/survey/tree/15.0/survey_crm_generation"><img alt="OCA/survey" src="https://img.shields.io/badge/github-OCA%2Fsurvey-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/survey-15-0/survey-15-0-survey_crm_generation"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/survey&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows to generate leads/opportunities from surveys.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def test_lead_generation(self):
),
)
expected_lead_description = Markup(
"<p>E-mail address: test@test.com\n"
"Your company name?: Tecnativa\n"
"And your name?: Tecnativa</p>"
"<li><em>E-mail address</em>: <b>test@test.com</b></li>"
"<li><em>Your company name?</em>: <b>Tecnativa</b></li>"
"<li><em>And your name?</em>: <b>Tecnativa</b></li>"
)
self.assertEqual(
self.generated_lead.description,
Expand Down
Loading