Skip to content

Commit

Permalink
[MIG] survey_contact_generation: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
arielbarreiros96 committed Jan 23, 2025
1 parent c8d9782 commit 0ccf6c8
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 14 deletions.
10 changes: 5 additions & 5 deletions survey_contact_generation/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Survey contacts generation
: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_contact_generation
:target: https://github.com/OCA/survey/tree/16.0/survey_contact_generation
: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_contact_generation
:target: https://translation.odoo-community.org/projects/survey-16-0/survey-16-0-survey_contact_generation
: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=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -65,7 +65,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/survey/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/survey/issues/new?body=module:%20survey_contact_generation%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/survey/issues/new?body=module:%20survey_contact_generation%0Aversion:%2016.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.

Expand Down Expand Up @@ -107,6 +107,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-chienandalu|

This module is part of the `OCA/survey <https://github.com/OCA/survey/tree/15.0/survey_contact_generation>`_ project on GitHub.
This module is part of the `OCA/survey <https://github.com/OCA/survey/tree/16.0/survey_contact_generation>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion survey_contact_generation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Survey contacts generation",
"summary": "Generate new contacts from surveys",
"version": "15.0.1.1.2",
"version": "16.0.1.1.2",
"development_status": "Beta",
"category": "Marketing/Survey",
"website": "https://github.com/OCA/survey",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<field name="title">Contact Creation Survey</field>
<field name="access_token">80e5f1e2-1a9d-4c51-8e23-09e93f7fa2c5</field>
<field name="access_mode">public</field>
<field name="questions_layout">one_page</field>
<field name="users_can_go_back" eval="True" />
<field name="generate_contact" eval="True" />
<field name="create_parent_contact" eval="True" />
Expand Down
17 changes: 10 additions & 7 deletions survey_contact_generation/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -368,7 +369,7 @@ <h1 class="title">Survey contacts generation</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:986cee374f71c937639568c28530ff9e575ae48f8a880620c5d8698ca355632c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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_contact_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_contact_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><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/16.0/survey_contact_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-16-0/survey-16-0-survey_contact_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=16.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 new contacts from surveys answers.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -412,7 +413,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/survey/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/survey/issues/new?body=module:%20survey_contact_generation%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/survey/issues/new?body=module:%20survey_contact_generation%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -437,13 +438,15 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/chienandalu"><img alt="chienandalu" src="https://github.com/chienandalu.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/survey/tree/15.0/survey_contact_generation">OCA/survey</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/survey/tree/16.0/survey_contact_generation">OCA/survey</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions survey_contact_generation/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from . import test_survey_contact_generation
from . import test_survey_question
from . import test_survey_user_input
90 changes: 90 additions & 0 deletions survey_contact_generation/tests/test_survey_question.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
from odoo.addons.survey.tests.common import SurveyCase


class TestSurveyQuestion(SurveyCase):
def setUp(self):
super().setUp()
self.char_box_survey_question = self.env["survey.question"].create(
{
"title": "CharBox Question",
"question_type": "char_box",
}
)
self.text_box_survey_question = self.env["survey.question"].create(
{
"title": "TextBox Question",
"question_type": "text_box",
}
)
self.multiple_choice_survey_question = self.env["survey.question"].create(
{
"title": "MultipleChoice Question",
"question_type": "multiple_choice",
}
)
self.simple_choice_survey_question = self.env["survey.question"].create(
{
"title": "SimpleChoice Question",
"question_type": "simple_choice",
"res_partner_field": self.env["ir.model.fields"]
.search([("model", "=", "res.partner"), ("name", "=", "company_id")])
.id,
}
)

def test_compute_allowed_field_ids(self):
self.char_box_survey_question._compute_allowed_field_ids()
char_box_allowed_field_ids = self.char_box_survey_question.allowed_field_ids.ids
char_box_expected_field_ids = (
self.env["ir.model.fields"]
.search(
[
("model", "=", "res.partner"),
("ttype", "in", ["char", "text"]),
]
)
.ids
)
self.text_box_survey_question._compute_allowed_field_ids()
text_box_allowed_field_ids = self.text_box_survey_question.allowed_field_ids.ids
text_box_expected_field_ids = (
self.env["ir.model.fields"]
.search(
[
("model", "=", "res.partner"),
("ttype", "=", "html"),
]
)
.ids
)
self.multiple_choice_survey_question._compute_allowed_field_ids()
multiple_choice_allowed_field_ids = (
self.multiple_choice_survey_question.allowed_field_ids.ids
)
multiple_choice_expected_field_ids = (
self.env["ir.model.fields"]
.search(
[
("model", "=", "res.partner"),
("ttype", "in", ["many2many", "html", "char"]),
]
)
.ids
)

self.assertEqual(char_box_allowed_field_ids, char_box_expected_field_ids)
self.assertEqual(text_box_allowed_field_ids, text_box_expected_field_ids)
self.assertEqual(
multiple_choice_allowed_field_ids, multiple_choice_expected_field_ids
)

def test_question_answer_default_get(self):
self.simple_choice_survey_question.with_context(
default_res_partner_field=self.simple_choice_survey_question.res_partner_field.id
).write({"suggested_answer_ids": [(0, 0, {"value": "Company With Id 1"})]})
# Question uses company_id field, therefore id=1 by default
# since it always be at least 1 company
self.assertEqual(
self.simple_choice_survey_question.suggested_answer_ids.res_partner_field_resource_ref.id, # noqa: B950
1,
)
75 changes: 75 additions & 0 deletions survey_contact_generation/tests/test_survey_user_input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from odoo.addons.survey.tests.common import SurveyCase


class TestSurveyUserInput(SurveyCase):
def setUp(self):
super().setUp()
self.survey = self.env["survey.survey"].create(
{"title": "Test Survey", "generate_contact": True}
)
self.name_question = self.env["survey.question"].create(
{
"survey_id": self.survey.id,
"title": "Name Question",
"question_type": "char_box",
"res_partner_field": self.env["ir.model.fields"]
.search([("model", "=", "res.partner"), ("name", "=", "name")])
.id,
}
)
self.comment_question = self.env["survey.question"].create(
{
"survey_id": self.survey.id,
"title": "Comment Question",
"question_type": "char_box",
"res_partner_field": self.env["ir.model.fields"]
.search([("model", "=", "res.partner"), ("name", "=", "comment")])
.id,
}
)
self.email_question = self.env["survey.question"].create(
{
"survey_id": self.survey.id,
"title": "Email Question",
"question_type": "char_box",
"res_partner_field": self.env["ir.model.fields"]
.search([("model", "=", "res.partner"), ("name", "=", "email")])
.id,
}
)
self.user_input = self.env["survey.user_input"].create(
{"survey_id": self.survey.id}
)
self.name_user_input_answer = self.env["survey.user_input.line"].create(
{
"user_input_id": self.user_input.id,
"question_id": self.name_question.id,
"value_char_box": "Partner 01",
"answer_type": "char_box",
}
)
self.comment_user_input_answer = self.env["survey.user_input.line"].create(
{
"user_input_id": self.user_input.id,
"question_id": self.comment_question.id,
"value_char_box": "Comment Partner 01",
"answer_type": "char_box",
}
)
self.email_user_input_answer = self.env["survey.user_input.line"].create(
{
"user_input_id": self.user_input.id,
"question_id": self.email_question.id,
"value_char_box": "[email protected]",
"answer_type": "char_box",
}
)

def test_prepare_partner(self):
prepared_vals = self.user_input._prepare_partner()
self.assertTrue(prepared_vals)
self.assertTrue(prepared_vals.get("name") == "Partner 01")
self.assertTrue(prepared_vals.get("email") == "[email protected]")
self.assertTrue(
prepared_vals.get("comment") == "\nComment Question: Comment Partner 01"
)
2 changes: 1 addition & 1 deletion survey_contact_generation/views/survey_survey_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<odoo>
<record id="survey_form" model="ir.ui.view">
<field name="model">survey.survey</field>
<field name="inherit_id" ref="survey.survey_form" />
<field name="inherit_id" ref="survey.survey_survey_view_form" />
<field name="arch" type="xml">
<group name="options" position="inside">
<group name="contact_options" string="Contact">
Expand Down

0 comments on commit 0ccf6c8

Please sign in to comment.