From 61e01e4be0bfc90fefd99de11ed383f0bda8fd53 Mon Sep 17 00:00:00 2001 From: clementthomas Date: Tue, 21 Nov 2023 12:54:02 +0100 Subject: [PATCH] [NEW] first commit for all modules coming from training-tools --- .gitignore | 165 +++++++ survey_base/__init__.py | 1 + survey_base/__manifest__.py | 26 + survey_base/models/__init__.py | 2 + survey_base/models/survey_question_answer.py | 19 + survey_base/models/survey_user_input_line.py | 46 ++ survey_contact_generation/README.rst | 109 +++++ survey_contact_generation/__init__.py | 1 + survey_contact_generation/__manifest__.py | 24 + .../demo/survey_contact_generation_demo.xml | 100 ++++ survey_contact_generation/i18n/es.po | 168 +++++++ survey_contact_generation/i18n/fr.po | 64 +++ survey_contact_generation/models/__init__.py | 3 + .../models/survey_question.py | 80 ++++ .../models/survey_survey.py | 11 + .../models/survey_user_input.py | 77 +++ .../readme/CONFIGURE.rst | 10 + .../readme/CONTRIBUTORS.rst | 5 + .../readme/DESCRIPTION.rst | 1 + survey_contact_generation/readme/USAGE.rst | 3 + .../static/description/icon.png | Bin 0 -> 8322 bytes .../static/description/index.html | 450 ++++++++++++++++++ .../tests/survey_contact_generation_tour.js | 82 ++++ survey_contact_generation/tests/__init__.py | 1 + .../tests/test_survey_contact_generation.py | 31 ++ .../views/survey_question_views.xml | 32 ++ .../views/survey_survey_views.xml | 14 + survey_crm_generation/README.rst | 105 ++++ survey_crm_generation/__init__.py | 1 + survey_crm_generation/__manifest__.py | 26 + .../demo/survey_crm_demo.xml | 51 ++ survey_crm_generation/i18n/es.po | 137 ++++++ survey_crm_generation/i18n/fr.po | 85 ++++ survey_crm_generation/models/__init__.py | 4 + survey_crm_generation/models/crm_lead.py | 9 + .../models/survey_question.py | 9 + survey_crm_generation/models/survey_survey.py | 16 + .../models/survey_user_input.py | 76 +++ survey_crm_generation/readme/CONFIGURE.rst | 8 + survey_crm_generation/readme/CONTRIBUTORS.rst | 4 + survey_crm_generation/readme/DESCRIPTION.rst | 1 + survey_crm_generation/readme/USAGE.rst | 2 + .../static/description/icon.png | Bin 0 -> 8322 bytes .../static/description/index.html | 445 +++++++++++++++++ .../tests/survey_crm_generation_tour.js | 48 ++ survey_crm_generation/tests/__init__.py | 1 + .../tests/test_survey_crm_sale_generation.py | 49 ++ .../views/crm_lead_views.xml | 17 + .../views/survey_question_views.xml | 18 + .../views/survey_survey_views.xml | 23 + .../views/survey_user_input_views.xml | 15 + survey_crm_generation_attachment/__init__.py | 1 + .../__manifest__.py | 25 + .../models/__init__.py | 1 + .../models/survey_user_input.py | 32 ++ survey_crm_generation_training/__init__.py | 1 + .../__manifest__.py | 26 + survey_crm_generation_training/i18n/fr.po | 48 ++ .../models/__init__.py | 2 + .../models/crm_lead.py | 23 + .../models/survey_user_input.py | 15 + .../views/crm_lead_views.xml | 61 +++ survey_event_base/__init__.py | 1 + survey_event_base/__manifest__.py | 23 + survey_event_base/models/__init__.py | 1 + survey_event_base/models/survey_user_input.py | 61 +++ .../__init__.py | 1 + .../__manifest__.py | 18 + .../models/__init__.py | 3 + .../models/survey_question.py | 38 ++ .../models/survey_survey.py | 12 + .../models/survey_user_input.py | 82 ++++ .../security/ir.model.access.csv | 2 + .../views/survey_question_views.xml | 19 + .../views/survey_survey_views.xml | 16 + .../__init__.py | 1 + .../__manifest__.py | 25 + .../models/__init__.py | 1 + .../models/survey_user_input.py | 32 ++ survey_event_speaker_generation/__init__.py | 1 + .../__manifest__.py | 18 + survey_event_speaker_generation/i18n/fr.po | 56 +++ .../models/__init__.py | 2 + .../models/survey_survey.py | 11 + .../models/survey_user_input.py | 46 ++ .../views/mail_templates_chatter.xml | 22 + .../views/survey_survey_views.xml | 15 + survey_event_visibility/__init__.py | 1 + survey_event_visibility/__manifest__.py | 24 + survey_event_visibility/models/__init__.py | 3 + survey_event_visibility/models/event_event.py | 28 ++ survey_event_visibility/models/event_stage.py | 7 + .../models/product_product.py | 23 + .../views/event_stage_views.xml | 31 ++ 94 files changed, 3534 insertions(+) create mode 100644 .gitignore create mode 100644 survey_base/__init__.py create mode 100644 survey_base/__manifest__.py create mode 100644 survey_base/models/__init__.py create mode 100644 survey_base/models/survey_question_answer.py create mode 100644 survey_base/models/survey_user_input_line.py create mode 100644 survey_contact_generation/README.rst create mode 100644 survey_contact_generation/__init__.py create mode 100644 survey_contact_generation/__manifest__.py create mode 100644 survey_contact_generation/demo/survey_contact_generation_demo.xml create mode 100644 survey_contact_generation/i18n/es.po create mode 100644 survey_contact_generation/i18n/fr.po create mode 100644 survey_contact_generation/models/__init__.py create mode 100644 survey_contact_generation/models/survey_question.py create mode 100644 survey_contact_generation/models/survey_survey.py create mode 100644 survey_contact_generation/models/survey_user_input.py create mode 100644 survey_contact_generation/readme/CONFIGURE.rst create mode 100644 survey_contact_generation/readme/CONTRIBUTORS.rst create mode 100644 survey_contact_generation/readme/DESCRIPTION.rst create mode 100644 survey_contact_generation/readme/USAGE.rst create mode 100644 survey_contact_generation/static/description/icon.png create mode 100644 survey_contact_generation/static/description/index.html create mode 100644 survey_contact_generation/static/tests/survey_contact_generation_tour.js create mode 100644 survey_contact_generation/tests/__init__.py create mode 100644 survey_contact_generation/tests/test_survey_contact_generation.py create mode 100644 survey_contact_generation/views/survey_question_views.xml create mode 100644 survey_contact_generation/views/survey_survey_views.xml create mode 100644 survey_crm_generation/README.rst create mode 100644 survey_crm_generation/__init__.py create mode 100644 survey_crm_generation/__manifest__.py create mode 100644 survey_crm_generation/demo/survey_crm_demo.xml create mode 100644 survey_crm_generation/i18n/es.po create mode 100644 survey_crm_generation/i18n/fr.po create mode 100644 survey_crm_generation/models/__init__.py create mode 100644 survey_crm_generation/models/crm_lead.py create mode 100644 survey_crm_generation/models/survey_question.py create mode 100644 survey_crm_generation/models/survey_survey.py create mode 100644 survey_crm_generation/models/survey_user_input.py create mode 100644 survey_crm_generation/readme/CONFIGURE.rst create mode 100644 survey_crm_generation/readme/CONTRIBUTORS.rst create mode 100644 survey_crm_generation/readme/DESCRIPTION.rst create mode 100644 survey_crm_generation/readme/USAGE.rst create mode 100644 survey_crm_generation/static/description/icon.png create mode 100644 survey_crm_generation/static/description/index.html create mode 100644 survey_crm_generation/static/tests/survey_crm_generation_tour.js create mode 100644 survey_crm_generation/tests/__init__.py create mode 100644 survey_crm_generation/tests/test_survey_crm_sale_generation.py create mode 100644 survey_crm_generation/views/crm_lead_views.xml create mode 100644 survey_crm_generation/views/survey_question_views.xml create mode 100644 survey_crm_generation/views/survey_survey_views.xml create mode 100644 survey_crm_generation/views/survey_user_input_views.xml create mode 100644 survey_crm_generation_attachment/__init__.py create mode 100644 survey_crm_generation_attachment/__manifest__.py create mode 100644 survey_crm_generation_attachment/models/__init__.py create mode 100644 survey_crm_generation_attachment/models/survey_user_input.py create mode 100644 survey_crm_generation_training/__init__.py create mode 100644 survey_crm_generation_training/__manifest__.py create mode 100644 survey_crm_generation_training/i18n/fr.po create mode 100644 survey_crm_generation_training/models/__init__.py create mode 100644 survey_crm_generation_training/models/crm_lead.py create mode 100644 survey_crm_generation_training/models/survey_user_input.py create mode 100644 survey_crm_generation_training/views/crm_lead_views.xml create mode 100644 survey_event_base/__init__.py create mode 100644 survey_event_base/__manifest__.py create mode 100644 survey_event_base/models/__init__.py create mode 100644 survey_event_base/models/survey_user_input.py create mode 100644 survey_event_registration_generation/__init__.py create mode 100644 survey_event_registration_generation/__manifest__.py create mode 100644 survey_event_registration_generation/models/__init__.py create mode 100644 survey_event_registration_generation/models/survey_question.py create mode 100644 survey_event_registration_generation/models/survey_survey.py create mode 100644 survey_event_registration_generation/models/survey_user_input.py create mode 100644 survey_event_registration_generation/security/ir.model.access.csv create mode 100644 survey_event_registration_generation/views/survey_question_views.xml create mode 100644 survey_event_registration_generation/views/survey_survey_views.xml create mode 100644 survey_event_registration_generation_attachment/__init__.py create mode 100644 survey_event_registration_generation_attachment/__manifest__.py create mode 100644 survey_event_registration_generation_attachment/models/__init__.py create mode 100644 survey_event_registration_generation_attachment/models/survey_user_input.py create mode 100644 survey_event_speaker_generation/__init__.py create mode 100644 survey_event_speaker_generation/__manifest__.py create mode 100644 survey_event_speaker_generation/i18n/fr.po create mode 100644 survey_event_speaker_generation/models/__init__.py create mode 100644 survey_event_speaker_generation/models/survey_survey.py create mode 100644 survey_event_speaker_generation/models/survey_user_input.py create mode 100644 survey_event_speaker_generation/views/mail_templates_chatter.xml create mode 100644 survey_event_speaker_generation/views/survey_survey_views.xml create mode 100644 survey_event_visibility/__init__.py create mode 100644 survey_event_visibility/__manifest__.py create mode 100644 survey_event_visibility/models/__init__.py create mode 100644 survey_event_visibility/models/event_event.py create mode 100644 survey_event_visibility/models/event_stage.py create mode 100644 survey_event_visibility/models/product_product.py create mode 100644 survey_event_visibility/views/event_stage_views.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f0726c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,165 @@ +*.docx + +.~* + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + diff --git a/survey_base/__init__.py b/survey_base/__init__.py new file mode 100644 index 0000000..9a7e03e --- /dev/null +++ b/survey_base/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/survey_base/__manifest__.py b/survey_base/__manifest__.py new file mode 100644 index 0000000..adee7e2 --- /dev/null +++ b/survey_base/__manifest__.py @@ -0,0 +1,26 @@ +# Copyright 2016-2020 Akretion France () +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Survey base", + 'summary': 'Add fields used by several survey addons', + 'description': """ +Add fields used by several survey addons +---------------------------------------------------- +* Add record reference in survey_question and survey.user_input.line +* Add value_file in survey.user_input.line +* Implementation of theses fields should be in another module + +""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Elabore", + "website": "https://www.elabore.coop", + "category": "", + "depends": ["survey"], + "data": [ + + ], + "installable": True, +} diff --git a/survey_base/models/__init__.py b/survey_base/models/__init__.py new file mode 100644 index 0000000..4487824 --- /dev/null +++ b/survey_base/models/__init__.py @@ -0,0 +1,2 @@ +from . import survey_question_answer +from . import survey_user_input_line \ No newline at end of file diff --git a/survey_base/models/survey_question_answer.py b/survey_base/models/survey_question_answer.py new file mode 100644 index 0000000..8af6e75 --- /dev/null +++ b/survey_base/models/survey_question_answer.py @@ -0,0 +1,19 @@ + +import logging +import textwrap +import uuid + +from dateutil.relativedelta import relativedelta + +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError +from odoo.tools import float_is_zero + +_logger = logging.getLogger(__name__) + + +class SurveyQuestionAnswer(models.Model): + _inherit = 'survey.question.answer' + + record_reference = fields.Many2oneReference(model_field="record_reference_model", string="Record") + record_reference_model = fields.Char("Record Model") \ No newline at end of file diff --git a/survey_base/models/survey_user_input_line.py b/survey_base/models/survey_user_input_line.py new file mode 100644 index 0000000..6c49097 --- /dev/null +++ b/survey_base/models/survey_user_input_line.py @@ -0,0 +1,46 @@ + +import logging +import textwrap +import uuid + +from dateutil.relativedelta import relativedelta + +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError +from odoo.tools import float_is_zero + +_logger = logging.getLogger(__name__) + + +class SurveyUserInputLine(models.Model): + _inherit = 'survey.user_input.line' + + #attachment fields + value_file = fields.Binary(string="File") + value_file_fname = fields.Char(string="File Name") + + #record reference fields + record_reference = fields.Many2oneReference(model_field="record_reference_model", string="Record") + record_reference_model = fields.Char('Record model') + + """set record_reference when saving survey_user_input line + """ + def set_record_reference_data(self, vals): + if vals.get('answer_type') == "suggestion" and 'suggested_answer_id' in vals: + #find model + answer = self.env['survey.question.answer'].browse(vals['suggested_answer_id']) + vals['record_reference_model'] = answer.record_reference_model + vals['record_reference'] = answer.record_reference + + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + self.set_record_reference_data(vals) + return super(SurveyUserInputLine, self).create(vals_list) + + + def write(self, vals): + self.set_record_reference_data(vals) + return super(SurveyUserInputLine, self).write(vals) + + diff --git a/survey_contact_generation/README.rst b/survey_contact_generation/README.rst new file mode 100644 index 0000000..f60b817 --- /dev/null +++ b/survey_contact_generation/README.rst @@ -0,0 +1,109 @@ +========================== +Survey contacts generation +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0a298d1600a5f93ffe77357631c7e799e78b23b84c362b126720e36655dd5227 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_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 + :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 allows to generate new contacts from surveys answers. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure the contact generation: + +#. Go to the configured survey. +#. In the *Contact* section of the *Options* tab, set + *Generate Contact* on, if you want contacts to be + generated from the answers to this survey. +#. In each question associated with a future new contact, + specify the corresponding contact field. To do this, + go to the 'Options' tab, then navigate to the 'Contact' group, + and select the 'Contact field' field. + +Usage +===== + +if the survey is properly configured, once it is submited +by an anonomous user, a new contact is create or an +existing one is linked. + +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 + * Ernesto Tejeda + * Stefan Ungureanu + +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-chienandalu| image:: https://github.com/chienandalu.png?size=40px + :target: https://github.com/chienandalu + :alt: chienandalu + +Current `maintainer `__: + +|maintainer-chienandalu| + +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_contact_generation/__init__.py b/survey_contact_generation/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/survey_contact_generation/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/survey_contact_generation/__manifest__.py b/survey_contact_generation/__manifest__.py new file mode 100644 index 0000000..8138023 --- /dev/null +++ b/survey_contact_generation/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2023 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Survey contacts generation", + "summary": "Generate new contacts from surveys", + "version": "16.0.1.0.0", + "development_status": "Beta", + "category": "Marketing/Survey", + "website": "https://github.com/OCA/survey", + "author": "Tecnativa, Odoo Community Association (OCA)", + "maintainers": ["clement_thomas"], + "license": "AGPL-3", + "depends": ["survey"], + "data": [ + "views/survey_question_views.xml", + "views/survey_survey_views.xml", + ], + "demo": ["demo/survey_contact_generation_demo.xml"], + "assets": { + "web.assets_tests": [ + "/survey_contact_generation/static/tests/survey_contact_generation_tour.js", + ], + }, +} diff --git a/survey_contact_generation/demo/survey_contact_generation_demo.xml b/survey_contact_generation/demo/survey_contact_generation_demo.xml new file mode 100644 index 0000000..85fcc64 --- /dev/null +++ b/survey_contact_generation/demo/survey_contact_generation_demo.xml @@ -0,0 +1,100 @@ + + + + + Contact Creation Survey + 80e5f1e2-1a9d-4c51-8e23-09e93f7fa2c5 + public + + + + + + 0 + Name + char_box + + + + + + 1 + Email + char_box + + + + + 2 + Notes + text_box + + + + + 3 + Color + numerical_box + + + + + 4 + Date + date + + + + + 4 + Country + simple_choice + + + + + 1 + Spain + + + + + 2 + Romania + + + + + 4 + Tags + multiple_choice + + + + + 1 + Vendor + + + + + 2 + Prospects + + + + + 3 + Employees + + + diff --git a/survey_contact_generation/i18n/es.po b/survey_contact_generation/i18n/es.po new file mode 100644 index 0000000..1a29c04 --- /dev/null +++ b/survey_contact_generation/i18n/es.po @@ -0,0 +1,168 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_contact_generation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-06-14 11:55+0000\n" +"PO-Revision-Date: 2023-06-14 13:58+0200\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: \n" +"X-Generator: Poedit 3.0.1\n" + +#. module: survey_contact_generation +#: model:ir.model.fields,field_description:survey_contact_generation.field_survey_question__allowed_field_ids +msgid "Allowed Field" +msgstr "Campo permitido" + +#. module: survey_contact_generation +#: model:survey.question,title:survey_contact_generation.survey_contact_q3 +msgid "Color" +msgstr "Color" + +#. module: survey_contact_generation +#: model_terms:ir.ui.view,arch_db:survey_contact_generation.survey_form +#: model_terms:ir.ui.view,arch_db:survey_contact_generation.survey_question_form +msgid "Contact" +msgstr "Contacto" + +#. module: survey_contact_generation +#: model:survey.survey,title:survey_contact_generation.survey_contact_creation +msgid "Contact Creation Survey" +msgstr "Encuesta de creación de contactos" + +#. module: survey_contact_generation +#: model:ir.model.fields,field_description:survey_contact_generation.field_survey_question__res_partner_field +#: model:ir.model.fields,field_description:survey_contact_generation.field_survey_question_answer__res_partner_field +msgid "Contact field" +msgstr "Campo de contacto" + +#. module: survey_contact_generation +#: model:ir.model.fields,field_description:survey_contact_generation.field_survey_question_answer__res_partner_field_resource_ref +msgid "Contact field value" +msgstr "" + +#. module: survey_contact_generation +#: model:survey.question,title:survey_contact_generation.survey_contact_q5 +msgid "Country" +msgstr "" + +#. module: survey_contact_generation +#: model:survey.question,title:survey_contact_generation.survey_contact_q4 +msgid "Date" +msgstr "Fecha" + +#. module: survey_contact_generation +#: model:survey.question,title:survey_contact_generation.survey_contact_q1 +msgid "Email" +msgstr "Correo electrónico" + +#. module: survey_contact_generation +#: model:survey.question.answer,value:survey_contact_generation.survey_contact_q6_sug3 +msgid "Employees" +msgstr "" + +#. module: survey_contact_generation +#: model:ir.model.fields,field_description:survey_contact_generation.field_survey_survey__generate_contact +msgid "Generate Contact" +msgstr "Generar contacto" + +#. module: survey_contact_generation +#: model:ir.model.fields,help:survey_contact_generation.field_survey_survey__generate_contact +msgid "Generate contacts for anonymous survey users" +msgstr "Generar contacto para encuestas anónimas" + +#. module: survey_contact_generation +#: model:survey.question,comments_message:survey_contact_generation.survey_contact_q0 +#: model:survey.question,comments_message:survey_contact_generation.survey_contact_q1 +#: model:survey.question,comments_message:survey_contact_generation.survey_contact_q2 +#: model:survey.question,comments_message:survey_contact_generation.survey_contact_q3 +#: model:survey.question,comments_message:survey_contact_generation.survey_contact_q4 +#: model:survey.question,comments_message:survey_contact_generation.survey_contact_q5 +#: model:survey.question,comments_message:survey_contact_generation.survey_contact_q6 +msgid "If other, please specify:" +msgstr "Si es otro, especifíquelo:" + +#. module: survey_contact_generation +#: model:survey.question,title:survey_contact_generation.survey_contact_q0 +msgid "Name" +msgstr "Nombre" + +#. module: survey_contact_generation +#: model:survey.question,title:survey_contact_generation.survey_contact_q2 +msgid "Notes" +msgstr "Notas" + +#. module: survey_contact_generation +#: model:survey.question.answer,value:survey_contact_generation.survey_contact_q6_sug2 +msgid "Prospects" +msgstr "" + +#. module: survey_contact_generation +#: model:survey.question.answer,value:survey_contact_generation.survey_contact_q5_sug2 +msgid "Romania" +msgstr "" + +#. module: survey_contact_generation +#: model:survey.question.answer,value:survey_contact_generation.survey_contact_q5_sug1 +msgid "Spain" +msgstr "" + +#. module: survey_contact_generation +#: model:ir.model,name:survey_contact_generation.model_survey_survey +msgid "Survey" +msgstr "Planificación" + +#. module: survey_contact_generation +#: model:ir.model,name:survey_contact_generation.model_survey_question_answer +msgid "Survey Label" +msgstr "" + +#. module: survey_contact_generation +#: model:ir.model,name:survey_contact_generation.model_survey_question +msgid "Survey Question" +msgstr "Pregunta de la encuesta" + +#. module: survey_contact_generation +#: model:ir.model,name:survey_contact_generation.model_survey_user_input +msgid "Survey User Input" +msgstr "Entrada de usuario de la encuesta" + +#. module: survey_contact_generation +#: model:survey.question,title:survey_contact_generation.survey_contact_q6 +msgid "Tags" +msgstr "" + +#. module: survey_contact_generation +#: model:survey.question,validation_error_msg:survey_contact_generation.survey_contact_q0 +#: model:survey.question,validation_error_msg:survey_contact_generation.survey_contact_q1 +#: model:survey.question,validation_error_msg:survey_contact_generation.survey_contact_q2 +#: model:survey.question,validation_error_msg:survey_contact_generation.survey_contact_q3 +#: model:survey.question,validation_error_msg:survey_contact_generation.survey_contact_q4 +#: model:survey.question,validation_error_msg:survey_contact_generation.survey_contact_q5 +#: model:survey.question,validation_error_msg:survey_contact_generation.survey_contact_q6 +msgid "The answer you entered is not valid." +msgstr "La respuesta que has introducido no es válida." + +#. module: survey_contact_generation +#: model:survey.question,constr_error_msg:survey_contact_generation.survey_contact_q0 +#: model:survey.question,constr_error_msg:survey_contact_generation.survey_contact_q1 +#: model:survey.question,constr_error_msg:survey_contact_generation.survey_contact_q2 +#: model:survey.question,constr_error_msg:survey_contact_generation.survey_contact_q3 +#: model:survey.question,constr_error_msg:survey_contact_generation.survey_contact_q4 +#: model:survey.question,constr_error_msg:survey_contact_generation.survey_contact_q5 +#: model:survey.question,constr_error_msg:survey_contact_generation.survey_contact_q6 +msgid "This question requires an answer." +msgstr "Esta pregunta requiere una respuesta." + +#. module: survey_contact_generation +#: model:survey.question.answer,value:survey_contact_generation.survey_contact_q6_sug1 +msgid "Vendor" +msgstr "" diff --git a/survey_contact_generation/i18n/fr.po b/survey_contact_generation/i18n/fr.po new file mode 100644 index 0000000..44c9217 --- /dev/null +++ b/survey_contact_generation/i18n/fr.po @@ -0,0 +1,64 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_contact_generation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-09-19 14:33+0000\n" +"PO-Revision-Date: 2023-09-19 14:33+0000\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_contact_generation +#: model:ir.model.fields,field_description:survey_contact_generation.field_survey_question__allowed_field_ids +msgid "Allowed Field" +msgstr "Champs autorisés" + +#. module: survey_contact_generation +#: model_terms:ir.ui.view,arch_db:survey_contact_generation.survey_form +#: model_terms:ir.ui.view,arch_db:survey_contact_generation.survey_question_form +msgid "Contact" +msgstr "" + +#. module: survey_contact_generation +#: model:ir.model.fields,field_description:survey_contact_generation.field_survey_question__res_partner_field +#: model:ir.model.fields,field_description:survey_contact_generation.field_survey_question_answer__res_partner_field +msgid "Contact field" +msgstr "Champ contact" + +#. module: survey_contact_generation +#: model:ir.model.fields,field_description:survey_contact_generation.field_survey_question_answer__res_partner_field_resource_ref +msgid "Contact field value" +msgstr "Valeur du champ contact" + +#. module: survey_contact_generation +#: model:ir.model.fields,field_description:survey_contact_generation.field_survey_survey__generate_contact +msgid "Generate Contact" +msgstr "Générer un contact" + +#. module: survey_contact_generation +#: model:ir.model.fields,help:survey_contact_generation.field_survey_survey__generate_contact +msgid "Generate contacts for anonymous survey users" +msgstr "Générer des contacts pour les questionnaires anonymes" + + +#. module: survey_contact_generation +#: model:ir.model,name:survey_contact_generation.model_survey_question_answer +msgid "Survey Label" +msgstr "Étiquette du questionnaire" + +#. module: survey_contact_generation +#: model:ir.model,name:survey_contact_generation.model_survey_question +msgid "Survey Question" +msgstr "Question du questionnaire" + +#. module: survey_contact_generation +#: model:ir.model,name:survey_contact_generation.model_survey_user_input +msgid "Survey User Input" +msgstr "Entrée utilisateur du questionnaire" diff --git a/survey_contact_generation/models/__init__.py b/survey_contact_generation/models/__init__.py new file mode 100644 index 0000000..93bb3b4 --- /dev/null +++ b/survey_contact_generation/models/__init__.py @@ -0,0 +1,3 @@ +from . import survey_question +from . import survey_survey +from . import survey_user_input diff --git a/survey_contact_generation/models/survey_question.py b/survey_contact_generation/models/survey_question.py new file mode 100644 index 0000000..e86d4a0 --- /dev/null +++ b/survey_contact_generation/models/survey_question.py @@ -0,0 +1,80 @@ +# Copyright 2022 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, fields, models + + +class SurveyQuestion(models.Model): + _inherit = "survey.question" + + allowed_field_ids = fields.Many2many( + comodel_name="ir.model.fields", + compute="_compute_allowed_field_ids", + ) + res_partner_field = fields.Many2one( + string="Contact field", + comodel_name="ir.model.fields", + domain="[('id', 'in', allowed_field_ids)]", + ) + + @api.depends("question_type") + def _compute_allowed_field_ids(self): + type_mapping = { + "char_box": ["char", "text"], + "text_box": ["html"], + "numerical_box": ["integer", "float", "html", "char"], + "date": ["date", "text", "char"], + "datetime": ["datetime", "html", "char"], + "simple_choice": ["many2one", "html", "char"], + "multiple_choice": ["many2many", "html", "char"], + } + for record in self: + record.allowed_field_ids = ( + self.env["ir.model.fields"] + .search( + [ + ("model", "=", "res.partner"), + ("ttype", "in", type_mapping.get(record.question_type, [])), + ] + ) + .ids + ) + + +class SurveyQuestionAnswer(models.Model): + _inherit = "survey.question.answer" + + @api.model + def default_get(self, fields): + result = super().default_get(fields) + if ( + not result.get("res_partner_field") + or "res_partner_field_resource_ref" not in fields + ): + return result + partner_field = self.env["ir.model.fields"].browse(result["res_partner_field"]) + # Otherwise we'll just use the value (char, text) + if partner_field.ttype not in {"many2one", "many2many"}: + return result + res = self.env[partner_field.relation].search([], limit=1) + if res: + result["res_partner_field_resource_ref"] = "%s,%s" % ( + partner_field.relation, + res.id, + ) + return result + + @api.model + def _selection_res_partner_field_resource_ref(self): + return [(model.model, model.name) for model in self.env["ir.model"].search([])] + + res_partner_field = fields.Many2one(related="question_id.res_partner_field") + res_partner_field_resource_ref = fields.Reference( + string="Contact field value", + selection="_selection_res_partner_field_resource_ref", + ) + + @api.onchange("res_partner_field_resource_ref") + def _onchange_res_partner_field_resource_ref(self): + """Set the default value as the product name, although we can change it""" + if self.res_partner_field_resource_ref: + self.value = self.res_partner_field_resource_ref.display_name or "" diff --git a/survey_contact_generation/models/survey_survey.py b/survey_contact_generation/models/survey_survey.py new file mode 100644 index 0000000..9632102 --- /dev/null +++ b/survey_contact_generation/models/survey_survey.py @@ -0,0 +1,11 @@ +# Copyright 2023 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class SurveySurvey(models.Model): + _inherit = "survey.survey" + + generate_contact = fields.Boolean( + help="Generate contacts for anonymous survey users", + ) diff --git a/survey_contact_generation/models/survey_user_input.py b/survey_contact_generation/models/survey_user_input.py new file mode 100644 index 0000000..b47ca1e --- /dev/null +++ b/survey_contact_generation/models/survey_user_input.py @@ -0,0 +1,77 @@ +# Copyright 2022 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import models + + +class SurveyUserInput(models.Model): + _inherit = "survey.user_input" + + def _prepare_partner(self): + """Extract partner values from the answers""" + self.ensure_one() + elegible_inputs = self.user_input_line_ids.filtered( + lambda x: x.question_id.res_partner_field and not x.skipped + ) + basic_inputs = elegible_inputs.filtered( + lambda x: x.answer_type not in {"suggestion"} + and x.question_id.res_partner_field.name != "comment" + ) + vals = { + line.question_id.res_partner_field.name: line[f"value_{line.answer_type}"] + for line in basic_inputs + } + for line in elegible_inputs - basic_inputs: + field_name = line.question_id.res_partner_field.name + if line.question_id.res_partner_field.ttype == "many2one": + vals[ + field_name + ] = line.suggested_answer_id.res_partner_field_resource_ref.id + elif line.question_id.res_partner_field.ttype == "many2many": + vals.setdefault(field_name, []) + vals[field_name] += [ + (4, line.suggested_answer_id.res_partner_field_resource_ref.id) + ] + # We'll use the comment field to add any other infos + elif field_name == "comment": + vals.setdefault("comment", "") + value = ( + line.suggested_answer_id.value + if line.answer_type == "suggestion" + else line[f"value_{line.answer_type}"] + ) + vals["comment"] += f"\n{line.question_id.title}: {value}" + else: + if line.question_id.question_type == "multiple_choice": + if not vals.get(field_name): + vals[field_name] = line.suggested_answer_id.value + else: + vals[field_name] += line.suggested_answer_id.value + else: + vals[field_name] = line.suggested_answer_id.value + return vals + + def _create_contact_post_process(self, partner): + """After creating the lead send an internal message with the input link""" + partner.message_post_with_view( + "mail.message_origin_link", + values={"self": partner, "origin": self.survey_id}, + subtype_id=self.env.ref("mail.mt_note").id, + ) + + def _mark_done(self): + """Generate the contact when the survey is submitted""" + for user_input in self.filtered( + lambda r: r.survey_id.generate_contact# and not self.partner_id #uncomment to avoid contact generation several times + ): + vals = user_input._prepare_partner() + partner = False + email = vals.get("email") + if email: + partner = self.env["res.partner"].search( + [("email", "=", email)], limit=1 + ) + if not partner: + partner = self.env["res.partner"].create(vals) + self._create_contact_post_process(partner) + self.update({"partner_id": partner.id, "email": partner.email}) + return super()._mark_done() diff --git a/survey_contact_generation/readme/CONFIGURE.rst b/survey_contact_generation/readme/CONFIGURE.rst new file mode 100644 index 0000000..18966aa --- /dev/null +++ b/survey_contact_generation/readme/CONFIGURE.rst @@ -0,0 +1,10 @@ +To configure the contact generation: + +#. Go to the configured survey. +#. In the *Contact* section of the *Options* tab, set + *Generate Contact* on, if you want contacts to be + generated from the answers to this survey. +#. In each question associated with a future new contact, + specify the corresponding contact field. To do this, + go to the 'Options' tab, then navigate to the 'Contact' group, + and select the 'Contact field' field. diff --git a/survey_contact_generation/readme/CONTRIBUTORS.rst b/survey_contact_generation/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..e3851e7 --- /dev/null +++ b/survey_contact_generation/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* `Tecnativa `_ + + * David Vidal + * Ernesto Tejeda + * Stefan Ungureanu diff --git a/survey_contact_generation/readme/DESCRIPTION.rst b/survey_contact_generation/readme/DESCRIPTION.rst new file mode 100644 index 0000000..ac10b74 --- /dev/null +++ b/survey_contact_generation/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to generate new contacts from surveys answers. diff --git a/survey_contact_generation/readme/USAGE.rst b/survey_contact_generation/readme/USAGE.rst new file mode 100644 index 0000000..f7c7830 --- /dev/null +++ b/survey_contact_generation/readme/USAGE.rst @@ -0,0 +1,3 @@ +if the survey is properly configured, once it is submited +by an anonomous user, a new contact is create or an +existing one is linked. diff --git a/survey_contact_generation/static/description/icon.png b/survey_contact_generation/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ae0af814c13aaa36da581cafb348ae53540fdb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p4ByRc;8-Ei zD7mMRT=r=Q1SbQ9am{dC5z(*>_v`_I7A+vyszpMMOaL?*vpyQRrW@H5qt}}eYC3;~ z`5}A^W3Rd9u}r(@+IOHB86_4^gTNu)W!%(;PgEv%HxlrKLm&l$k6&T(Ez-l1S8;%ZSCsO6+4oU=1=;H1K zEJ{0?jZcw|W;49~+L5+g3&8Mov|p0o8{>I!hh?lssmL-a7K;J215pbWuN`kppa@79 zVHh^`do%0cWhzksil%2Xo$?nG(=ZBT8TBSW;0)-Z3y6Vh9Lat$ib%eWC5f$>bSmcs zinSz}^X9clc((HDJBm}1?2KPSHq`otLJt#0Cu7Fw$7G zVf0_fDu8yUK;t|5L}qc`Fs86g6AtTa7B6iKQ3kO~ZzD;GPhn`b*+1cRJdFX$oYc+7 zcupD92~d~~AJQARab~gWsAORvD#N5~8YAPHVXN?*Ge353VQ! zh^A*6+ZGZgNn?LWiHD&Zjb`Q$qjWS-?V4F*5O)`p0m#^Y6I zzZiw>-cT7PT3QCxpBHYCp#KjRN#W2`=-fef#;hgfGDGHgjW$k(IFsUO(1Y9Ke1LTG z9g@6$7pD>-3LxI}cok1=;a3>jGZTBbmDKF3qgs}oN7&D9G-X&E1SgcX|AYE!jqoNhA0MZGR%s28ALmfF(MGdOCu*spaFNI z);A~@fMsS*DOs4eL>!g_Dt3io|)HusZIIYdMT4eBSct zCKxkh68BC8k(F%*mgD+zOTP83xXjNs{K0D08wdt#q?~i6o_b{Qb7T-0(&j+_AN;Qr zO1l~&(HrY{j-)?$8~^|SFiAu~RGYHR zU|~+PIV;BNu3)w=!&A+)7+L<8U=Z&W+$z`Bymx1G&ruwxCtmTL1t6 M07*qoM6N<$g1NtQl>h($ literal 0 HcmV?d00001 diff --git a/survey_contact_generation/static/description/index.html b/survey_contact_generation/static/description/index.html new file mode 100644 index 0000000..64dc95c --- /dev/null +++ b/survey_contact_generation/static/description/index.html @@ -0,0 +1,450 @@ + + + + + + +Survey contacts generation + + + +
+

Survey contacts generation

+ + +

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

+

This module allows to generate new contacts from surveys answers.

+

Table of contents

+ +
+

Configuration

+

To configure the contact generation:

+
    +
  1. Go to the configured survey.
  2. +
  3. In the Contact section of the Options tab, set +Generate Contact on, if you want contacts to be +generated from the answers to this survey.
  4. +
  5. In each question associated with a future new contact, +specify the corresponding contact field. To do this, +go to the ‘Options’ tab, then navigate to the ‘Contact’ group, +and select the ‘Contact field’ field.
  6. +
+
+
+

Usage

+

if the survey is properly configured, once it is submited +by an anonomous user, a new contact is create or an +existing one is linked.

+
+
+

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
    • +
    • Ernesto Tejeda
    • +
    • Stefan Ungureanu
    • +
    +
  • +
+
+
+

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:

+

chienandalu

+

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_contact_generation/static/tests/survey_contact_generation_tour.js b/survey_contact_generation/static/tests/survey_contact_generation_tour.js new file mode 100644 index 0000000..25e3d2b --- /dev/null +++ b/survey_contact_generation/static/tests/survey_contact_generation_tour.js @@ -0,0 +1,82 @@ +odoo.define("survey.tour_test_survey_contact_generation", function (require) { + "use strict"; + + const tour = require("web_tour.tour"); + + tour.register( + "test_survey_contact_generation", + { + test: true, + url: "/survey/start/80e5f1e2-1a9d-4c51-8e23-09e93f7fa2c5", + }, + [ + { + content: "Click on Start", + trigger: "button.btn:contains('Start Survey')", + }, + { + content: "Name", + trigger: "div.js_question-wrapper:contains('Name') input", + run: "text My Name", + }, + { + content: "Email", + trigger: "div.js_question-wrapper:contains('Email') input", + run: "text survey_contact_generation@test.com", + }, + { + content: "Notes", + trigger: "div.js_question-wrapper:contains('Notes') textarea", + run: "text This is a test note", + }, + { + content: "Color", + trigger: "div.js_question-wrapper:contains('Color') input", + run: "text 1", + }, + { + content: "Date", + trigger: "div.js_question-wrapper:contains('Date') input", + run: "text 01/01/2023", + }, + { + content: "Country", + trigger: + "div.js_question-wrapper:contains('Country') label:contains('Romania') i", + run: function () { + $( + "div.js_question-wrapper:contains('Country') label:contains('Romania') i" + ).prop("checked", true); + }, + }, + { + content: "Tags", + trigger: + "div.js_question-wrapper:contains('Tags') label:contains('Prospects') i", + run: function () { + $( + "div.js_question-wrapper:contains('Tags') label:contains('Prospects') i" + ).prop("checked", true); + }, + }, + { + content: "Tags", + trigger: + "div.js_question-wrapper:contains('Tags') label:contains('Vendor') i", + run: function () { + $( + "div.js_question-wrapper:contains('Tags') label:contains('Vendor') i" + ).prop("checked", true); + }, + }, + { + content: "Click Submit", + trigger: "button[value='finish']", + }, + { + content: "Thank you", + trigger: "h1:contains('Thank you!')", + }, + ] + ); +}); diff --git a/survey_contact_generation/tests/__init__.py b/survey_contact_generation/tests/__init__.py new file mode 100644 index 0000000..d4c56fb --- /dev/null +++ b/survey_contact_generation/tests/__init__.py @@ -0,0 +1 @@ +from . import test_survey_contact_generation diff --git a/survey_contact_generation/tests/test_survey_contact_generation.py b/survey_contact_generation/tests/test_survey_contact_generation.py new file mode 100644 index 0000000..ff24ca9 --- /dev/null +++ b/survey_contact_generation/tests/test_survey_contact_generation.py @@ -0,0 +1,31 @@ +# Copyright 2023 Tecnativa - David Vidal +# Copyright 2023 Tecnativa - Stefan Ungureanu +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests import HttpCase, tagged + +from odoo.addons.survey.tests.common import SurveyCase + + +@tagged("-at_install", "post_install") +class SurveyContactGenerationCase(SurveyCase, HttpCase): + def setUp(self): + """We run the tour in the setup so we can share the tests case with other + modules""" + super().setUp() + self.survey = self.env.ref("survey_contact_generation.survey_contact_creation") + initial_user_inputs = self.survey.user_input_ids + # Run the survey as a portal user and get the generated quotation + self.start_tour( + f"/survey/start/{self.survey.access_token}", + "test_survey_contact_generation", + ) + self.user_input = self.survey.user_input_ids - initial_user_inputs + + +@tagged("-at_install", "post_install") +class SurveyContactGenerationTests(SurveyContactGenerationCase): + def test_contact_generation(self): + partner = self.env["res.partner"].search( + [("email", "=", "survey_contact_generation@test.com")] + ) + self.assertEqual(partner, self.user_input.partner_id) diff --git a/survey_contact_generation/views/survey_question_views.xml b/survey_contact_generation/views/survey_question_views.xml new file mode 100644 index 0000000..e235807 --- /dev/null +++ b/survey_contact_generation/views/survey_question_views.xml @@ -0,0 +1,32 @@ + + + + survey.question + + + + + + + + + + {'default_question_id': active_id, 'default_res_partner_field': res_partner_field} + + + + + + + + diff --git a/survey_contact_generation/views/survey_survey_views.xml b/survey_contact_generation/views/survey_survey_views.xml new file mode 100644 index 0000000..c901a1b --- /dev/null +++ b/survey_contact_generation/views/survey_survey_views.xml @@ -0,0 +1,14 @@ + + + + survey.survey + + + + + + + + + + diff --git a/survey_crm_generation/README.rst b/survey_crm_generation/README.rst new file mode 100644 index 0000000..698a837 --- /dev/null +++ b/survey_crm_generation/README.rst @@ -0,0 +1,105 @@ +======================= +Survey leads generation +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:72ceb1068020aaec4baba6df86a6b1b024793db57bdfc2cec8374da9cac8d031 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_crm_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_crm_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 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to generate leads/opportunities from surveys. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure the leads/opportunities generation: + +#. Go to the configured survey. +#. In the *CRM* section of the *Options* tab, set *Generate leads* on. +#. Optionally you can set default tags for the generated leads. +#. You can set the crm team to assign the leads to. + +The questions marked to be shown in the lead description will be shown there. + +Usage +===== + +Once the surveys are submited a lead/opportunity (depending on the default options for +the company) will be generated with a link to the answers. + +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 + * Stefan ungureanu + +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-chienandalu| image:: https://github.com/chienandalu.png?size=40px + :target: https://github.com/chienandalu + :alt: chienandalu + +Current `maintainer `__: + +|maintainer-chienandalu| + +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_crm_generation/__init__.py b/survey_crm_generation/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/survey_crm_generation/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/survey_crm_generation/__manifest__.py b/survey_crm_generation/__manifest__.py new file mode 100644 index 0000000..ef8ecb5 --- /dev/null +++ b/survey_crm_generation/__manifest__.py @@ -0,0 +1,26 @@ +# Copyright 2023 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Survey leads generation", + "summary": "Generate CRM leads/opportunities from surveys", + "version": "16.0.1.0.0", + "development_status": "Beta", + "category": "Marketing/Survey", + "website": "https://github.com/OCA/survey", + "author": "Tecnativa, Odoo Community Association (OCA)", + "maintainers": ["chienandalu"], + "license": "AGPL-3", + "depends": ["survey", "crm"], + "data": [ + "views/survey_survey_views.xml", + "views/survey_question_views.xml", + "views/survey_user_input_views.xml", + "views/crm_lead_views.xml", + ], + "demo": ["demo/survey_crm_demo.xml"], + "assets": { + "web.assets_tests": [ + "/survey_crm_generation/static/tests/survey_crm_generation_tour.js", + ], + }, +} diff --git a/survey_crm_generation/demo/survey_crm_demo.xml b/survey_crm_generation/demo/survey_crm_demo.xml new file mode 100644 index 0000000..638631c --- /dev/null +++ b/survey_crm_generation/demo/survey_crm_demo.xml @@ -0,0 +1,51 @@ + + + + Survey Leads + + + OCA Partnership + + + + OCA Partnership + + + + Become OCA Partner + Be part of the Odoo Community! + 08b4db21-66cc-4c69-a712-cc364c54902c + public + + + + + + + + 0 + E-mail address + text_box + + + + + + 1 + Your company name? + text_box + + + + + + 2 + And your name? + text_box + + + + diff --git a/survey_crm_generation/i18n/es.po b/survey_crm_generation/i18n/es.po new file mode 100644 index 0000000..2dfe41d --- /dev/null +++ b/survey_crm_generation/i18n/es.po @@ -0,0 +1,137 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_crm_generation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-06-01 09:49+0000\n" +"PO-Revision-Date: 2023-06-01 12:07+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es_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.0.1\n" + +#. module: survey_crm_generation +#: model:survey.question,title:survey_crm_generation.survey_oca_q3 +msgid "And your name?" +msgstr "¿Y tu nombre? " + +#. module: survey_crm_generation +#: model:survey.survey,description:survey_crm_generation.become_partner +msgid "Be part of the Odoo Community!" +msgstr "¡Se parte de la comunidad de Odoo!" + +#. module: survey_crm_generation +#: model:survey.survey,title:survey_crm_generation.become_partner +msgid "Become OCA Partner" +msgstr "Conviértete en miembro OCA" + +#. module: survey_crm_generation +#: model_terms:ir.ui.view,arch_db:survey_crm_generation.survey_form +#: model_terms:ir.ui.view,arch_db:survey_crm_generation.survey_question_form +msgid "CRM" +msgstr "CRM" + +#. module: survey_crm_generation +#: model:ir.model.fields,field_description:survey_crm_generation.field_survey_survey__crm_tag_ids +msgid "Crm Tag" +msgstr "Etiqueta CRM" + +#. module: survey_crm_generation +#: model:ir.model.fields,field_description:survey_crm_generation.field_survey_survey__crm_team_id +msgid "Crm Team" +msgstr "Equipo CRM" + +#. module: survey_crm_generation +#: model:survey.question,title:survey_crm_generation.survey_oca_q0 +msgid "E-mail address" +msgstr "Dirección de correo electrónico" + +#. module: survey_crm_generation +#: model:ir.model.fields,field_description:survey_crm_generation.field_survey_survey__generate_leads +msgid "Generate Leads" +msgstr "Generación de iniciativa" + +#. module: survey_crm_generation +#: model:ir.model.fields,help:survey_crm_generation.field_survey_survey__generate_leads +msgid "Generate leads/opportunities linked to the generated quotations" +msgstr "Generar iniciativas/oportunidades vinculadas a las ofertas generadas" + +#. module: survey_crm_generation +#: model:survey.question,comments_message:survey_crm_generation.survey_oca_q0 +#: model:survey.question,comments_message:survey_crm_generation.survey_oca_q1 +#: model:survey.question,comments_message:survey_crm_generation.survey_oca_q3 +msgid "If other, please specify:" +msgstr "Si es otro, especifíquelo:" + +#. module: survey_crm_generation +#: model:ir.model,name:survey_crm_generation.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Iniciativa/Oportunidad" + +#. module: survey_crm_generation +#: model:crm.tag,name:survey_crm_generation.tag_oca_partnership +#: model:crm.team,name:survey_crm_generation.oca_partnership_leads +msgid "OCA Partnership" +msgstr "Asociación OCA" + +#. module: survey_crm_generation +#: model:ir.model.fields,field_description:survey_crm_generation.field_survey_user_input__opportunity_id +msgid "Opportunity" +msgstr "Oportunidad" + +#. module: survey_crm_generation +#: model:ir.model.fields,help:survey_crm_generation.field_survey_survey__crm_tag_ids +msgid "Set the default crm tags in the generated leads/opportunities" +msgstr "Establecer las etiquetas crm por defecto en las iniciativas/oportunidades generadas" + +#. module: survey_crm_generation +#: model:ir.model.fields,field_description:survey_crm_generation.field_survey_question__show_in_lead_description +msgid "Show In Lead Description" +msgstr "Mostrar en la descripción de la iniciativa" + +#. module: survey_crm_generation +#: model:ir.model,name:survey_crm_generation.model_survey_survey +msgid "Survey" +msgstr "Encuesta" + +#. module: survey_crm_generation +#: model:crm.tag,name:survey_crm_generation.tag_survey_leads +msgid "Survey Leads" +msgstr "Encuesta de la iniciativa" + +#. module: survey_crm_generation +#: model:ir.model,name:survey_crm_generation.model_survey_question +msgid "Survey Question" +msgstr "Pregunta de la encuesta" + +#. module: survey_crm_generation +#: model:ir.model,name:survey_crm_generation.model_survey_user_input +#: model:ir.model.fields,field_description:survey_crm_generation.field_crm_lead__survey_user_input_id +msgid "Survey User Input" +msgstr "Respuestas de los usuarios" + +#. module: survey_crm_generation +#: model:survey.question,validation_error_msg:survey_crm_generation.survey_oca_q0 +#: model:survey.question,validation_error_msg:survey_crm_generation.survey_oca_q1 +#: model:survey.question,validation_error_msg:survey_crm_generation.survey_oca_q3 +msgid "The answer you entered is not valid." +msgstr "La respuesta que has introducido no es válida." + +#. module: survey_crm_generation +#: model:survey.question,constr_error_msg:survey_crm_generation.survey_oca_q0 +#: model:survey.question,constr_error_msg:survey_crm_generation.survey_oca_q1 +#: model:survey.question,constr_error_msg:survey_crm_generation.survey_oca_q3 +msgid "This question requires an answer." +msgstr "Esta pregunta requiere una respuesta." + +#. module: survey_crm_generation +#: model:survey.question,title:survey_crm_generation.survey_oca_q1 +msgid "Your company name?" +msgstr "¿El nombre de su empresa?" diff --git a/survey_crm_generation/i18n/fr.po b/survey_crm_generation/i18n/fr.po new file mode 100644 index 0000000..836a32f --- /dev/null +++ b/survey_crm_generation/i18n/fr.po @@ -0,0 +1,85 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_crm_generation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-10-24 08:50+0000\n" +"PO-Revision-Date: 2023-10-24 08:50+0000\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_crm_generation +#: model_terms:ir.ui.view,arch_db:survey_crm_generation.survey_form +#: model_terms:ir.ui.view,arch_db:survey_crm_generation.survey_question_form +msgid "CRM" +msgstr "" + +#. module: survey_crm_generation +#: model:ir.model.fields,field_description:survey_crm_generation.field_survey_survey__crm_tag_ids +msgid "Crm Tag" +msgstr "Étiquette CRM" + +#. module: survey_crm_generation +#: model:ir.model.fields,field_description:survey_crm_generation.field_survey_survey__crm_team_id +msgid "Crm Team" +msgstr "Équipe commerciale" + +#. module: survey_crm_generation +#: model:ir.model.fields,field_description:survey_crm_generation.field_survey_survey__generate_leads +msgid "Generate Leads" +msgstr "Générer des pistes" + +#. module: survey_crm_generation +#: model:ir.model.fields,help:survey_crm_generation.field_survey_survey__generate_leads +msgid "Generate leads/opportunities linked to the generated quotations" +msgstr "Générer des pistes / opportunités liées aux devis" + +#. module: survey_crm_generation +#: model:ir.model,name:survey_crm_generation.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Piste/Opportunité" + +#. module: survey_crm_generation +#: model:ir.model.fields,field_description:survey_crm_generation.field_survey_user_input__opportunity_id +msgid "Opportunity" +msgstr "Opportunité" + +#. module: survey_crm_generation +#: model:ir.model.fields,help:survey_crm_generation.field_survey_survey__crm_tag_ids +msgid "Set the default crm tags in the generated leads/opportunities" +msgstr "Attribuer les étiquettes par défault dans les pistes générées" + +#. module: survey_crm_generation +#: model:ir.model.fields,field_description:survey_crm_generation.field_survey_question__show_in_lead_description +msgid "Show In Lead Description" +msgstr "Montrer dans la description de la piste CRM" + +#. module: survey_crm_generation +#: model:ir.model,name:survey_crm_generation.model_survey_survey +msgid "Survey" +msgstr "Questionnaire" + +#. module: survey_crm_generation +#: model:ir.model,name:survey_crm_generation.model_survey_question +msgid "Survey Question" +msgstr "Question du questionnaire" + +#. module: survey_crm_generation +#: model:ir.model,name:survey_crm_generation.model_survey_user_input +#: model:ir.model.fields,field_description:survey_crm_generation.field_crm_lead__survey_user_input_id +msgid "Survey User Input" +msgstr "Entrée utilisateur du questionnaire" + +#. module: survey_crm_generation +#. odoo-python +#: code:addons/survey_crm_generation/models/survey_user_input.py:0 +#, python-format +msgid "Survey answers: " +msgstr "Réponses au questionnaire : " diff --git a/survey_crm_generation/models/__init__.py b/survey_crm_generation/models/__init__.py new file mode 100644 index 0000000..e27bb41 --- /dev/null +++ b/survey_crm_generation/models/__init__.py @@ -0,0 +1,4 @@ +from . import crm_lead +from . import survey_question +from . import survey_survey +from . import survey_user_input diff --git a/survey_crm_generation/models/crm_lead.py b/survey_crm_generation/models/crm_lead.py new file mode 100644 index 0000000..0471593 --- /dev/null +++ b/survey_crm_generation/models/crm_lead.py @@ -0,0 +1,9 @@ +# Copyright 2023 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class CrmLead(models.Model): + _inherit = "crm.lead" + + survey_user_input_id = fields.Many2one(comodel_name="survey.user_input") diff --git a/survey_crm_generation/models/survey_question.py b/survey_crm_generation/models/survey_question.py new file mode 100644 index 0000000..f5163eb --- /dev/null +++ b/survey_crm_generation/models/survey_question.py @@ -0,0 +1,9 @@ +# Copyright 2022 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class SurveyQuestion(models.Model): + _inherit = "survey.question" + + show_in_lead_description = fields.Boolean() diff --git a/survey_crm_generation/models/survey_survey.py b/survey_crm_generation/models/survey_survey.py new file mode 100644 index 0000000..62b1eaf --- /dev/null +++ b/survey_crm_generation/models/survey_survey.py @@ -0,0 +1,16 @@ +# Copyright 2023 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class SurveySurvey(models.Model): + _inherit = "survey.survey" + + generate_leads = fields.Boolean( + help="Generate leads/opportunities linked to the generated quotations", + ) + crm_tag_ids = fields.Many2many( + comodel_name="crm.tag", + help="Set the default crm tags in the generated leads/opportunities", + ) + crm_team_id = fields.Many2one(comodel_name="crm.team") diff --git a/survey_crm_generation/models/survey_user_input.py b/survey_crm_generation/models/survey_user_input.py new file mode 100644 index 0000000..5f3d0c2 --- /dev/null +++ b/survey_crm_generation/models/survey_user_input.py @@ -0,0 +1,76 @@ +# Copyright 2022 Tecnativa - David Vidal +# 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" + + opportunity_id = fields.Many2one(comodel_name="crm.lead") + + def _prepare_opportunity(self): + return { + "name": self.survey_id.title, + "tag_ids": [(6, 0, self.survey_id.crm_tag_ids.ids)], + "partner_id": self.partner_id.id, + "user_id": self.survey_id.crm_team_id.user_id.id, + "team_id": self.survey_id.crm_team_id.id, + "company_id": self.create_uid.company_id.id, + "survey_user_input_id": self.id, + "description": self._prepare_lead_description(), + } + + 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 + ) + + li = '' + for answer in relevant_answers: + li += '
  • ' + if answer.answer_type == "suggestion": + answer_value = answer.suggested_answer_id + else: + answer_value = answer[f'value_{answer.answer_type}'] + #case of value Models + if isinstance(answer_value,models.Model): + # case of Multi Models + if len(answer_value._ids) > 1: + ul2 = f'{answer.question_id.title}:
      ' + for answer_value_object in answer_value: + ul2 += '
    • '+f"{answer_value_object.display_name}"+'
    • ' + ul2 += '
    ' + li += ul2 + # case of One Models + else: + li += f"{answer.question_id.title}: {answer_value.display_name}" + else: + # case of string value + li += f"{answer.question_id.title}: {answer_value}" + li += '
  • ' + + description = ''+_('Survey answers: ')+"
      "+li+"
    " + return description + + def _create_opportunity_post_process(self): + """After creating the lead send an internal message with the input link""" + self.opportunity_id.message_post_with_view( + "mail.message_origin_link", + values={"self": self.opportunity_id, "origin": self}, + subtype_id=self.env.ref("mail.mt_note").id, + ) + + def _mark_done(self): + """Generate the opportunity when the survey is submitted""" + res = super()._mark_done() + if not self.survey_id.generate_leads: + return res + vals = self._prepare_opportunity() + self.opportunity_id = self.env["crm.lead"].sudo().create(vals) + self._create_opportunity_post_process() + return res diff --git a/survey_crm_generation/readme/CONFIGURE.rst b/survey_crm_generation/readme/CONFIGURE.rst new file mode 100644 index 0000000..4c55dc7 --- /dev/null +++ b/survey_crm_generation/readme/CONFIGURE.rst @@ -0,0 +1,8 @@ +To configure the leads/opportunities generation: + +#. Go to the configured survey. +#. In the *CRM* section of the *Options* tab, set *Generate leads* on. +#. Optionally you can set default tags for the generated leads. +#. You can set the crm team to assign the leads to. + +The questions marked to be shown in the lead description will be shown there. diff --git a/survey_crm_generation/readme/CONTRIBUTORS.rst b/survey_crm_generation/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..cbf3a46 --- /dev/null +++ b/survey_crm_generation/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_ + + * David Vidal + * Stefan ungureanu diff --git a/survey_crm_generation/readme/DESCRIPTION.rst b/survey_crm_generation/readme/DESCRIPTION.rst new file mode 100644 index 0000000..f115b35 --- /dev/null +++ b/survey_crm_generation/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to generate leads/opportunities from surveys. diff --git a/survey_crm_generation/readme/USAGE.rst b/survey_crm_generation/readme/USAGE.rst new file mode 100644 index 0000000..79a88f5 --- /dev/null +++ b/survey_crm_generation/readme/USAGE.rst @@ -0,0 +1,2 @@ +Once the surveys are submited a lead/opportunity (depending on the default options for +the company) will be generated with a link to the answers. diff --git a/survey_crm_generation/static/description/icon.png b/survey_crm_generation/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ae0af814c13aaa36da581cafb348ae53540fdb93 GIT binary patch literal 8322 zcmV-|AbsD7P)PyA07*naRCr$PT?v>J#o7LPW@mPnU0LoMJP=Jdqlte+L`^tUl$gr|mO~IkhKFzN}#IrrK!qyA5(QTb5;zBuV=k02u$R{Mq=L z1QN&~1OBh>p(m%56Hmoio+QD4M|};=9s8%TAN*?HP#{nd4hD8qH#EHQ$DZGxFG*6J zsV7ElSbJORjLd~WNy@RJ>+&)JHqUDLEPsaLY2GgKt z^On#lGqYw^&mXju9{l*Dhh9IpXV&T38WS&?G_#2T5@<&e0206$^|Y}%uqgoG zB}F@x2&eChwvT9fT77kZ;RXuBPs5vD1mRw5yomAXM~4t!hv4MG&-Rttzp&6GNq$-P zel_r!R^Ma>1P!p-`f^E9vVLGw0Pt*=G{P`Wwe?IJ(PvtHlXZX+_HiOfel@&bnww%E zy@f`b4LfB_9m6m?E=i5tGY$|wwPRx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h^A*6+ZGZgNn?LWiHD&Zjb`Q$qjWS-?V4F*5O)`p0m#^Y6I zzZiw>-cT7PT3QCxpBHYCp#KjRN#W2`=-fef#;hgfGDGHgjW$k(IFsUO(1Y9Ke1LTG z9g@6$7pD>-3LxI}cok1=;a3>jGZTBbmDKF3qgs}oN7&D9G-X&E1SgcX|AYE!jqoNhA0MZGR%s28ALmfF(MGdOCu*spaFNI z);A~@fMsS*DOs4eL>!g_Dt3io|)HusZIIYdMT4eBSct zCKxkh68BC8k(F%*mgD+zOTP83xXjNs{K0D08wdt#q?~i6o_b{Qb7T-0(&j+_AN;Qr zO1l~&(HrY{j-)?$8~^|SFiAu~RGYHR zU|~+PIV;BNu3)w=!&A+)7+L<8U=Z&W+$z`Bymx1G&ruwxCtmTL1t6 M07*qoM6N<$g1NtQl>h($ literal 0 HcmV?d00001 diff --git a/survey_crm_generation/static/description/index.html b/survey_crm_generation/static/description/index.html new file mode 100644 index 0000000..de45f06 --- /dev/null +++ b/survey_crm_generation/static/description/index.html @@ -0,0 +1,445 @@ + + + + + + +Survey leads generation + + + +
    +

    Survey leads generation

    + + +

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

    +

    This module allows to generate leads/opportunities from surveys.

    +

    Table of contents

    + +
    +

    Configuration

    +

    To configure the leads/opportunities generation:

    +
      +
    1. Go to the configured survey.
    2. +
    3. In the CRM section of the Options tab, set Generate leads on.
    4. +
    5. Optionally you can set default tags for the generated leads.
    6. +
    7. You can set the crm team to assign the leads to.
    8. +
    +

    The questions marked to be shown in the lead description will be shown there.

    +
    +
    +

    Usage

    +

    Once the surveys are submited a lead/opportunity (depending on the default options for +the company) will be generated with a link to the answers.

    +
    +
    +

    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
      • +
      • Stefan ungureanu
      • +
      +
    • +
    +
    +
    +

    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:

    +

    chienandalu

    +

    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_crm_generation/static/tests/survey_crm_generation_tour.js b/survey_crm_generation/static/tests/survey_crm_generation_tour.js new file mode 100644 index 0000000..f53a35f --- /dev/null +++ b/survey_crm_generation/static/tests/survey_crm_generation_tour.js @@ -0,0 +1,48 @@ +odoo.define( + "survey_crm_generation.tour_test_survey_crm_generation", + function (require) { + "use strict"; + + const tour = require("web_tour.tour"); + + tour.register( + "test_survey_crm_generation", + { + test: true, + url: "/survey/start/08b4db21-66cc-4c69-a712-cc364c54902c", + }, + [ + { + content: "Start Survey", + trigger: "button.btn:contains('Start Survey')", + }, + { + content: "E-mail address", + trigger: + "div.js_question-wrapper:contains('E-mail address') textarea", + run: "text test@test.com", + }, + { + content: "Your company name?", + trigger: + "div.js_question-wrapper:contains('Your company name?') textarea", + run: "text Tecnativa", + }, + { + content: "And your name?", + trigger: + "div.js_question-wrapper:contains('And your name?') textarea", + run: "text Tecnativa", + }, + { + content: "Click Submit", + trigger: "button[value='finish']", + }, + { + content: "Thank you", + trigger: "h1:contains('Thank you!')", + }, + ] + ); + } +); diff --git a/survey_crm_generation/tests/__init__.py b/survey_crm_generation/tests/__init__.py new file mode 100644 index 0000000..7683754 --- /dev/null +++ b/survey_crm_generation/tests/__init__.py @@ -0,0 +1 @@ +from . import test_survey_crm_sale_generation diff --git a/survey_crm_generation/tests/test_survey_crm_sale_generation.py b/survey_crm_generation/tests/test_survey_crm_sale_generation.py new file mode 100644 index 0000000..fdb07cc --- /dev/null +++ b/survey_crm_generation/tests/test_survey_crm_sale_generation.py @@ -0,0 +1,49 @@ +# Copyright 2023 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from markupsafe import Markup + +from odoo.tests import HttpCase, tagged + +from odoo.addons.survey.tests.common import SurveyCase + + +@tagged("-at_install", "post_install") +class SurveyCrmGenerationCase(SurveyCase, HttpCase): + def setUp(self): + """We run the tour in the setup so we can share the tests case with other + modules""" + super().setUp() + self.oca_leads = self.env.ref("survey_crm_generation.oca_partnership_leads") + self.survey = self.env.ref("survey_crm_generation.become_partner") + initial_user_inputs = self.survey.user_input_ids + # Run the survey as a portal user and get the generated quotation + self.start_tour( + f"/survey/start/{self.survey.access_token}", + "test_survey_crm_generation", + login="portal", + ) + self.user_input = self.survey.user_input_ids - initial_user_inputs + self.generated_lead = self.user_input.opportunity_id + + +@tagged("-at_install", "post_install") +class SurveyCrmGenerationTests(SurveyCrmGenerationCase): + def test_lead_generation(self): + self.assertFalse(self.generated_lead.stage_id.is_won) + self.assertEqual(self.generated_lead.team_id, self.oca_leads) + self.assertEqual( + self.generated_lead.tag_ids, + ( + self.env.ref("survey_crm_generation.tag_oca_partnership") + + self.env.ref("survey_crm_generation.tag_survey_leads") + ), + ) + expected_lead_description = Markup( + "

    E-mail address: test@test.com\n" + "Your company name?: Tecnativa\n" + "And your name?: Tecnativa

    " + ) + self.assertEqual( + self.generated_lead.description, + expected_lead_description, + ) diff --git a/survey_crm_generation/views/crm_lead_views.xml b/survey_crm_generation/views/crm_lead_views.xml new file mode 100644 index 0000000..151b995 --- /dev/null +++ b/survey_crm_generation/views/crm_lead_views.xml @@ -0,0 +1,17 @@ + + + + crm.lead + + + + + + + + diff --git a/survey_crm_generation/views/survey_question_views.xml b/survey_crm_generation/views/survey_question_views.xml new file mode 100644 index 0000000..8cb1288 --- /dev/null +++ b/survey_crm_generation/views/survey_question_views.xml @@ -0,0 +1,18 @@ + + + + survey.question + + + + + + + + + + + diff --git a/survey_crm_generation/views/survey_survey_views.xml b/survey_crm_generation/views/survey_survey_views.xml new file mode 100644 index 0000000..d846082 --- /dev/null +++ b/survey_crm_generation/views/survey_survey_views.xml @@ -0,0 +1,23 @@ + + + + survey.survey + + + + + + + + + + + + diff --git a/survey_crm_generation/views/survey_user_input_views.xml b/survey_crm_generation/views/survey_user_input_views.xml new file mode 100644 index 0000000..6346ea7 --- /dev/null +++ b/survey_crm_generation/views/survey_user_input_views.xml @@ -0,0 +1,15 @@ + + + + survey.user_input + + + + + + + + diff --git a/survey_crm_generation_attachment/__init__.py b/survey_crm_generation_attachment/__init__.py new file mode 100644 index 0000000..9a7e03e --- /dev/null +++ b/survey_crm_generation_attachment/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/survey_crm_generation_attachment/__manifest__.py b/survey_crm_generation_attachment/__manifest__.py new file mode 100644 index 0000000..f4225bb --- /dev/null +++ b/survey_crm_generation_attachment/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2016-2020 Akretion France () +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Survey lead generation attachment", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Elabore", + 'summary': 'Link Attachments from Surveys to generated leads', + 'description': """ +Link Attachments from Surveys to generated leads +---------------------------------------------------- +* Create new attachments on lead creation, based on attached file of survey answer (survey.user_input.line) + +""", + "website": "https://www.elabore.coop", + "category": "", + "depends": ["survey_base","survey_crm_generation"], + "data": [ + + ], + "installable": True, + "auto_install":True +} diff --git a/survey_crm_generation_attachment/models/__init__.py b/survey_crm_generation_attachment/models/__init__.py new file mode 100644 index 0000000..a690749 --- /dev/null +++ b/survey_crm_generation_attachment/models/__init__.py @@ -0,0 +1 @@ +from . import survey_user_input \ No newline at end of file diff --git a/survey_crm_generation_attachment/models/survey_user_input.py b/survey_crm_generation_attachment/models/survey_user_input.py new file mode 100644 index 0000000..5bdc65b --- /dev/null +++ b/survey_crm_generation_attachment/models/survey_user_input.py @@ -0,0 +1,32 @@ + +import logging +import textwrap +import uuid + +from dateutil.relativedelta import relativedelta + +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError +from odoo.tools import float_is_zero + +_logger = logging.getLogger(__name__) + + +class SurveyUserInput(models.Model): + _inherit = 'survey.user_input' + + def _mark_done(self): + """Copy attachments to crm lead""" + res = super()._mark_done() + for user_input in self: + if user_input.survey_id.generate_leads and user_input.opportunity_id: + for user_input_line in user_input.user_input_line_ids: + if user_input_line.value_file: + self.env['ir.attachment'].create({ + 'res_model':'crm.lead', + 'res_id':user_input.opportunity_id.id, + 'name': user_input_line.value_file_fname, + 'datas': user_input_line.value_file, + 'type': 'binary' + }) + return res diff --git a/survey_crm_generation_training/__init__.py b/survey_crm_generation_training/__init__.py new file mode 100644 index 0000000..9a7e03e --- /dev/null +++ b/survey_crm_generation_training/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/survey_crm_generation_training/__manifest__.py b/survey_crm_generation_training/__manifest__.py new file mode 100644 index 0000000..5d403f4 --- /dev/null +++ b/survey_crm_generation_training/__manifest__.py @@ -0,0 +1,26 @@ +# Copyright 2016-2020 Akretion France () +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Survey Crm Generation Training", + 'summary': 'Customize lead creation from survey according to trainings', + 'description': """ +Customize lead creation from survey according to trainings +---------------------------------------------------- +* add event products in crm.lead +* Copy event products selected in survey answer, to created lead + +""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Elabore", + "website": "https://www.elabore.coop", + "category": "", + "depends": ["event","survey_crm_generation","survey_event_registration_generation","survey_event_base"], + "data": [ + "views/crm_lead_views.xml" + ], + "installable": True, + "auto_install":True +} diff --git a/survey_crm_generation_training/i18n/fr.po b/survey_crm_generation_training/i18n/fr.po new file mode 100644 index 0000000..650cee7 --- /dev/null +++ b/survey_crm_generation_training/i18n/fr.po @@ -0,0 +1,48 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_crm_generation_training +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-10-31 10:46+0000\n" +"PO-Revision-Date: 2023-10-31 10:46+0000\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_crm_generation_training +#: model_terms:ir.ui.view,arch_db:survey_crm_generation_training.crm_lead_view_for_crm_generation_training +msgid "" +"\n" +" Responses\n" +" " +msgstr "" +"\n" +" Réponses\n" +" " + +#. module: survey_crm_generation_training +#: model:ir.model.fields,field_description:survey_crm_generation_training.field_crm_lead__event_products_ids +#: model_terms:ir.ui.view,arch_db:survey_crm_generation_training.view_crm_case_opportunities_filter_survey_crm_generation_training +msgid "Event product" +msgstr "Produit de formation" + +#. module: survey_crm_generation_training +#: model:ir.model,name:survey_crm_generation_training.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Piste/Opportunité" + +#. module: survey_crm_generation_training +#: model:ir.model,name:survey_crm_generation_training.model_survey_user_input +msgid "Survey User Input" +msgstr "Entrée utilisateur du questionnaire" + +#. module: survey_crm_generation_training +#: model_terms:ir.ui.view,arch_db:survey_crm_generation_training.crm_lead_view_for_crm_generation_training +msgid "View survey answer that created this lead" +msgstr "Voir les réponses aux questionnaire qui ont créé cette piste" diff --git a/survey_crm_generation_training/models/__init__.py b/survey_crm_generation_training/models/__init__.py new file mode 100644 index 0000000..03a1f1f --- /dev/null +++ b/survey_crm_generation_training/models/__init__.py @@ -0,0 +1,2 @@ +from . import crm_lead +from . import survey_user_input \ No newline at end of file diff --git a/survey_crm_generation_training/models/crm_lead.py b/survey_crm_generation_training/models/crm_lead.py new file mode 100644 index 0000000..10c645d --- /dev/null +++ b/survey_crm_generation_training/models/crm_lead.py @@ -0,0 +1,23 @@ +# Copyright 2023 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class CrmLead(models.Model): + _inherit = "crm.lead" + + event_products_ids = fields.Many2many('product.product', string='Event product') + + + def action_view_survey_user_input_id(self): + form_view_id = self.env.ref('survey.survey_user_input_view_form').id + if self.survey_user_input_id: + action = self.env["ir.actions.actions"]._for_xml_id("survey.action_survey_user_input") + action['res_id'] = self.survey_user_input_id.id + action['domain'] = [('id', '=', self.survey_user_input_id.id)] + action['view_type'] = 'form' + action['view_mode'] = 'form' + action['binding_view_types'] = 'form' + action['view_id'] = form_view_id + action['views'] = [(form_view_id, 'form')] + return action diff --git a/survey_crm_generation_training/models/survey_user_input.py b/survey_crm_generation_training/models/survey_user_input.py new file mode 100644 index 0000000..ad83ffc --- /dev/null +++ b/survey_crm_generation_training/models/survey_user_input.py @@ -0,0 +1,15 @@ +# Copyright 2022 Tecnativa - David Vidal +# 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" + + def _create_opportunity_post_process(self): + """After lead creation from survey answer (module survey_crm_generation), + if answer (survey_user_input) contains event_products_ids, copy it in lead. + """ + self.opportunity_id.event_products_ids = self.event_products_ids.ids + + return super(SurveyUserInput, self)._create_opportunity_post_process() diff --git a/survey_crm_generation_training/views/crm_lead_views.xml b/survey_crm_generation_training/views/crm_lead_views.xml new file mode 100644 index 0000000..c7bf7f7 --- /dev/null +++ b/survey_crm_generation_training/views/crm_lead_views.xml @@ -0,0 +1,61 @@ + + + + crm.lead.search.opportunity.crm.generation.training" + + crm.lead + + + + + + + + + + + + + crm.lead + crm.lead.crm.generation.training + + +
    + +
    + + + + +
    + + + + crm.lead.tree.opportunity.survey.crm.generation.training + crm.lead + 1 + + + + + + + +
    diff --git a/survey_event_base/__init__.py b/survey_event_base/__init__.py new file mode 100644 index 0000000..9a7e03e --- /dev/null +++ b/survey_event_base/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/survey_event_base/__manifest__.py b/survey_event_base/__manifest__.py new file mode 100644 index 0000000..bb20698 --- /dev/null +++ b/survey_event_base/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2016-2020 Akretion France () +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Survey event base", + 'summary': 'Add field to reference events and product events in servey answers (survey.user_input)', + 'description': """ +Add field to reference events and product events in servey answers (survey.user_input) +---------------------------------------------------- +* +""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Elabore", + "website": "https://www.elabore.coop", + "category": "", + "depends": ["event","survey_base"], + "data": [ + + ], + "installable": True, +} diff --git a/survey_event_base/models/__init__.py b/survey_event_base/models/__init__.py new file mode 100644 index 0000000..a690749 --- /dev/null +++ b/survey_event_base/models/__init__.py @@ -0,0 +1 @@ +from . import survey_user_input \ No newline at end of file diff --git a/survey_event_base/models/survey_user_input.py b/survey_event_base/models/survey_user_input.py new file mode 100644 index 0000000..3ab4e18 --- /dev/null +++ b/survey_event_base/models/survey_user_input.py @@ -0,0 +1,61 @@ + +import logging +import textwrap +import uuid + +from dateutil.relativedelta import relativedelta + +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError +from odoo.tools import float_is_zero + +_logger = logging.getLogger(__name__) + + +class SurveyUserInput(models.Model): + _inherit = 'survey.user_input' + + events_ids = fields.Many2many('event.event', string='Events', compute="compute_events_ids", search="search_events_ids") #related events + event_products_ids = fields.Many2many('product.product', string='Event products', compute="compute_event_products_ids", search="search_event_products_ids") #related event products + + def search_events_ids(self, operator, value): + user_input_ids = set() + user_input_lines = self.env['survey.user_input.line'].search([('record_reference_model','=','event.event'),('record_reference','=', value)]) + for user_input_line in user_input_lines: + user_input_ids.add(user_input_line.user_input_id.id) + return [('id',operator,list(user_input_ids))] + + @api.depends('user_input_line_ids') + def compute_events_ids(self): + """set events_ids as answer of "event" question + """ + for user_input in self: + event_ids = [] + for user_input in self: + for user_input_line in user_input.user_input_line_ids: + if user_input_line.record_reference_model == 'event.event': + event_ids.append(user_input_line.record_reference) + user_input.events_ids = event_ids + + + def search_event_products_ids(self, operator, value): + user_input_ids = set() + user_input_lines = self.env['survey.user_input.line'].search([('record_reference_model','=','product.product'),('record_reference','=', value)]) + for user_input_line in user_input_lines: + user_input_ids.add(user_input_line.user_input_id.id) + return [('id',operator,list(user_input_ids))] + + + + @api.depends('user_input_line_ids') + def compute_event_products_ids(self): + """set event_products_ids as answer of "event product" or "multiple event products" question + """ + for user_input in self: + event_products_ids = [] + for user_input in self: + for user_input_line in user_input.user_input_line_ids: + if user_input_line.record_reference_model == 'product.product': + event_products_ids.append(user_input_line.record_reference) + user_input.event_products_ids = event_products_ids + diff --git a/survey_event_registration_generation/__init__.py b/survey_event_registration_generation/__init__.py new file mode 100644 index 0000000..9a7e03e --- /dev/null +++ b/survey_event_registration_generation/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/survey_event_registration_generation/__manifest__.py b/survey_event_registration_generation/__manifest__.py new file mode 100644 index 0000000..2cd7233 --- /dev/null +++ b/survey_event_registration_generation/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2016-2020 Akretion France () +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Survey event registration generation", + "version": "16.0.0.0.0", + "license": "AGPL-3", + "author": "Elabore", + "website": "https://www.elabore.coop", + "category": "", + "depends": ["survey", "survey_base"], + "data": [ + 'views/survey_question_views.xml', + 'views/survey_survey_views.xml', + ], + "installable": True, +} diff --git a/survey_event_registration_generation/models/__init__.py b/survey_event_registration_generation/models/__init__.py new file mode 100644 index 0000000..39e22bd --- /dev/null +++ b/survey_event_registration_generation/models/__init__.py @@ -0,0 +1,3 @@ +from . import survey_user_input +from . import survey_survey +from . import survey_question \ No newline at end of file diff --git a/survey_event_registration_generation/models/survey_question.py b/survey_event_registration_generation/models/survey_question.py new file mode 100644 index 0000000..8ec4d7c --- /dev/null +++ b/survey_event_registration_generation/models/survey_question.py @@ -0,0 +1,38 @@ +from email.policy import default +from odoo import models, fields, api + + +class SurveyQuestion(models.Model): + _inherit = 'survey.question' + + event_registration_allowed_field_ids = fields.Many2many( + comodel_name="ir.model.fields", + compute="_compute_event_registration_allowed_field_ids", + ) #fields of event registration, proposed in question, to associate answer to good event registration field, during event registration creation + event_registration_field = fields.Many2one( + string="Event registration field", + comodel_name="ir.model.fields", + domain="[('id', 'in', event_registration_allowed_field_ids)]", + ) #field of event registration selected, used in event registration creation + + @api.depends("question_type") + def _compute_event_registration_allowed_field_ids(self): + """propose all event registration fields corresponding to selected question type + """ + type_mapping = { + "char_box": ["char", "text"], + "text_box": ["html"], + "numerical_box": ["integer", "float", "html", "char"], + "date": ["date", "text", "char"], + "datetime": ["datetime", "html", "char"], + "simple_choice": ["many2one", "html", "char"], + "multiple_choice": ["many2many", "html", "char"], + } + for record in self: + search_domain = [ + ("model", "=", "event.registration"), + ("ttype", "in", type_mapping.get(record.question_type, [])), + ] + + record.event_registration_allowed_field_ids = self.env["ir.model.fields"].search(search_domain).ids + \ No newline at end of file diff --git a/survey_event_registration_generation/models/survey_survey.py b/survey_event_registration_generation/models/survey_survey.py new file mode 100644 index 0000000..d241d97 --- /dev/null +++ b/survey_event_registration_generation/models/survey_survey.py @@ -0,0 +1,12 @@ +# Copyright 2023 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class SurveySurvey(models.Model): + _inherit = "survey.survey" + + generate_registration = fields.Boolean( + help="Generate event registration for selected event", + ) + diff --git a/survey_event_registration_generation/models/survey_user_input.py b/survey_event_registration_generation/models/survey_user_input.py new file mode 100644 index 0000000..3aed2ec --- /dev/null +++ b/survey_event_registration_generation/models/survey_user_input.py @@ -0,0 +1,82 @@ + +import logging +import textwrap +import uuid + +from dateutil.relativedelta import relativedelta + +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError +from odoo.tools import float_is_zero + +_logger = logging.getLogger(__name__) + + +class SurveyUserInput(models.Model): + _inherit = 'survey.user_input' + + registration_id = fields.Many2one('event.registration', 'Event registration') #registration created automaticaly on survey post + + + + def _prepare_registration(self): + """Extract registration values from the answers""" + + elegible_inputs = self.user_input_line_ids.filtered( + lambda x: x.question_id.event_registration_field and not x.skipped + ) + + vals = {} + for line in elegible_inputs: + if line.question_id.event_registration_field.ttype == 'many2one': + vals[line.question_id.event_registration_field.name] = line.suggested_answer_id.record_reference + else: + vals[line.question_id.event_registration_field.name] = line[f"value_{line.answer_type}"] + + + return vals + + def _create_registration_post_process(self, registration): + """After creating the event registration send an internal message with the input link""" + registration.message_post_with_view( + "mail.message_origin_link", + values={"self": registration, "origin": self}, + subtype_id=self.env.ref("mail.mt_note").id, + ) + + def _mark_done(self): + """Generate registration when the survey is submitted""" + for user_input in self.filtered( + lambda r: r.survey_id.generate_registration and not self.registration_id + ): + vals = user_input._prepare_registration() + + # check doublon : if old draft registration already exists : update it + email = vals.get('email') + event_id = vals.get('event_id') + old_registration = False + if email and event_id: + old_registration = self.env["event.registration"].search([('email','=',email),('event_id','=',event_id)]) + if old_registration: + old_registration = old_registration[0] + if old_registration.state == 'draft': + registration = old_registration + registration.write(vals) + registration.message_post_with_view( + "mail.message_origin_link", + values={"edit":True, "self": registration, "origin": user_input}, + subtype_id=self.env.ref("mail.mt_note").id, + ) + + if not old_registration: + registration = self.env["event.registration"].create(vals) + self._create_registration_post_process(registration) + + self.update({"registration_id": registration.id}) + res = super()._mark_done() + + # after all, set partner id of registration as the partner of user input + for user_input in self: + if user_input.registration_id and user_input.partner_id: + user_input.registration_id.partner_id = user_input.partner_id + return res diff --git a/survey_event_registration_generation/security/ir.model.access.csv b/survey_event_registration_generation/security/ir.model.access.csv new file mode 100644 index 0000000..3c17417 --- /dev/null +++ b/survey_event_registration_generation/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_ir_model_fields_survey_user,ir.model.fields.survey.user,base.model_ir_model_fields,survey.group_survey_user,1,0,0,0 \ No newline at end of file diff --git a/survey_event_registration_generation/views/survey_question_views.xml b/survey_event_registration_generation/views/survey_question_views.xml new file mode 100644 index 0000000..5b5ddcf --- /dev/null +++ b/survey_event_registration_generation/views/survey_question_views.xml @@ -0,0 +1,19 @@ + + + + + + survey.question + + + + + + + + + + + + + diff --git a/survey_event_registration_generation/views/survey_survey_views.xml b/survey_event_registration_generation/views/survey_survey_views.xml new file mode 100644 index 0000000..c4edeef --- /dev/null +++ b/survey_event_registration_generation/views/survey_survey_views.xml @@ -0,0 +1,16 @@ + + + + + survey.survey + + + + + + + + + + + diff --git a/survey_event_registration_generation_attachment/__init__.py b/survey_event_registration_generation_attachment/__init__.py new file mode 100644 index 0000000..9a7e03e --- /dev/null +++ b/survey_event_registration_generation_attachment/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/survey_event_registration_generation_attachment/__manifest__.py b/survey_event_registration_generation_attachment/__manifest__.py new file mode 100644 index 0000000..19ce4b4 --- /dev/null +++ b/survey_event_registration_generation_attachment/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright 2016-2020 Akretion France () +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Survey event generation attachment", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Elabore", + "website": "https://www.elabore.coop", + "category": "", + 'summary': 'Link Attachments from Surveys to generated event registration', + 'description': """ +Link Attachments from Surveys to generated event registration +---------------------------------------------------- +* Create new attachments on event registration creation, based on attached file of survey answer (survey.user_input.line) + +""", + "depends": ["survey_base","survey_event_registration_generation"], + "data": [ + + ], + "installable": True, + "auto_install":True +} diff --git a/survey_event_registration_generation_attachment/models/__init__.py b/survey_event_registration_generation_attachment/models/__init__.py new file mode 100644 index 0000000..a690749 --- /dev/null +++ b/survey_event_registration_generation_attachment/models/__init__.py @@ -0,0 +1 @@ +from . import survey_user_input \ No newline at end of file diff --git a/survey_event_registration_generation_attachment/models/survey_user_input.py b/survey_event_registration_generation_attachment/models/survey_user_input.py new file mode 100644 index 0000000..5a398d2 --- /dev/null +++ b/survey_event_registration_generation_attachment/models/survey_user_input.py @@ -0,0 +1,32 @@ + +import logging +import textwrap +import uuid + +from dateutil.relativedelta import relativedelta + +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError +from odoo.tools import float_is_zero + +_logger = logging.getLogger(__name__) + + +class SurveyUserInput(models.Model): + _inherit = 'survey.user_input' + + def _mark_done(self): + """Copy attachments to event registration""" + res = super()._mark_done() + for user_input in self: + if user_input.survey_id.generate_registration and user_input.registration_id: + for user_input_line in user_input.user_input_line_ids: + if user_input_line.value_file: + self.env['ir.attachment'].create({ + 'res_model':'event.registration', + 'res_id':user_input.registration_id.id, + 'name': user_input_line.value_file_fname, + 'datas': user_input_line.value_file, + 'type': 'binary' + }) + return res diff --git a/survey_event_speaker_generation/__init__.py b/survey_event_speaker_generation/__init__.py new file mode 100644 index 0000000..9a7e03e --- /dev/null +++ b/survey_event_speaker_generation/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/survey_event_speaker_generation/__manifest__.py b/survey_event_speaker_generation/__manifest__.py new file mode 100644 index 0000000..ae11061 --- /dev/null +++ b/survey_event_speaker_generation/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2016-2020 Akretion France () +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Survey event speaker generation", + "version": "16.0.0.0.0", + "license": "AGPL-3", + "author": "Elabore", + "website": "https://www.elabore.coop", + "category": "", + "depends": ["survey", "event_speaker"], + "data": [ + 'views/mail_templates_chatter.xml', + 'views/survey_survey_views.xml', + ], + "installable": True, +} diff --git a/survey_event_speaker_generation/i18n/fr.po b/survey_event_speaker_generation/i18n/fr.po new file mode 100644 index 0000000..ee79186 --- /dev/null +++ b/survey_event_speaker_generation/i18n/fr.po @@ -0,0 +1,56 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey_event_speaker_generation +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-09-19 14:42+0000\n" +"PO-Revision-Date: 2023-09-19 14:42+0000\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_event_speaker_generation +#: model_terms:ir.ui.view,arch_db:survey_event_speaker_generation.survey_form +msgid "Events speakers" +msgstr "Intervenants d'événements" + +#. module: survey_event_speaker_generation +#: model:ir.model.fields,field_description:survey_event_speaker_generation.field_survey_user_input__speaker_id +msgid "Event speaker" +msgstr "Intervenants" + +#. module: survey_event_speaker_generation +#: model:ir.model.fields,field_description:survey_event_speaker_generation.field_survey_survey__generate_speaker +msgid "Generate Speaker" +msgstr "Générer un intervenant" + +#. module: survey_event_speaker_generation +#: model:ir.model.fields,help:survey_event_speaker_generation.field_survey_survey__generate_speaker +msgid "Generate speaker for selected event" +msgstr "Générer un intervenant pour l'événement selectionné" + +#. module: survey_event_speaker_generation +#: model:ir.model,name:survey_event_speaker_generation.model_survey_survey +msgid "Survey" +msgstr "Questionnaire" + +#. module: survey_event_speaker_generation +#: model:ir.model,name:survey_event_speaker_generation.model_survey_user_input +msgid "Survey User Input" +msgstr "Entrée utilisateur du questionnaire" + +#. module: survey_event_speaker_generation +#: model_terms:ir.ui.view,arch_db:survey_event_speaker_generation.message_event_speaker_assigned +msgid "from survey answers" +msgstr "depuis la réponse au questionnaire" + +#. module: survey_event_speaker_generation +#: model_terms:ir.ui.view,arch_db:survey_event_speaker_generation.message_event_speaker_assigned +msgid "has been assigned to" +msgstr "a été assigné à" diff --git a/survey_event_speaker_generation/models/__init__.py b/survey_event_speaker_generation/models/__init__.py new file mode 100644 index 0000000..6eda04e --- /dev/null +++ b/survey_event_speaker_generation/models/__init__.py @@ -0,0 +1,2 @@ +from . import survey_user_input +from . import survey_survey \ No newline at end of file diff --git a/survey_event_speaker_generation/models/survey_survey.py b/survey_event_speaker_generation/models/survey_survey.py new file mode 100644 index 0000000..55384ef --- /dev/null +++ b/survey_event_speaker_generation/models/survey_survey.py @@ -0,0 +1,11 @@ +# Copyright 2023 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import fields, models + + +class SurveySurvey(models.Model): + _inherit = "survey.survey" + + generate_speaker = fields.Boolean( + help="Generate speaker for selected event", + ) #Field to check if user wants to generate a speaker on survey submit diff --git a/survey_event_speaker_generation/models/survey_user_input.py b/survey_event_speaker_generation/models/survey_user_input.py new file mode 100644 index 0000000..356f0d7 --- /dev/null +++ b/survey_event_speaker_generation/models/survey_user_input.py @@ -0,0 +1,46 @@ + +import logging +import textwrap +import uuid + +from dateutil.relativedelta import relativedelta + +from odoo import api, fields, models, _, Command +from odoo.exceptions import ValidationError +from odoo.tools import float_is_zero + +_logger = logging.getLogger(__name__) + + +class SurveyUserInput(models.Model): + _inherit = 'survey.user_input' + + speaker_id = fields.Many2one('res.partner', 'Event speaker') #created partner when submit survey + + def _get_event(self): + """Find event selected, in all answers""" + for line in self.user_input_line_ids: + if line.question_id.question_type == 'event' and not line.skipped \ + and line.answer_type != "suggestion" \ + and line.question_id.event_registration_field.name != "comment": + return line.value_event + + + def _create_speaker_post_process(self, speaker): + """Add message to chatter to note speaker creation and association with event""" + speaker.message_post_with_view( + "survey_event_speaker_generation.message_event_speaker_assigned", + values={"speaker": speaker, "user_input": self, "event":self._get_event()}, + subtype_id=self.env.ref("mail.mt_note").id, + ) + + def _mark_done(self): + """Attach partner as speaker of event""" + + res = super()._mark_done() + for user_input in self.filtered(lambda r: r.survey_id.generate_speaker and not r.speaker_id and r.partner_id): + user_input.update({"speaker_id": user_input.partner_id.id}) + user_input._get_event().speakers = [Command.link(user_input.speaker_id.id)] + user_input._create_speaker_post_process(user_input.speaker_id) + + return res diff --git a/survey_event_speaker_generation/views/mail_templates_chatter.xml b/survey_event_speaker_generation/views/mail_templates_chatter.xml new file mode 100644 index 0000000..025f329 --- /dev/null +++ b/survey_event_speaker_generation/views/mail_templates_chatter.xml @@ -0,0 +1,22 @@ + + + + + + + + diff --git a/survey_event_speaker_generation/views/survey_survey_views.xml b/survey_event_speaker_generation/views/survey_survey_views.xml new file mode 100644 index 0000000..7b451f8 --- /dev/null +++ b/survey_event_speaker_generation/views/survey_survey_views.xml @@ -0,0 +1,15 @@ + + + + + survey.survey + + + + + + + + + + diff --git a/survey_event_visibility/__init__.py b/survey_event_visibility/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/survey_event_visibility/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/survey_event_visibility/__manifest__.py b/survey_event_visibility/__manifest__.py new file mode 100644 index 0000000..95c632a --- /dev/null +++ b/survey_event_visibility/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2016-2020 Akretion France () +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Survey event visibility", + "version": "16.0.0.0.0", + "license": "AGPL-3", + "author": "Elabore", + 'summary': 'Add visibility field in event stage', + 'description': """ +Add visibility information in product and events +---------------------------------------------------- + +The product and event visibility is computed from event stage visibility. +""", + "website": "https://www.elabore.coop", + "category": "", + "depends": ["survey"], + "data": [ + 'views/event_stage_views.xml', + ], + "installable": True, +} diff --git a/survey_event_visibility/models/__init__.py b/survey_event_visibility/models/__init__.py new file mode 100644 index 0000000..354e2c0 --- /dev/null +++ b/survey_event_visibility/models/__init__.py @@ -0,0 +1,3 @@ +from . import event_stage +from . import event_event +from . import product_product \ No newline at end of file diff --git a/survey_event_visibility/models/event_event.py b/survey_event_visibility/models/event_event.py new file mode 100644 index 0000000..58fa69e --- /dev/null +++ b/survey_event_visibility/models/event_event.py @@ -0,0 +1,28 @@ +from odoo import models, fields, api + + +class EventEvent(models.Model): + _inherit = 'event.event' + + visible_in_survey = fields.Boolean('Visible in survey', related='stage_id.visible_in_survey', readonly=True, + help="""Events in step configured as 'visible in survey'.""") + + def get_events_from_event_products(self, product_ids=None, only_visible_in_survey=False): + """Search events in stage filtered by product present in ticket.. + + Args: + product_ids (list[product.product ids], optional): to filter only events with tickets using product in this list. Defaults to None. + + Returns: + event.event: Events + """ + event_search = [] + if product_ids: + event_tickets = self.env['event.event.ticket'].search([('product_id','in',product_ids)]) + event_search.append(('event_ticket_ids','in',event_tickets.ids)) + + if only_visible_in_survey: + event_search.append(('visible_in_survey','=',True)) + + return self.env['event.event'].search(event_search) + \ No newline at end of file diff --git a/survey_event_visibility/models/event_stage.py b/survey_event_visibility/models/event_stage.py new file mode 100644 index 0000000..68f5c9c --- /dev/null +++ b/survey_event_visibility/models/event_stage.py @@ -0,0 +1,7 @@ +from odoo import models, fields, api + + +class EventStage(models.Model): + _inherit = 'event.stage' + + visible_in_survey = fields.Boolean('Visible in surveys') #if checked, only events on this stage are visible in surveys \ No newline at end of file diff --git a/survey_event_visibility/models/product_product.py b/survey_event_visibility/models/product_product.py new file mode 100644 index 0000000..8f7b50a --- /dev/null +++ b/survey_event_visibility/models/product_product.py @@ -0,0 +1,23 @@ +from odoo import models, fields, api + + +class ProductProduct(models.Model): + _inherit = 'product.product' + + visible_in_survey = fields.Boolean('Visible in survey', compute='_compute_visible_in_survey', readonly=True, + help="""Events in step configured as 'visible in survey'.""") + + + def _compute_visible_in_survey(self): + #get all events in step 'visible in survey' + product_ids = set() + events = self.env['event.event'].search([('visible_in_survey','=',True)]) + for event in events: + for ticket in event.event_ticket_ids: + product_ids.add(ticket.product_id.id) + for event_product in self: + if event_product.id in product_ids: + event_product.visible_in_survey = True + else: + event_product.visible_in_survey = False + diff --git a/survey_event_visibility/views/event_stage_views.xml b/survey_event_visibility/views/event_stage_views.xml new file mode 100644 index 0000000..22937b4 --- /dev/null +++ b/survey_event_visibility/views/event_stage_views.xml @@ -0,0 +1,31 @@ + + + + + + + event.stage.view.form.survey.event.registration.generation + event.stage + + + + + + + + + + + + event.stage.view.tree.survey.event.registration.generation + event.stage + + + + + + + + + +