diff --git a/.gitea/workflows/pre-commit.yml b/.gitea/workflows/pre-commit.yml index 61d456b..039e8d9 100644 --- a/.gitea/workflows/pre-commit.yml +++ b/.gitea/workflows/pre-commit.yml @@ -3,7 +3,7 @@ name: pre-commit on: pull_request: branches: - - "16.0*" + - "18.0*" jobs: pre-commit: diff --git a/.pylintrc b/.pylintrc index 652a781..8d996d7 100644 --- a/.pylintrc +++ b/.pylintrc @@ -10,7 +10,7 @@ manifest-required-authors=Elabore manifest-required-keys=license manifest-deprecated-keys=description,active license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3 -valid-odoo-versions=16.0 +valid-odoo-versions=18.0 [MESSAGES CONTROL] disable=all diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory index 14ca356..aa43e02 100644 --- a/.pylintrc-mandatory +++ b/.pylintrc-mandatory @@ -9,7 +9,7 @@ manifest-required-authors=Elabore manifest-required-keys=license manifest-deprecated-keys=description,active license-allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3 -valid-odoo-versions=16.0 +valid-odoo-versions=18.0 [MESSAGES CONTROL] disable=all diff --git a/survey_base/__init__.py b/survey_base/__init__.py deleted file mode 100644 index 9a7e03e..0000000 --- a/survey_base/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import models \ No newline at end of file diff --git a/survey_base/__manifest__.py b/survey_base/__manifest__.py deleted file mode 100644 index adee7e2..0000000 --- a/survey_base/__manifest__.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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/i18n/fr.po b/survey_base/i18n/fr.po deleted file mode 100644 index 45d1244..0000000 --- a/survey_base/i18n/fr.po +++ /dev/null @@ -1,54 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * survey_base -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-17 14:44+0000\n" -"PO-Revision-Date: 2026-02-17 14:44+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_base -#: model:ir.model.fields,field_description:survey_base.field_survey_user_input_line__value_file -msgid "File" -msgstr "Fichier" - -#. module: survey_base -#: model:ir.model.fields,field_description:survey_base.field_survey_user_input_line__value_file_fname -msgid "File Name" -msgstr "Nom du fichier" - -#. module: survey_base -#: model:ir.model.fields,field_description:survey_base.field_survey_question_answer__record_reference -#: model:ir.model.fields,field_description:survey_base.field_survey_user_input_line__record_reference -msgid "Record" -msgstr "Enregistrement" - -#. module: survey_base -#: model:ir.model.fields,field_description:survey_base.field_survey_question_answer__record_reference_model -#: model:ir.model.fields,field_description:survey_base.field_survey_user_input_line__record_reference_model -msgid "Record Model" -msgstr "Modèle de l'enregistrement" - -#. module: survey_base -#: model:ir.model.fields,field_description:survey_base.field_survey_question_answer__smart_search -#: model:ir.model.fields,field_description:survey_base.field_survey_user_input_line__smart_search -msgid "Smart Search" -msgstr "Recherche intelligente" - -#. module: survey_base -#: model:ir.model,name:survey_base.model_survey_question_answer -msgid "Survey Label" -msgstr "Étiquette du sondage" - -#. module: survey_base -#: model:ir.model,name:survey_base.model_survey_user_input_line -msgid "Survey User Input Line" -msgstr "Ligne d'entrée pour l'utilisateur du sondage" diff --git a/survey_base/models/__init__.py b/survey_base/models/__init__.py deleted file mode 100644 index 4487824..0000000 --- a/survey_base/models/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 8af6e75..0000000 --- a/survey_base/models/survey_question_answer.py +++ /dev/null @@ -1,19 +0,0 @@ - -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 deleted file mode 100644 index f19c031..0000000 --- a/survey_base/models/survey_user_input_line.py +++ /dev/null @@ -1,46 +0,0 @@ - -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 deleted file mode 100644 index f60b817..0000000 --- a/survey_contact_generation/README.rst +++ /dev/null @@ -1,109 +0,0 @@ -========================== -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 deleted file mode 100644 index 0650744..0000000 --- a/survey_contact_generation/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import models diff --git a/survey_contact_generation/__manifest__.py b/survey_contact_generation/__manifest__.py deleted file mode 100644 index cede82f..0000000 --- a/survey_contact_generation/__manifest__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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","partner_firstname"], - "data": [ - 'security/ir.model.access.csv', - "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 deleted file mode 100644 index 85fcc64..0000000 --- a/survey_contact_generation/demo/survey_contact_generation_demo.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - 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 deleted file mode 100644 index 1a29c04..0000000 --- a/survey_contact_generation/i18n/es.po +++ /dev/null @@ -1,168 +0,0 @@ -# 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 deleted file mode 100644 index 44c9217..0000000 --- a/survey_contact_generation/i18n/fr.po +++ /dev/null @@ -1,64 +0,0 @@ -# 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 deleted file mode 100644 index 93bb3b4..0000000 --- a/survey_contact_generation/models/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 577d35b..0000000 --- a/survey_contact_generation/models/survey_question.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2022 Tecnativa - David Vidal -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import api, fields, models - -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"], -} - -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): - - 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 deleted file mode 100644 index 9632102..0000000 --- a/survey_contact_generation/models/survey_survey.py +++ /dev/null @@ -1,11 +0,0 @@ -# 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 deleted file mode 100644 index a0fc084..0000000 --- a/survey_contact_generation/models/survey_user_input.py +++ /dev/null @@ -1,94 +0,0 @@ -# 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" - and not (x.question_id.comments_allowed and x.question_id.comment_count_as_answer and x.question_id.res_partner_field.ttype in ("many2one","many2many")) #exclude comments answer in case of many2one or many2many reference - ) - 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, []) - if line.suggested_answer_id: # exclude "comment" answer - 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") - firstname = vals.get("firstname") - lastname = vals.get("lastname") - - # check doublon only if email send - if not email: - continue - - #search if partner exists with same email, firstname and lastname depending on submitted data - doublon_domain = [] - if email: - doublon_domain.append(("email", "ilike", email)) - if firstname: - doublon_domain.append(("firstname", "ilike", firstname)) - if lastname: - doublon_domain.append(("lastname", "ilike", lastname)) - - if doublon_domain: - partner = self.env["res.partner"].search(doublon_domain, 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 deleted file mode 100644 index 18966aa..0000000 --- a/survey_contact_generation/readme/CONFIGURE.rst +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index e3851e7..0000000 --- a/survey_contact_generation/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,5 +0,0 @@ -* `Tecnativa `_ - - * David Vidal - * Ernesto Tejeda - * Stefan Ungureanu diff --git a/survey_contact_generation/readme/DESCRIPTION.rst b/survey_contact_generation/readme/DESCRIPTION.rst deleted file mode 100644 index ac10b74..0000000 --- a/survey_contact_generation/readme/DESCRIPTION.rst +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index f7c7830..0000000 --- a/survey_contact_generation/readme/USAGE.rst +++ /dev/null @@ -1,3 +0,0 @@ -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/security/ir.model.access.csv b/survey_contact_generation/security/ir.model.access.csv deleted file mode 100644 index 3c17417..0000000 --- a/survey_contact_generation/security/ir.model.access.csv +++ /dev/null @@ -1,2 +0,0 @@ -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_contact_generation/static/description/icon.png b/survey_contact_generation/static/description/icon.png deleted file mode 100644 index ae0af81..0000000 Binary files a/survey_contact_generation/static/description/icon.png and /dev/null differ diff --git a/survey_contact_generation/static/description/index.html b/survey_contact_generation/static/description/index.html deleted file mode 100644 index 64dc95c..0000000 --- a/survey_contact_generation/static/description/index.html +++ /dev/null @@ -1,450 +0,0 @@ - - - - - - -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 deleted file mode 100644 index 25e3d2b..0000000 --- a/survey_contact_generation/static/tests/survey_contact_generation_tour.js +++ /dev/null @@ -1,82 +0,0 @@ -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 deleted file mode 100644 index d4c56fb..0000000 --- a/survey_contact_generation/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index ff24ca9..0000000 --- a/survey_contact_generation/tests/test_survey_contact_generation.py +++ /dev/null @@ -1,31 +0,0 @@ -# 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 deleted file mode 100644 index e235807..0000000 --- a/survey_contact_generation/views/survey_question_views.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - 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 deleted file mode 100644 index c901a1b..0000000 --- a/survey_contact_generation/views/survey_survey_views.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - survey.survey - - - - - - - - - - diff --git a/survey_crm_generation/README.rst b/survey_crm_generation/README.rst deleted file mode 100644 index 698a837..0000000 --- a/survey_crm_generation/README.rst +++ /dev/null @@ -1,105 +0,0 @@ -======================= -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 deleted file mode 100644 index 0650744..0000000 --- a/survey_crm_generation/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import models diff --git a/survey_crm_generation/__manifest__.py b/survey_crm_generation/__manifest__.py deleted file mode 100644 index ef8ecb5..0000000 --- a/survey_crm_generation/__manifest__.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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 deleted file mode 100644 index 638631c..0000000 --- a/survey_crm_generation/demo/survey_crm_demo.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - 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 deleted file mode 100644 index 2dfe41d..0000000 --- a/survey_crm_generation/i18n/es.po +++ /dev/null @@ -1,137 +0,0 @@ -# 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 deleted file mode 100644 index 836a32f..0000000 --- a/survey_crm_generation/i18n/fr.po +++ /dev/null @@ -1,85 +0,0 @@ -# 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 deleted file mode 100644 index e27bb41..0000000 --- a/survey_crm_generation/models/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index 0471593..0000000 --- a/survey_crm_generation/models/crm_lead.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 deleted file mode 100644 index f5163eb..0000000 --- a/survey_crm_generation/models/survey_question.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 deleted file mode 100644 index 62b1eaf..0000000 --- a/survey_crm_generation/models/survey_survey.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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 deleted file mode 100644 index 3593349..0000000 --- a/survey_crm_generation/models/survey_user_input.py +++ /dev/null @@ -1,77 +0,0 @@ -# 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(), - "type": "lead" - } - - 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 deleted file mode 100644 index 4c55dc7..0000000 --- a/survey_crm_generation/readme/CONFIGURE.rst +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100644 index cbf3a46..0000000 --- a/survey_crm_generation/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,4 +0,0 @@ -* `Tecnativa `_ - - * David Vidal - * Stefan ungureanu diff --git a/survey_crm_generation/readme/DESCRIPTION.rst b/survey_crm_generation/readme/DESCRIPTION.rst deleted file mode 100644 index f115b35..0000000 --- a/survey_crm_generation/readme/DESCRIPTION.rst +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 79a88f5..0000000 --- a/survey_crm_generation/readme/USAGE.rst +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index ae0af81..0000000 Binary files a/survey_crm_generation/static/description/icon.png and /dev/null differ diff --git a/survey_crm_generation/static/description/index.html b/survey_crm_generation/static/description/index.html deleted file mode 100644 index de45f06..0000000 --- a/survey_crm_generation/static/description/index.html +++ /dev/null @@ -1,445 +0,0 @@ - - - - - - -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 deleted file mode 100644 index f53a35f..0000000 --- a/survey_crm_generation/static/tests/survey_crm_generation_tour.js +++ /dev/null @@ -1,48 +0,0 @@ -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 deleted file mode 100644 index 7683754..0000000 --- a/survey_crm_generation/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index fdb07cc..0000000 --- a/survey_crm_generation/tests/test_survey_crm_sale_generation.py +++ /dev/null @@ -1,49 +0,0 @@ -# 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 deleted file mode 100644 index 151b995..0000000 --- a/survey_crm_generation/views/crm_lead_views.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - crm.lead - - - - - - - - diff --git a/survey_crm_generation/views/survey_question_views.xml b/survey_crm_generation/views/survey_question_views.xml deleted file mode 100644 index 8cb1288..0000000 --- a/survey_crm_generation/views/survey_question_views.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - survey.question - - - - - - - - - - - diff --git a/survey_crm_generation/views/survey_survey_views.xml b/survey_crm_generation/views/survey_survey_views.xml deleted file mode 100644 index d846082..0000000 --- a/survey_crm_generation/views/survey_survey_views.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - survey.survey - - - - - - - - - - - - diff --git a/survey_crm_generation/views/survey_user_input_views.xml b/survey_crm_generation/views/survey_user_input_views.xml deleted file mode 100644 index 6346ea7..0000000 --- a/survey_crm_generation/views/survey_user_input_views.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - survey.user_input - - - - - - - - diff --git a/survey_crm_generation_attachment/__init__.py b/survey_crm_generation_attachment/__init__.py deleted file mode 100644 index 9a7e03e..0000000 --- a/survey_crm_generation_attachment/__init__.py +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index f4225bb..0000000 --- a/survey_crm_generation_attachment/__manifest__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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 deleted file mode 100644 index a690749..0000000 --- a/survey_crm_generation_attachment/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 5bdc65b..0000000 --- a/survey_crm_generation_attachment/models/survey_user_input.py +++ /dev/null @@ -1,32 +0,0 @@ - -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 deleted file mode 100644 index 9a7e03e..0000000 --- a/survey_crm_generation_training/__init__.py +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 5660e54..0000000 --- a/survey_crm_generation_training/__manifest__.py +++ /dev/null @@ -1,26 +0,0 @@ -# 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 type in crm.lead -* Copy event type 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 deleted file mode 100644 index b651976..0000000 --- a/survey_crm_generation_training/i18n/fr.po +++ /dev/null @@ -1,53 +0,0 @@ -# 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: 2024-12-04 10:52+0000\n" -"PO-Revision-Date: 2024-12-04 10:52+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_terms:ir.ui.view,arch_db:survey_crm_generation_training.view_crm_case_leads_filter_survey_crm_generation_training -#: model_terms:ir.ui.view,arch_db:survey_crm_generation_training.view_crm_case_opportunities_filter_survey_crm_generation_training -msgid "Event type" -msgstr "Formation(s)" - -#. module: survey_crm_generation_training -#: model:ir.model.fields,field_description:survey_crm_generation_training.field_crm_lead__event_type_ids -msgid "Formation" -msgstr "" - -#. 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 for custom matrix" -msgstr "Entrée des utilisateurs de l'enquête pour la matrice personnalisée" - -#. 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 deleted file mode 100644 index 03a1f1f..0000000 --- a/survey_crm_generation_training/models/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index fa29479..0000000 --- a/survey_crm_generation_training/models/crm_lead.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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_type_ids = fields.Many2many('event.type', string='Formation') - - - 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 deleted file mode 100644 index ee3e2f1..0000000 --- a/survey_crm_generation_training/models/survey_user_input.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2022 Tecnativa - David Vidal -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import fields, models, _, Command - - -class SurveyUserInput(models.Model): - _inherit = "survey.user_input" - - def _prepare_opportunity(self): - res = super(SurveyUserInput, self)._prepare_opportunity() - - #if answer (survey_user_input) contains event_type_ids, copy it in lead. - res["event_type_ids"] = [Command.set(self.event_type_ids.ids)] - - - # use survey responsible as seller instead of manager of sale department - if self.survey_id.user_id: - res["user_id"] = self.survey_id.user_id.id - - - return res - diff --git a/survey_crm_generation_training/views/crm_lead_views.xml b/survey_crm_generation_training/views/crm_lead_views.xml deleted file mode 100644 index e40f31b..0000000 --- a/survey_crm_generation_training/views/crm_lead_views.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - crm.lead.search.opportunity.crm.generation.training" - - crm.lead - - - - - - - - - - - - crm.lead.search.leads.crm.generation.training" - - crm.lead - - - - - - - - - - - - - - - crm.lead - crm.lead.crm.generation.training - - -
    - -
    - - - - - -
    -
    - - - - crm.lead.tree.opportunity.survey.crm.generation.training - crm.lead - 1 - - - - - - - - - - - crm.case.tree.view.leads.survey.crm.generation.training - crm.lead - 1 - - - - - - - - - - -
    diff --git a/survey_event_base/__init__.py b/survey_event_base/__init__.py deleted file mode 100644 index 9a7e03e..0000000 --- a/survey_event_base/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import models \ No newline at end of file diff --git a/survey_event_base/__manifest__.py b/survey_event_base/__manifest__.py deleted file mode 100644 index bb20698..0000000 --- a/survey_event_base/__manifest__.py +++ /dev/null @@ -1,23 +0,0 @@ -# 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 deleted file mode 100644 index a690749..0000000 --- a/survey_event_base/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index f3963ce..0000000 --- a/survey_event_base/models/survey_user_input.py +++ /dev/null @@ -1,61 +0,0 @@ - -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_type_ids = fields.Many2many('event.type', string='Formations', compute="compute_event_type_ids", search="search_event_type_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): - """get all answers of type "event.event" - """ - 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_type_ids(self, operator, value): - user_input_ids = set() - user_input_lines = self.env['survey.user_input.line'].search([('record_reference_model','=','event.type'),('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_type_ids(self): - """get all answers of type "event.type" - """ - for user_input in self: - event_type_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.type': - event_type_ids.append(user_input_line.record_reference) - user_input.event_type_ids = event_type_ids - diff --git a/survey_event_registration_generation/__init__.py b/survey_event_registration_generation/__init__.py deleted file mode 100644 index 9a7e03e..0000000 --- a/survey_event_registration_generation/__init__.py +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index c51d921..0000000 --- a/survey_event_registration_generation/__manifest__.py +++ /dev/null @@ -1,19 +0,0 @@ -# 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": [ - 'security/ir.model.access.csv', - '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 deleted file mode 100644 index 39e22bd..0000000 --- a/survey_event_registration_generation/models/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 8ec4d7c..0000000 --- a/survey_event_registration_generation/models/survey_question.py +++ /dev/null @@ -1,38 +0,0 @@ -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 deleted file mode 100644 index d241d97..0000000 --- a/survey_event_registration_generation/models/survey_survey.py +++ /dev/null @@ -1,12 +0,0 @@ -# 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 deleted file mode 100644 index 3aed2ec..0000000 --- a/survey_event_registration_generation/models/survey_user_input.py +++ /dev/null @@ -1,82 +0,0 @@ - -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 deleted file mode 100644 index 3c17417..0000000 --- a/survey_event_registration_generation/security/ir.model.access.csv +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 5b5ddcf..0000000 --- a/survey_event_registration_generation/views/survey_question_views.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - survey.question - - - - - - - - - - - - - diff --git a/survey_event_registration_generation/views/survey_survey_views.xml b/survey_event_registration_generation/views/survey_survey_views.xml deleted file mode 100644 index c4edeef..0000000 --- a/survey_event_registration_generation/views/survey_survey_views.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - survey.survey - - - - - - - - - - - diff --git a/survey_event_registration_generation_attachment/__init__.py b/survey_event_registration_generation_attachment/__init__.py deleted file mode 100644 index 9a7e03e..0000000 --- a/survey_event_registration_generation_attachment/__init__.py +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 19ce4b4..0000000 --- a/survey_event_registration_generation_attachment/__manifest__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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 deleted file mode 100644 index a690749..0000000 --- a/survey_event_registration_generation_attachment/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 5a398d2..0000000 --- a/survey_event_registration_generation_attachment/models/survey_user_input.py +++ /dev/null @@ -1,32 +0,0 @@ - -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 deleted file mode 100644 index 9a7e03e..0000000 --- a/survey_event_speaker_generation/__init__.py +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 361fab1..0000000 --- a/survey_event_speaker_generation/__manifest__.py +++ /dev/null @@ -1,18 +0,0 @@ -# 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", "survey_event_base", "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 deleted file mode 100644 index ee79186..0000000 --- a/survey_event_speaker_generation/i18n/fr.po +++ /dev/null @@ -1,56 +0,0 @@ -# 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 deleted file mode 100644 index 6eda04e..0000000 --- a/survey_event_speaker_generation/models/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 55384ef..0000000 --- a/survey_event_speaker_generation/models/survey_survey.py +++ /dev/null @@ -1,11 +0,0 @@ -# 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 deleted file mode 100644 index a162c7d..0000000 --- a/survey_event_speaker_generation/models/survey_user_input.py +++ /dev/null @@ -1,41 +0,0 @@ - -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 _create_speaker_post_process(self, speaker): - for event in self.events_ids: - """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":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}) - for event in user_input.events_ids: - for track in event.track_ids: - track.speaker_ids = [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 deleted file mode 100644 index 025f329..0000000 --- a/survey_event_speaker_generation/views/mail_templates_chatter.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - diff --git a/survey_event_speaker_generation/views/survey_survey_views.xml b/survey_event_speaker_generation/views/survey_survey_views.xml deleted file mode 100644 index 7b451f8..0000000 --- a/survey_event_speaker_generation/views/survey_survey_views.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - survey.survey - - - - - - - - - - diff --git a/survey_event_visibility/__init__.py b/survey_event_visibility/__init__.py deleted file mode 100644 index 0650744..0000000 --- a/survey_event_visibility/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import models diff --git a/survey_event_visibility/__manifest__.py b/survey_event_visibility/__manifest__.py deleted file mode 100644 index 95c632a..0000000 --- a/survey_event_visibility/__manifest__.py +++ /dev/null @@ -1,24 +0,0 @@ -# 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 deleted file mode 100644 index 354e2c0..0000000 --- a/survey_event_visibility/models/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 58fa69e..0000000 --- a/survey_event_visibility/models/event_event.py +++ /dev/null @@ -1,28 +0,0 @@ -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 deleted file mode 100644 index 68f5c9c..0000000 --- a/survey_event_visibility/models/event_stage.py +++ /dev/null @@ -1,7 +0,0 @@ -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 deleted file mode 100644 index 8f7b50a..0000000 --- a/survey_event_visibility/models/product_product.py +++ /dev/null @@ -1,23 +0,0 @@ -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 deleted file mode 100644 index 22937b4..0000000 --- a/survey_event_visibility/views/event_stage_views.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - event.stage.view.form.survey.event.registration.generation - event.stage - - - - - - - - - - - - event.stage.view.tree.survey.event.registration.generation - event.stage - - - - - - - - - - diff --git a/survey_extra_fields/__init__.py b/survey_extra_fields/__init__.py deleted file mode 100644 index 91c5580..0000000 --- a/survey_extra_fields/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from . import controllers -from . import models diff --git a/survey_extra_fields/__manifest__.py b/survey_extra_fields/__manifest__.py deleted file mode 100644 index 77339c2..0000000 --- a/survey_extra_fields/__manifest__.py +++ /dev/null @@ -1,33 +0,0 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - -{ - "name": "Survey extra fields", - "summary": "Add extra question types to surveys", - "description": """ -Add extra question types to surveys: ----------------------------------------------------- -* File upload question type - - Allows survey participants to upload a file as an answer - - Configurable maximum file size (in MB) per question (default: 10 MB, 0 = no limit) - - Configurable allowed file extensions per question (e.g. .pdf,.docx — empty = all types allowed) - - Client-side validation (size and extension) before form submission - - Server-side validation on save to enforce constraints -""", - "version": "16.0.1.0.0", - "license": "AGPL-3", - "author": "Elabore", - "website": "https://www.elabore.coop", - "category": "", - "depends": ["base", "survey_base"], - "data": [ - "views/survey_templates.xml", - "views/survey_user_views.xml", - "views/survey_question_views.xml", - ], - "assets": { - "survey.survey_assets": [ - "/survey_extra_fields/static/src/js/survey_form.js", - ], - }, - "installable": True, -} diff --git a/survey_extra_fields/controllers/__init__.py b/survey_extra_fields/controllers/__init__.py deleted file mode 100644 index 12a7e52..0000000 --- a/survey_extra_fields/controllers/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import main diff --git a/survey_extra_fields/controllers/main.py b/survey_extra_fields/controllers/main.py deleted file mode 100644 index d417641..0000000 --- a/survey_extra_fields/controllers/main.py +++ /dev/null @@ -1,61 +0,0 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - -from __future__ import annotations - -import base64 -from typing import TYPE_CHECKING, Any - -from odoo import http -from odoo.http import request, content_disposition -from odoo.addons.survey.controllers.main import Survey - -if TYPE_CHECKING: - from werkzeug.wrappers import Response - - -class SurveyExtraFieldsController(Survey): - - @http.route( - "/survey/file///", - type="http", - auth="public", - ) - def survey_file_download( - self, - survey_token: str, - answer_token: str, - line_id: int, - **kwargs: Any - ) -> Response: - survey = request.env["survey.survey"].sudo().search( - [("access_token", "=", survey_token)], limit=1 - ) - if not survey: - return request.not_found() - - answer = request.env["survey.user_input"].sudo().search( - [ - ("survey_id", "=", survey.id), - ("access_token", "=", answer_token), - ], - limit=1, - ) - if not answer: - return request.not_found() - - line = request.env["survey.user_input.line"].sudo().browse(line_id) - if not line.exists() or line.user_input_id != answer: - return request.not_found() - - if not line.value_file: - return request.not_found() - - file_content = base64.b64decode(line.value_file) - filename = line.value_file_fname or "file" - return request.make_response( - file_content, - headers=[ - ("Content-Type", "application/octet-stream"), - ("Content-Disposition", content_disposition(filename)), - ], - ) diff --git a/survey_extra_fields/i18n/fr.po b/survey_extra_fields/i18n/fr.po deleted file mode 100644 index 8a6d53f..0000000 --- a/survey_extra_fields/i18n/fr.po +++ /dev/null @@ -1,124 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * survey_extra_fields -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-02-18 16:38+0000\n" -"PO-Revision-Date: 2026-02-18 16:38+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_extra_fields -#: model_terms:ir.ui.view,arch_db:survey_extra_fields.survey_question_form_inh -msgid ".pdf,.docx,.xlsx" -msgstr "" - -#. module: survey_extra_fields -#: model:ir.model.fields,field_description:survey_extra_fields.field_survey_question__allowed_extensions -msgid "Allowed Extensions" -msgstr "Extensions autorisées" - -#. module: survey_extra_fields -#: model:ir.model.fields,field_description:survey_extra_fields.field_survey_user_input_line__answer_type -msgid "Answer Type" -msgstr "Type de réponse" - -#. module: survey_extra_fields -#: model:ir.model.fields,help:survey_extra_fields.field_survey_question__allowed_extensions -msgid "" -"Comma-separated list of allowed extensions (e.g. .pdf,.docx). Leave empty to" -" allow all types." -msgstr "" -"Liste d'extensions autorisées séparées par une virgule (e.g. .pdf,.docx). Laisser vide pour" -" autoriser tous les types de fichier." - -#. module: survey_extra_fields -#: model:ir.model.fields.selection,name:survey_extra_fields.selection__survey_question__question_type__file -#: model:ir.model.fields.selection,name:survey_extra_fields.selection__survey_user_input_line__answer_type__file -msgid "File" -msgstr "Fichier" - -#. module: survey_extra_fields -#: model:ir.model.fields,field_description:survey_extra_fields.field_survey_question__max_file_size -#: model_terms:ir.ui.view,arch_db:survey_extra_fields.survey_question_form_inh -msgid "Max File Size (MB)" -msgstr "Taille maximale du fichier" - -#. module: survey_extra_fields -#: model:ir.model.fields,help:survey_extra_fields.field_survey_question__max_file_size -msgid "Maximum file size in MB. Leave 0 for no limit." -msgstr "Taille maximale du fichier en MB. Laisser à 0 pour ne pas restreindre la taille. La valeur par défaut est 10 MB." - -#. module: survey_extra_fields -#: model:ir.model.fields,field_description:survey_extra_fields.field_survey_question__question_type -msgid "Question Type" -msgstr "Type de question" - -#. module: survey_extra_fields -#: model_terms:ir.ui.view,arch_db:survey_extra_fields.survey_page_print_inh_type_file -msgid "Skipped" -msgstr "Ignoré" - -#. module: survey_extra_fields -#: model:ir.model.fields,field_description:survey_extra_fields.field_survey_question__smart_search -#: model:ir.model.fields,field_description:survey_extra_fields.field_survey_user_input__smart_search -#: model:ir.model.fields,field_description:survey_extra_fields.field_survey_user_input_line__smart_search -msgid "Smart Search" -msgstr "Recherche intelligente" - -#. module: survey_extra_fields -#: model:ir.model,name:survey_extra_fields.model_survey_question -msgid "Survey Question" -msgstr "Question du sondage" - -#. module: survey_extra_fields -#: model:ir.model,name:survey_extra_fields.model_survey_user_input -msgid "Survey User Input" -msgstr "Entrée utilisateur du sondage" - -#. module: survey_extra_fields -#: model:ir.model,name:survey_extra_fields.model_survey_user_input_line -msgid "Survey User Input Line" -msgstr "Ligne d'entrée pour l'utilisateur du sondage" - -#. module: survey_extra_fields -#. odoo-python -#: code:addons/survey_extra_fields/models/survey_user_input.py:0 -#, python-format -msgid "The file '%(name)s' exceeds the maximum allowed size of %(size)s MB." -msgstr "Le fichier '%(name)s' dépasse la taille maximale autorisée de %(size)s MB." - -#. module: survey_extra_fields -#. odoo-python -#: code:addons/survey_extra_fields/models/survey_user_input.py:0 -#, python-format -msgid "The file '%(name)s' is not allowed. Accepted formats: %(exts)s." -msgstr "Le fichier '%(name)s' n'est pas autorisé. Les formats de fichier autorisés sont : %(exts)s." - -#. module: survey_extra_fields -#. odoo-javascript -#: code:addons/survey_extra_fields/static/src/js/survey_form.js:0 -#, python-format -msgid "The file exceeds the maximum allowed size of %s MB." -msgstr "Le fichier dépasse la taille maximale autorisée de %s MB." - -#. module: survey_extra_fields -#. odoo-javascript -#: code:addons/survey_extra_fields/static/src/js/survey_form.js:0 -#, python-format -msgid "This file type is not allowed. Accepted formats: %s." -msgstr "Le fichier n'est pas autorisé. Les formats de fichier autorisés sont : %s." - -#. module: survey_extra_fields -#. odoo-javascript -#: code:addons/survey_extra_fields/static/src/js/survey_form.js:0 -#, python-format -msgid "This question requires an answer." -msgstr "Cette question requiert une réponse." diff --git a/survey_extra_fields/models/__init__.py b/survey_extra_fields/models/__init__.py deleted file mode 100644 index 198087b..0000000 --- a/survey_extra_fields/models/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from . import survey_question -from . import survey_user_input -from . import survey_user_input_line diff --git a/survey_extra_fields/models/survey_question.py b/survey_extra_fields/models/survey_question.py deleted file mode 100644 index 8bb622c..0000000 --- a/survey_extra_fields/models/survey_question.py +++ /dev/null @@ -1,20 +0,0 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - -from odoo import fields, models - - -class SurveyQuestion(models.Model): - _inherit = "survey.question" - - question_type = fields.Selection( - selection_add=[("file", "File")] - ) - max_file_size = fields.Integer( - string="Max File Size (MB)", - default=10, - help="Maximum file size in MB. Leave 0 for no limit.", - ) - allowed_extensions = fields.Char( - string="Allowed Extensions", - help="Comma-separated list of allowed extensions (e.g. .pdf,.docx). Leave empty to allow all types.", - ) diff --git a/survey_extra_fields/models/survey_user_input.py b/survey_extra_fields/models/survey_user_input.py deleted file mode 100644 index 5ea52d2..0000000 --- a/survey_extra_fields/models/survey_user_input.py +++ /dev/null @@ -1,73 +0,0 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - -from __future__ import annotations - -import base64 -import json -import os -from typing import TYPE_CHECKING - -from odoo import _, models -from odoo.exceptions import ValidationError - -if TYPE_CHECKING: - from odoo.addons.survey_extra_fields.models.survey_question import SurveyQuestion - - -class SurveyUserInput(models.Model): - _inherit = "survey.user_input" - - def save_lines(self, question: SurveyQuestion, answer: str | None, comment: str | None = None) -> None: - if question.question_type == "file": - old_answers = self.env["survey.user_input.line"].search([ - ("user_input_id", "=", self.id), - ("question_id", "=", question.id), - ]) - vals = { - "user_input_id": self.id, - "question_id": question.id, - "skipped": False, - "answer_type": "file", - } - if answer: - file_data = json.loads(answer) - file_b64 = file_data.get("data", "") - file_name = file_data.get("name", "") - self._check_file_constraints(question, file_b64, file_name) - vals["value_file"] = file_b64 - vals["value_file_fname"] = file_name - else: - vals.update(answer_type=None, skipped=True) - if old_answers: - old_answers.write(vals) - else: - self.env["survey.user_input.line"].create(vals) - else: - return super().save_lines(question, answer, comment=comment) - - def _check_file_constraints( - self, - question: SurveyQuestion, - file_b64: str, - file_name: str - ) -> None: - if question.max_file_size: - file_size = len(base64.b64decode(file_b64)) - max_bytes = question.max_file_size * 1024 * 1024 - if file_size > max_bytes: - raise ValidationError( - _("The file '%(name)s' exceeds the maximum allowed size of %(size)s MB.", - name=file_name, size=question.max_file_size) - ) - if question.allowed_extensions: - allowed = [ - allowed_extension.strip().lower() - for allowed_extension in question.allowed_extensions.split(",") - if allowed_extension.strip() - ] - file_extension = os.path.splitext(file_name)[1].lower() - if file_extension not in allowed: - raise ValidationError( - _("The file '%(name)s' is not allowed. Accepted formats: %(exts)s.", - name=file_name, exts=question.allowed_extensions) - ) diff --git a/survey_extra_fields/models/survey_user_input_line.py b/survey_extra_fields/models/survey_user_input_line.py deleted file mode 100644 index 19f851f..0000000 --- a/survey_extra_fields/models/survey_user_input_line.py +++ /dev/null @@ -1,17 +0,0 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - -from odoo import fields, models - - -class SurveyUserInputLine(models.Model): - _inherit = "survey.user_input.line" - - answer_type = fields.Selection( - selection_add=[("file", "File")] - ) - - def _compute_display_name(self): - super()._compute_display_name() - for line in self: - if line.answer_type == "file" and line.value_file_fname: - line.display_name = line.value_file_fname diff --git a/survey_extra_fields/static/src/js/survey_form.js b/survey_extra_fields/static/src/js/survey_form.js deleted file mode 100644 index 20844b8..0000000 --- a/survey_extra_fields/static/src/js/survey_form.js +++ /dev/null @@ -1,146 +0,0 @@ -odoo.define("survey_extra_fields.survey_form", function (require) { - "use strict"; - - var core = require("web.core"); - var _t = core._t; - var survey_form = require("survey.form"); - - survey_form.include({ - _readFileAsDataURL: function (file) { - return new Promise(function (resolve, reject) { - var reader = new FileReader(); - reader.onload = function (e) { - resolve(e.target.result); - }; - reader.onerror = function () { - reject(reader.error); - }; - reader.readAsDataURL(file); - }); - }, - - _submitForm: function (options) { - var self = this; - var $fileInputs = this.$('input[data-question-type="file"]'); - var hasFiles = false; - $fileInputs.each(function () { - if (this.files && this.files.length > 0) { - hasFiles = true; - return false; - } - }); - - if (!hasFiles || this.options.isStartScreen) { - return this._super(options); - } - - // Async flow: read files then submit - var params = {}; - if (options.previousPageId) { - params.previous_page_id = options.previousPageId; - } - - var $form = this.$("form"); - var formData = new FormData($form[0]); - - if (!options.skipValidation) { - if (!this._validateForm($form, formData)) { - return; - } - } - - this._prepareSubmitValues(formData, params); - - // Read all selected files as base64 - var filePromises = []; - $fileInputs.each(function () { - if (this.files && this.files.length > 0) { - var file = this.files[0]; - var name = this.name; - filePromises.push( - self._readFileAsDataURL(file).then(function (dataURL) { - params[name] = JSON.stringify({ - data: dataURL.split(",")[1], - name: file.name, - }); - }) - ); - } - }); - - this.preventEnterSubmit = true; - - if (this.options.sessionInProgress) { - this.fadeInOutDelay = 400; - this.readonly = true; - } - - Promise.all(filePromises).then(function () { - var submitPromise = self._rpc({ - route: _.str.sprintf( - "%s/%s/%s", - "/survey/submit", - self.options.surveyToken, - self.options.answerToken - ), - params: params, - }); - self._nextScreen(submitPromise, options); - }); - }, - - _validateForm: function ($form, formData) { - var result = this._super.apply(this, arguments); - var errors = {}; - var inactiveQuestionIds = this.options.sessionInProgress - ? [] - : this._getInactiveConditionalQuestionIds(); - - $form.find('input[data-question-type="file"]').each(function () { - var $questionWrapper = $(this).closest(".js_question-wrapper"); - var questionId = $questionWrapper.attr("id"); - if (inactiveQuestionIds.includes(parseInt(questionId))) { - return; - } - var questionRequired = $questionWrapper.data("required"); - var constrErrorMsg = - $questionWrapper.data("constrErrorMsg") || - _t("This question requires an answer."); - if (questionRequired && !(this.files && this.files.length > 0)) { - errors[questionId] = constrErrorMsg; - return; - } - if (this.files && this.files.length > 0) { - var file = this.files[0]; - var maxSizeMB = parseInt($(this).data("maxFileSize")); - if (maxSizeMB && file.size > maxSizeMB * 1024 * 1024) { - errors[questionId] = _.str.sprintf( - _t("The file exceeds the maximum allowed size of %s MB."), - maxSizeMB - ); - return; - } - var allowedExtensions = $(this).data("allowedExtensions"); - if (allowedExtensions) { - var allowed = allowedExtensions.split(",").map(function (e) { - return e.trim().toLowerCase(); - }); - var ext = "." + file.name.split(".").pop().toLowerCase(); - if (!allowed.includes(ext)) { - errors[questionId] = _.str.sprintf( - _t("This file type is not allowed. Accepted formats: %s."), - allowedExtensions - ); - } - } - } - }); - - if (_.keys(errors).length > 0) { - this._showErrors(errors); - return false; - } - return result; - }, - }); -}); diff --git a/survey_extra_fields/tests/__init__.py b/survey_extra_fields/tests/__init__.py deleted file mode 100644 index d0e947c..0000000 --- a/survey_extra_fields/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import test_survey_file diff --git a/survey_extra_fields/tests/test_survey_file.py b/survey_extra_fields/tests/test_survey_file.py deleted file mode 100644 index 3529ac9..0000000 --- a/survey_extra_fields/tests/test_survey_file.py +++ /dev/null @@ -1,278 +0,0 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - -import base64 -import json -from unittest.mock import patch, MagicMock - -from werkzeug.exceptions import NotFound -from werkzeug.wrappers import Response - -from odoo.addons.survey.tests import common - - -class TestSurveyFileCommon(common.TestSurveyCommon): - def setUp(self): - super().setUp() - self.file_content = b"Hello, this is a test file." - self.file_b64 = base64.b64encode(self.file_content).decode() - self.file_name = "test_document.pdf" - - self.question_file = self._add_question( - self.page_0, - "Upload your document", - "file", - constr_mandatory=False, - survey_id=self.survey.id, - ) - self.question_file_required = self._add_question( - self.page_0, - "Upload your required document", - "file", - constr_mandatory=True, - survey_id=self.survey.id, - ) - - def _create_answer_with_file(self): - answer = self._add_answer(self.survey, False, email="test@example.com") - line = self.env["survey.user_input.line"].create({ - "user_input_id": answer.id, - "question_id": self.question_file.id, - "answer_type": "file", - "skipped": False, - "value_file": self.file_b64, - "value_file_fname": self.file_name, - }) - return answer, line - - -class TestSurveyFileSaveLines(TestSurveyFileCommon): - """Test the save_lines method for file question type.""" - - def test_save_file_answer(self): - """Submitting a file stores base64 data and filename.""" - answer = self._add_answer(self.survey, self.survey_manager.partner_id) - file_json = json.dumps({"data": self.file_b64, "name": self.file_name}) - - answer.save_lines(self.question_file, file_json) - - line = answer.user_input_line_ids.filtered( - lambda l: l.question_id == self.question_file - ) - self.assertEqual(len(line), 1) - self.assertEqual(line.answer_type, "file") - self.assertFalse(line.skipped) - self.assertEqual(line.value_file, self.file_b64.encode()) - self.assertEqual(line.value_file_fname, self.file_name) - - def test_save_file_skipped(self): - """Submitting empty answer marks the line as skipped.""" - answer = self._add_answer(self.survey, self.survey_manager.partner_id) - - answer.save_lines(self.question_file, "") - - line = answer.user_input_line_ids.filtered( - lambda l: l.question_id == self.question_file - ) - self.assertEqual(len(line), 1) - self.assertTrue(line.skipped) - self.assertFalse(line.answer_type) - - def test_save_file_update_existing(self): - """Submitting a new file updates the existing answer line.""" - answer = self._add_answer(self.survey, self.survey_manager.partner_id) - file_json_1 = json.dumps({"data": self.file_b64, "name": "first.pdf"}) - answer.save_lines(self.question_file, file_json_1) - - new_b64 = base64.b64encode(b"Updated content").decode() - file_json_2 = json.dumps({"data": new_b64, "name": "second.pdf"}) - answer.save_lines(self.question_file, file_json_2) - - lines = answer.user_input_line_ids.filtered( - lambda l: l.question_id == self.question_file - ) - self.assertEqual(len(lines), 1, "Should update, not create a second line") - self.assertEqual(lines.value_file, new_b64.encode()) - self.assertEqual(lines.value_file_fname, "second.pdf") - - def test_save_file_then_skip(self): - """Uploading a file then submitting empty marks line as skipped.""" - answer = self._add_answer(self.survey, self.survey_manager.partner_id) - file_json = json.dumps({"data": self.file_b64, "name": self.file_name}) - answer.save_lines(self.question_file, file_json) - - answer.save_lines(self.question_file, "") - - line = answer.user_input_line_ids.filtered( - lambda l: l.question_id == self.question_file - ) - self.assertEqual(len(line), 1) - self.assertTrue(line.skipped) - - -class TestSurveyFileConstraints(TestSurveyFileCommon): - """Test _check_file_constraints validation logic.""" - - def test_no_constraints(self): - """No max_file_size and no allowed_extensions: any file passes.""" - self.question_file.write({"max_file_size": 0, "allowed_extensions": False}) - answer = self._add_answer(self.survey, self.survey_manager.partner_id) - file_json = json.dumps({"data": self.file_b64, "name": "anything.exe"}) - answer.save_lines(self.question_file, file_json) - line = answer.user_input_line_ids.filtered( - lambda l: l.question_id == self.question_file - ) - self.assertFalse(line.skipped) - - def test_file_within_size_limit(self): - """File smaller than max_file_size passes.""" - self.question_file.write({"max_file_size": 10}) - answer = self._add_answer(self.survey, self.survey_manager.partner_id) - file_json = json.dumps({"data": self.file_b64, "name": self.file_name}) - answer.save_lines(self.question_file, file_json) - line = answer.user_input_line_ids.filtered( - lambda l: l.question_id == self.question_file - ) - self.assertFalse(line.skipped) - - def test_file_exceeds_size_limit(self): - """File larger than max_file_size raises ValidationError.""" - self.question_file.write({"max_file_size": 1}) - large_content = b"x" * (1 * 1024 * 1024 + 1) - large_b64 = base64.b64encode(large_content).decode() - answer = self._add_answer(self.survey, self.survey_manager.partner_id) - file_json = json.dumps({"data": large_b64, "name": self.file_name}) - with self.assertRaises(Exception): - answer.save_lines(self.question_file, file_json) - - def test_allowed_extension_passes(self): - """File with an allowed extension passes.""" - self.question_file.write({"allowed_extensions": ".pdf,.docx"}) - answer = self._add_answer(self.survey, self.survey_manager.partner_id) - file_json = json.dumps({"data": self.file_b64, "name": "report.docx"}) - answer.save_lines(self.question_file, file_json) - line = answer.user_input_line_ids.filtered( - lambda l: l.question_id == self.question_file - ) - self.assertFalse(line.skipped) - - def test_disallowed_extension_raises(self): - """File with a disallowed extension raises ValidationError.""" - self.question_file.write({"allowed_extensions": ".pdf,.docx"}) - answer = self._add_answer(self.survey, self.survey_manager.partner_id) - file_json = json.dumps({"data": self.file_b64, "name": "script.exe"}) - with self.assertRaises(Exception): - answer.save_lines(self.question_file, file_json) - - def test_both_constraints_valid(self): - """File respecting both size and extension constraints passes.""" - self.question_file.write({"max_file_size": 10, "allowed_extensions": ".pdf"}) - answer = self._add_answer(self.survey, self.survey_manager.partner_id) - file_json = json.dumps({"data": self.file_b64, "name": self.file_name}) - answer.save_lines(self.question_file, file_json) - line = answer.user_input_line_ids.filtered( - lambda l: l.question_id == self.question_file - ) - self.assertFalse(line.skipped) - - -class TestSurveyFileDisplayName(TestSurveyFileCommon): - """Test the display_name computation for file answer lines.""" - - def test_display_name_filename(self): - answer = self._add_answer(self.survey, self.survey_manager.partner_id) - line = self.env["survey.user_input.line"].create({ - "user_input_id": answer.id, - "question_id": self.question_file.id, - "answer_type": "file", - "skipped": False, - "value_file": self.file_b64, - "value_file_fname": "my_filename.pdf", - }) - self.assertEqual(line.display_name, "my_filename.pdf") - - -class TestSurveyFileDownloadController(TestSurveyFileCommon): - """Test the file download controller logic with mocked request.""" - - def _call_download(self, survey_token, answer_token, line_id): - """Call the controller method with a mocked request context.""" - from odoo.addons.survey_extra_fields.controllers.main import ( - SurveyExtraFieldsController, - ) - - mock_request = MagicMock() - mock_request.env = self.env - mock_request.not_found.return_value = NotFound() - mock_request.make_response.side_effect = ( - lambda content, headers=None: Response(content, headers=headers) - ) - - controller = SurveyExtraFieldsController() - with patch( - "odoo.addons.survey_extra_fields.controllers.main.request", - mock_request, - ): - try: - return controller.survey_file_download( - survey_token, answer_token, line_id - ) - except NotFound: - return NotFound() - - def test_download_valid(self): - """Valid tokens return the file content.""" - answer, line = self._create_answer_with_file() - - response = self._call_download( - self.survey.access_token, answer.access_token, line.id - ) - - self.assertIsInstance(response, Response) - self.assertEqual(response.status_code, 200) - self.assertEqual(response.data, self.file_content) - - def test_download_invalid_survey_token(self): - """Invalid survey token returns not_found.""" - answer, line = self._create_answer_with_file() - - response = self._call_download( - "invalid-token", answer.access_token, line.id - ) - - self.assertIsInstance(response, NotFound) - - def test_download_invalid_answer_token(self): - """Invalid answer token returns not_found.""" - answer, line = self._create_answer_with_file() - - response = self._call_download( - self.survey.access_token, "invalid-token", line.id - ) - - self.assertIsInstance(response, NotFound) - - def test_download_line_not_belonging_to_answer(self): - """Accessing a line from another answer returns not_found.""" - answer, line = self._create_answer_with_file() - other_answer = self._add_answer(self.survey, False, email="other@example.com") - - response = self._call_download( - self.survey.access_token, other_answer.access_token, line.id - ) - - self.assertIsInstance(response, NotFound) - - def test_download_no_file(self): - """Accessing a line without file data returns not_found.""" - answer = self._add_answer(self.survey, False, email="test@example.com") - line = self.env["survey.user_input.line"].create({ - "user_input_id": answer.id, - "question_id": self.question_file.id, - "skipped": True, - }) - - response = self._call_download( - self.survey.access_token, answer.access_token, line.id - ) - - self.assertIsInstance(response, NotFound) diff --git a/survey_extra_fields/views/survey_question_views.xml b/survey_extra_fields/views/survey_question_views.xml deleted file mode 100644 index 8eaa08f..0000000 --- a/survey_extra_fields/views/survey_question_views.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - survey.question.form.inherit.extra_fields - survey.question - - - - - - - - - - diff --git a/survey_extra_fields/views/survey_templates.xml b/survey_extra_fields/views/survey_templates.xml deleted file mode 100644 index 26ac874..0000000 --- a/survey_extra_fields/views/survey_templates.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - diff --git a/survey_extra_fields/views/survey_user_views.xml b/survey_extra_fields/views/survey_user_views.xml deleted file mode 100644 index e97bee3..0000000 --- a/survey_extra_fields/views/survey_user_views.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - survey.user_input.line.view.form.inherit.extra_fields - survey.user_input.line - - - - - - - - - - diff --git a/survey_notify/__init__.py b/survey_notify/__init__.py deleted file mode 100644 index 9a7e03e..0000000 --- a/survey_notify/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import models \ No newline at end of file diff --git a/survey_notify/__manifest__.py b/survey_notify/__manifest__.py deleted file mode 100644 index fb68687..0000000 --- a/survey_notify/__manifest__.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2016-2020 Akretion France () -# @author: Alexis de Lattre -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - -{ - "name": "Survey notify", - 'summary': 'Add chatter message in survey after survey response', - 'description': """ -Add chatter message in survey after survey response ----------------------------------------------------- -* -""", - "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_notify/i18n/fr.po b/survey_notify/i18n/fr.po deleted file mode 100644 index dfb0ee2..0000000 --- a/survey_notify/i18n/fr.po +++ /dev/null @@ -1,49 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * survey_notify -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-15 09:48+0000\n" -"PO-Revision-Date: 2024-04-15 09:48+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_notify -#. odoo-python -#: code:addons/survey_notify/models/survey_user_input.py:0 -#, python-format -msgid "New %(response)s " -msgstr "Nouvelle %(response)s " - -#. module: survey_notify -#. odoo-python -#: code:addons/survey_notify/models/survey_user_input.py:0 -#, python-format -msgid "response" -msgstr "réponse" - -#. module: survey_notify -#: model:ir.model,name:survey_notify.model_survey_user_input -msgid "Survey User Input for custom matrix" -msgstr "" - -#. module: survey_notify -#. odoo-python -#: code:addons/survey_notify/models/survey_user_input.py:0 -#, python-format -msgid "for survey %(survey)s " -msgstr "pour le questionnaire %(survey)s " - -#. module: survey_notify -#. odoo-python -#: code:addons/survey_notify/models/survey_user_input.py:0 -#, python-format -msgid "of %(partner)s " -msgstr "de %(partner)s " diff --git a/survey_notify/models/__init__.py b/survey_notify/models/__init__.py deleted file mode 100644 index a690749..0000000 --- a/survey_notify/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import survey_user_input \ No newline at end of file diff --git a/survey_notify/models/survey_user_input.py b/survey_notify/models/survey_user_input.py deleted file mode 100644 index 1cb408b..0000000 --- a/survey_notify/models/survey_user_input.py +++ /dev/null @@ -1,25 +0,0 @@ - -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): - res = super(SurveyUserInput, self)._mark_done() - msg = _('New %(response)s ', response=self._get_html_link(_("response"))) - if self.partner_id: - msg += _('of %(partner)s ', partner=self.partner_id._get_html_link(self.partner_id.name)) - msg += _('for survey %(survey)s ', survey=self.survey_id._get_html_link(self.survey_id.title)) - self.survey_id.message_post(body=msg) - return res \ No newline at end of file diff --git a/survey_record_generation/README.rst b/survey_record_generation/README.rst deleted file mode 100644 index e03d218..0000000 --- a/survey_record_generation/README.rst +++ /dev/null @@ -1,146 +0,0 @@ -======================== -Survey record generation -======================== - -.. - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! This file is generated by oca-gen-addon-readme !! - !! changes will be overwritten. !! - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:03eeb5c11b7d8330051c416331c84103b2641351fdc1d0a1bad43acd09501a33 - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -.. |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/16.0/survey_record_generation - :alt: OCA/survey -.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/survey-16-0/survey-16-0-survey_record_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=16.0 - :alt: Try me on Runboat - -|badge1| |badge2| |badge3| |badge4| |badge5| - -This module allows to generate any record from surveys answers. - -**Table of contents** - -.. contents:: - :local: - -Use Cases / Context -=================== - -In several cases we want to use survey application to create records. -Website form application give the same possibility but the design is integrated on the web site. -Futhermore this module add other functionnalities like "duplicate" check, or creation of several interconnected records - -Typical use case : Information request form - -#. Submitting the form will create a contact (partner) only if it does not already exist in the database. -#. Submitting the form will also create a crm opportunity linked to previously created partner - - - -Configuration -============= - -Record generation configuration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. |Image of record creation list| image:: https://raw.githubusercontent.com/OCA/survey/16.0/survey_record_generation/static/description/record-creations.png - -#. Go to the the survey -#. In *Record creation* tab add a new line -#. Set a name for created record, select the Model of the record (eg: Prospect) -#. Add a field configuration. So for each field : - - .. |Image of record creation fields| image:: https://raw.githubusercontent.com/OCA/survey/16.0/survey_record_generation/static/description/record-creation-customer.png - - #. You can check "unicity constraint" to prevent duplicates. - In case of duplicates and if other record use this record to fill a m2o field, the founded record will be used - #. You can configure explicitly where Odoo should retrieve the value of field : - * **fixed**: To set explicit value - * **question**: If value come from user's answer - For m2o or m2m links, question should be configured before. See Question answers configuration section below. - * **other created record**: If value come from other created record (m2o case only) - - - -Question answers configuration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In a survey question : to configure value of choices - -.. |Question answers| image:: https://raw.githubusercontent.com/OCA/survey/16.0/survey_record_generation/static/description/question-answers.png - -#. Configure a multiple choice question -#. Select value type associated to answer: - * **Value** > eg: to fill a selection field - * **Record** > to fill m2o or m2m field -#. In case of *record* type: - #. Select referenced model - #. You can directly fill answers (eventualy with help of the domain field) - #. Or create new answers and set associated record -#. In case of *value* type: - #. Add new selectable answers and set associated value - - -Usage -===== - -When a survey is properly configured, once it is submited by a user, records should be created. - -To find records generated from a participation go to: - -#. Survey > participation -#. Click on **# Generated records** button (top-right) - -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 -~~~~~~~ - -* Elabore - -Contributors -~~~~~~~~~~~~ - -* `Elabore `_ - - * Clément Thomas - -Maintainers -~~~~~~~~~~~ - -This module is maintained by the OCA. - -.. image:: https://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: https://odoo-community.org - -OCA, or the Odoo Community Association, is a nonprofit organization whose -mission is to support the collaborative development of Odoo features and -promote its widespread use. - -This module is part of the `OCA/survey `_ project on GitHub. - -You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/survey_record_generation/__init__.py b/survey_record_generation/__init__.py deleted file mode 100644 index 9a7e03e..0000000 --- a/survey_record_generation/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import models \ No newline at end of file diff --git a/survey_record_generation/__manifest__.py b/survey_record_generation/__manifest__.py deleted file mode 100644 index 05a64e0..0000000 --- a/survey_record_generation/__manifest__.py +++ /dev/null @@ -1,28 +0,0 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - -{ - "name": "Survey record generation", - 'summary': 'Allow to create record of any model when sending the form', - 'description': """ -Allow to create record of any model when sending the form : ----------------------------------------------------- -* Choose list of models created on survey submission -* Set default values for record created -* Associate question with fields -* For x2m fields : Associate values to questions -""", - "version": "16.0.1.0.2", - "license": "AGPL-3", - "author": "Elabore", - "website": "https://www.elabore.coop", - "category": "", - "depends": ["survey"], - "data": [ - "security/ir.model.access.csv", - "views/survey_survey_views.xml", - "views/survey_question_views.xml", - "views/survey_user_input_views.xml", - "views/survey_generated_record_views.xml", - ], - "installable": True, -} diff --git a/survey_record_generation/i18n/fr.po b/survey_record_generation/i18n/fr.po deleted file mode 100644 index 574b4e5..0000000 --- a/survey_record_generation/i18n/fr.po +++ /dev/null @@ -1,540 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * survey_record_generation -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-11-13 16:41+0000\n" -"PO-Revision-Date: 2025-11-13 16:41+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_record_generation -#: model:ir.model.fields,help:survey_record_generation.field_survey_record_creation_field_values__value_origin -msgid "" -"* Fixed: you can set the value in value field\n" -" * Question: Response of the question will set the value. If you do not see your question, maybe the type of question do not match the type of field\n" -" * From other created record: You can set other record creation to link several created records. Can only be used with many2one fields." -msgstr "" -"* Fixé: Vous pouvez attribuer une valeur au champ\n" -" * Question: La réponse à la question attribuera la valeur. Si vous ne voyez pas votre question, peut-être que le type de question ne correspond pas au type de champ\n" -" * Depuis un autre enregistrement créé: Vous pouvez attribuer un autre enregistrement créé pour lier plusieurs enregistrements. Peut être utilisé uniquement avec les champs one2many." - -#. module: survey_record_generation -#: model_terms:ir.ui.view,arch_db:survey_record_generation.survey_generated_record_view_search -msgid "Active survey input" -msgstr "Participation active" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__allowed_field_ids -msgid "Allowed Fields" -msgstr "Champs acceptés" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__allowed_question_ids -msgid "Allowed Question" -msgstr "Question autorisée" - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_record_creation_field_values.py:0 -#: code:addons/survey_record_generation/models/survey_record_creation_field_values.py:0 -#, python-format -msgid "Answer to question: %s" -msgstr "Réponse à la question : %s" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_question__answer_values_type -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_question_answer__answer_values_type -msgid "Associate value to answer" -msgstr "Associer une valeur à la réponse" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_user_input__generated_records_count -msgid "Attempts Count" -msgstr "" - -#. module: survey_record_generation -#: model:ir.model.fields,help:survey_record_generation.field_survey_record_creation__field_to_retrieve_existing_records -msgid "" -"Choose the field you want to use to retrieve the existing record. WARNING: " -"We update only the first record found." -msgstr "" -"Choisissez le champs à partir duquel nous allons chercher l'enregistrement " -"existant. Attention : nous mettons à jour seulement le premier " -"enregistrement trouvé." - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_generated_record__create_uid -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__create_uid -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__create_uid -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values_x2m__create_uid -msgid "Created by" -msgstr "Créé par" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_generated_record__create_date -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__create_date -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__create_date -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values_x2m__create_date -msgid "Created on" -msgstr "Créé le" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_generated_record__display_name -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__display_name -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__display_name -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values_x2m__display_name -msgid "Display Name" -msgstr "" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_question__fill_domain -msgid "Domain" -msgstr "Domaine" - -#. module: survey_record_generation -#: model_terms:ir.ui.view,arch_db:survey_record_generation.survey_question_form -msgid "Empty and fill" -msgstr "Vider et remplir" - -#. module: survey_record_generation -#: model_terms:ir.ui.view,arch_db:survey_record_generation.survey_question_form -msgid "" -"Empty the list and fill it with all items of selected model matching domain" -msgstr "" -"Vide la liste et la remplie avec tous les enregistrements du modèle " -"sélectionné qui correspondent au domaine" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__field_id -msgid "Field" -msgstr "Champ" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__field_to_retrieve_existing_records -msgid "Field To Retrieve Existing Records" -msgstr "Champs pour retrouver l'enregistrement existant" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__field_type -msgid "Field Type" -msgstr "Type de champ" - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_record_creation_field_values.py:0 -#: code:addons/survey_record_generation/models/survey_record_creation_field_values.py:0 -#, python-format -msgid "Field type is : %s" -msgstr "Le type de champ est : %s" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__field_values_ids -msgid "Field values" -msgstr "Valeurs des champs" - -#. module: survey_record_generation -#: model:ir.model.fields.selection,name:survey_record_generation.selection__survey_record_creation_field_values__value_origin__fixed -msgid "Fixed" -msgstr "Fixé" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__fixed_value_many2many -msgid "Fixed Value Many2Many" -msgstr "Valeur fixée Many2Many" - -#. module: survey_record_generation -#: model:ir.model.fields,help:survey_record_generation.field_survey_record_creation_field_values__field_relation -msgid "For relationship fields, the technical name of the target model" -msgstr "Pour les champs relationnels, le nom technique du modèle ciblé" - -#. module: survey_record_generation -#: model:ir.model.fields.selection,name:survey_record_generation.selection__survey_record_creation_field_values__value_origin__other_record -msgid "From other created record" -msgstr "Depuis un autre enregistrement créé" - -#. module: survey_record_generation -#: model_terms:ir.ui.view,arch_db:survey_record_generation.survey_generated_record_view_tree -msgid "Generated from survey input" -msgstr "Généré depuis la participation" - -#. module: survey_record_generation -#: model_terms:ir.ui.view,arch_db:survey_record_generation.survey_generated_record_view_tree -msgid "Generated record type" -msgstr "Type d'enregistrement généré" - -#. module: survey_record_generation -#: model:ir.actions.act_window,name:survey_record_generation.survey_generated_record_action -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_user_input__generated_record_ids -#: model_terms:ir.ui.view,arch_db:survey_record_generation.survey_user_input_view_form_survey_record_generation -msgid "Generated records" -msgstr "Enregistrements générés" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__field_help -msgid "Help" -msgstr "Aide" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_generated_record__id -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__id -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__id -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values_x2m__id -msgid "ID" -msgstr "" - -#. module: survey_record_generation -#: model:ir.model.fields,help:survey_record_generation.field_survey_record_creation__ignore_if_mandatory_field_is_missing -msgid "" -"If a mandatory field is missing when trying to create the record, an error " -"is raised when the survey is submitted. If this option is activated, the " -"error is ignored." -msgstr "" -"Si un champs requis est manquant lors de la création de l'enregistrement, " -"une erreur est levée lors de la soumission du formulaire. " -"En activant cette option, l'erreur sera ignorée." - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__ignore_if_mandatory_field_is_missing -msgid "Ignore creation if a mandatory field is missing" -msgstr "Ignorer la création si un champs requis est manquant" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_generated_record____last_update -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation____last_update -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values____last_update -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values_x2m____last_update -msgid "Last Modified on" -msgstr "Dernière modification le" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_generated_record__write_uid -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__write_uid -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__write_uid -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values_x2m__write_uid -msgid "Last Updated by" -msgstr "Dernière modification par" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_generated_record__write_date -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__write_date -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__write_date -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values_x2m__write_date -msgid "Last Updated on" -msgstr "Dernière modification le" - -#. module: survey_record_generation -#: model_terms:ir.ui.view,arch_db:survey_record_generation.survey_generated_record_view_tree -msgid "Link to generated record" -msgstr "Lien vers l'enregistrement généré" - -#. module: survey_record_generation -#: model:ir.model.fields,help:survey_record_generation.field_survey_survey__survey_record_creation_ids -msgid "List of records created when survey submitted" -msgstr "Liste des enregistrements créés lorsque le sondage est envoyé" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_question__model_id -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_question__model_name -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_question_answer__model_id -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__model_id -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__model_id -msgid "Model" -msgstr "Modèle" - -#. module: survey_record_generation -#: model:ir.model.fields,help:survey_record_generation.field_survey_record_creation__model_id -#: model:ir.model.fields,help:survey_record_generation.field_survey_record_creation_field_values__model_id -msgid "Model of generated record" -msgstr "Modèle de l'enregistrement généré" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_generated_record__survey_record_creation_name -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__name -msgid "Name" -msgstr "Nom" - -#. module: survey_record_generation -#: model_terms:ir.actions.act_window,help:survey_record_generation.survey_generated_record_action -msgid "No generated records found" -msgstr "Pas d'enregistrements générés trouvés" - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_question.py:0 -#: code:addons/survey_record_generation/models/survey_question.py:0 -#, python-format -msgid "No record found in %s" -msgstr "Pas d'enregistrements trouvés parmis %s" - -#. module: survey_record_generation -#: model:ir.model.fields.selection,name:survey_record_generation.selection__survey_question__answer_values_type__no -msgid "No values" -msgstr "Pas de valeur" - -#. module: survey_record_generation -#: model:ir.model.fields,help:survey_record_generation.field_survey_record_creation_field_values__unicity_check -msgid "" -"On record creation, if another record exists with same value, record will " -"not be created." -msgstr "" -"Lors de la création d'un enregistrement, si un autre enregistrement existe " -"avec la même valeur, l'enregistrement ne sera pas créé." - -#. module: survey_record_generation -#: model_terms:ir.ui.view,arch_db:survey_record_generation.survey_survey_view_form -msgid "" -"Only the first matched record will be updated.\n" -" Also to be noticed, the unicity check feature has priority over updating the existing record." -msgstr "" -"Attention, seul le premier enregistrement trouvé sera mis à jour. Aussi, si " -"vous avez des champs avec une contrainte d'unicité, cette contrainte aura la" -" priorité sur la mise à jour des enregistrements." - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_record_creation_field_values.py:0 -#: code:addons/survey_record_generation/models/survey_record_creation_field_values.py:0 -#, python-format -msgid "Other created record: " -msgstr "Autre enregistrement créé : " - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__other_created_record_id -msgid "Other record" -msgstr "Autre enregistrement" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_generated_record__user_input_id -msgid "Participation" -msgstr "" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__question_id -#: model:ir.model.fields.selection,name:survey_record_generation.selection__survey_record_creation_field_values__value_origin__question -msgid "Question" -msgstr "" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__fixed_value_many2one -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values_x2m__value_reference -#: model:ir.model.fields.selection,name:survey_record_generation.selection__survey_question__answer_values_type__record -msgid "Record" -msgstr "Enregistrement" - -#. module: survey_record_generation -#: model_terms:ir.ui.view,arch_db:survey_record_generation.survey_survey_view_form -msgid "Record creation" -msgstr "Création d'un enregistrement" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_survey__survey_record_creation_ids -msgid "Records creation" -msgstr "Création d'enregistrements" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_generated_record__created_record_id -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_question_answer__record_id -msgid "Referenced record" -msgstr "Enregistrement référencé" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__field_relation -msgid "Related Model" -msgstr "Modèle relatif" - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_record_creation.py:0 -#: code:addons/survey_record_generation/models/survey_record_creation.py:0 -#, python-format -msgid "Some required fields are not set : %s" -msgstr "Certains champs requis ne sont pas remplis : %s" - -#. module: survey_record_generation -#: model:ir.model,name:survey_record_generation.model_survey_survey -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__survey_id -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__survey_id -msgid "Survey" -msgstr "Sondage" - -#. module: survey_record_generation -#: model:ir.model,name:survey_record_generation.model_survey_question_answer -msgid "Survey Label" -msgstr "Étiquette du sondage" - -#. module: survey_record_generation -#: model:ir.model,name:survey_record_generation.model_survey_question -msgid "Survey Question" -msgstr "Question du sondage" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__survey_record_creation_id -msgid "Survey Record Creation" -msgstr "Sondage Création d'enregistrements" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values_x2m__survey_record_creation_field_values_id -msgid "Survey Record Creation Field Values" -msgstr "Sondage Création d'enregistrement Valeur des champs" - -#. module: survey_record_generation -#: model:ir.model,name:survey_record_generation.model_survey_user_input -msgid "Survey User Input" -msgstr "Saisie utilisateur du sondage" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_generated_record__survey_record_creation_id -msgid "Survey record creation" -msgstr "Génération d'enregistrement depuis la participation" - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_user_input.py:0 -#, python-format -msgid "" -"The field %(field)s is mandatory for model %(model)s. In Record Creation " -"tab, drag %(record)s on top of the model %(model)s." -msgstr "" -"Le champs %(field)s est obligatoire pour le modèle %(model)s. Dans l'onglet " -"Création d'un enregistrement, placez la ligne %(record)s au dessus de la " -"ligne du modèle %(model)s." - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_user_input.py:0 -#, python-format -msgid "" -"The field %s is mandatory. In Record Creation tab, drag %s at the top of the" -" table" -msgstr "" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__unicity_check -msgid "Unicity constraint" -msgstr "Contrainte d'unicité" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__update_existing_records -msgid "Update existing records" -msgstr "Mettre à jour les enregistrements existants" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_question_answer__value_char -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__displayed_value -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__fixed_value_boolean -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__fixed_value_char -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__fixed_value_date -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__fixed_value_datetime -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__fixed_value_float -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__fixed_value_html -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__fixed_value_integer -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__fixed_value_selection -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__fixed_value_text -#: model:ir.model.fields.selection,name:survey_record_generation.selection__survey_question__answer_values_type__value -msgid "Value" -msgstr "Valeur" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation_field_values__value_origin -msgid "Value origin" -msgstr "Origine de la valeur" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__warning_message -msgid "Warning message" -msgstr "Message d'erreur" - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_record_creation_field_values.py:0 -#: code:addons/survey_record_generation/models/survey_record_creation_field_values.py:0 -#: code:addons/survey_record_generation/models/survey_record_creation_field_values.py:0 -#: code:addons/survey_record_generation/models/survey_record_creation_field_values.py:0 -#, python-format -msgid "You should append at least one record in %s" -msgstr "Vous devez au moins ajouter un enregistrement dans %s" - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_user_input.py:0 -#, python-format -msgid "" -"[Survey record generation] The answer values type '%(type)s' is not " -"supported (for question %(question)s). Use 'record' or 'value' instead." -msgstr "" -"[Survey record generation] La valeur '%(type)s' pour le champs " -"'answer_values_type' n'est pas supportée (pour la question %(question)s). " -"Veuillez utiliser 'Enregistrement' ou 'Valeur' à la place." - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_user_input.py:0 -#, python-format -msgid "" -"[Survey record generation] The boolean value %s(value)s is not supported " -"(for question %(question)s)." -msgstr "" -"[Survey record generation] La valeur booléenne %s(value)s n'est pas " -"supportée (pour la question %(question)s)." - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_user_input.py:0 -#, python-format -msgid "" -"[Survey record generation] The question type %(type)s is not recognized (for" -" question %(question)s)." -msgstr "" -"[Survey record generation] Le type de question %(type)s n'est pas reconnu " -"(pour la question %(question)s)." - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_user_input.py:0 -#, python-format -msgid "" -"[Survey record generation] The question type %(type)s is not supported yet." -msgstr "" -"[Survey record generation] Le type de question %(type)s n'est pas encore " -"supporté." - -#. module: survey_record_generation -#. odoo-python -#: code:addons/survey_record_generation/models/survey_record_creation_field_values.py:0 -#: code:addons/survey_record_generation/models/survey_record_creation_field_values.py:0 -#, python-format -msgid "possible values are %s" -msgstr "les valeurs possibles sont %s" - -#. module: survey_record_generation -#: model:ir.model.fields,field_description:survey_record_generation.field_survey_record_creation__sequence -msgid "sequence" -msgstr "" - -#. module: survey_record_generation -#: model:ir.model,name:survey_record_generation.model_survey_generated_record -msgid "survey.generated.record" -msgstr "" - -#. module: survey_record_generation -#: model:ir.model,name:survey_record_generation.model_survey_record_creation -msgid "survey.record.creation" -msgstr "" - -#. module: survey_record_generation -#: model:ir.model,name:survey_record_generation.model_survey_record_creation_field_values -msgid "survey.record.creation.field.values" -msgstr "" - -#. module: survey_record_generation -#: model:ir.model,name:survey_record_generation.model_survey_record_creation_field_values_x2m -msgid "survey.record.creation.field.values.x2m" -msgstr "" diff --git a/survey_record_generation/models/__init__.py b/survey_record_generation/models/__init__.py deleted file mode 100644 index e8d744a..0000000 --- a/survey_record_generation/models/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from . import survey_question_answer -from . import survey_question -from . import survey_record_creation_field_values -from . import survey_record_creation -from . import survey_survey -from . import survey_user_input -from . import survey_generated_record \ No newline at end of file diff --git a/survey_record_generation/models/survey_generated_record.py b/survey_record_generation/models/survey_generated_record.py deleted file mode 100644 index d199657..0000000 --- a/survey_record_generation/models/survey_generated_record.py +++ /dev/null @@ -1,15 +0,0 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import models, fields, api - - -class SurveyGeneratedRecord(models.Model): - _name = "survey.generated.record" - - survey_record_creation_name = fields.Char('Name', readonly=True) - survey_record_creation_id = fields.Many2one('survey.record.creation', 'Survey record creation', readonly=True) - user_input_id = fields.Many2one('survey.user_input', 'Participation', readonly=True) - created_record_id = fields.Reference(string="Referenced record", selection='_selection_target_model', readonly=True) - - @api.model - def _selection_target_model(self): - return [(model.model, model.name) for model in self.env['ir.model'].sudo().search([])] \ No newline at end of file diff --git a/survey_record_generation/models/survey_question.py b/survey_record_generation/models/survey_question.py deleted file mode 100644 index 4bb0478..0000000 --- a/survey_record_generation/models/survey_question.py +++ /dev/null @@ -1,49 +0,0 @@ - -import logging -import ast -from typing import Literal - -from odoo import api, fields, models, _, Command -from odoo.exceptions import UserError - -_logger = logging.getLogger(__name__) - -AnswerValuesType: Literal["no", "value", "record"] - -class SurveyQuestion(models.Model): - _inherit = 'survey.question' - - model_id = fields.Many2one('ir.model', string="Model") - model_name = fields.Char(related="model_id.model") - fill_domain = fields.Char("Domain", default="[]") - answer_values_type = fields.Selection([('no', 'No values'),('value','Value'),('record','Record')], string="Associate value to answer", default="no", required=True) - - @api.onchange('model_id') - def onchange_model_id(self): - self.fill_domain = "[]" - if self.model_id: - rec = self.env[self.model_id.model].search([], limit=1) - if not rec: - raise UserError(_('No record found in %s',self.model_id.name)) - else: - for answer in self.suggested_answer_ids: - answer.record_id = f"{self.model_id.model},{rec.id}" - - - def fill(self): - for question in self: - if question.model_id: - new_suggested_answer_ids = [Command.clear()] - record_model = question.model_id.model - - if question.fill_domain: - domain = ast.literal_eval(question.fill_domain) - else: - domain = [] - - records = self.env[record_model].search(domain) - - new_suggested_answer_ids += [Command.create({'value':record.display_name, 'record_id':f"{record_model},{record.id}" -}) for record in records] - question.suggested_answer_ids = new_suggested_answer_ids - diff --git a/survey_record_generation/models/survey_question_answer.py b/survey_record_generation/models/survey_question_answer.py deleted file mode 100644 index fc2a59a..0000000 --- a/survey_record_generation/models/survey_question_answer.py +++ /dev/null @@ -1,42 +0,0 @@ - -import logging - -from odoo import api, fields, models, _ - -_logger = logging.getLogger(__name__) - - -class SurveyQuestionAnswer(models.Model): - _inherit = 'survey.question.answer' - - record_id = fields.Reference(string="Referenced record", selection='_selection_target_model') - model_id = fields.Many2one('ir.model', related="question_id.model_id") - answer_values_type = fields.Selection(related="question_id.answer_values_type") - value_char = fields.Char('Value') - - @api.model - def _selection_target_model(self): - return [(model.model, model.name) for model in self.env['ir.model'].sudo().search([])] - - @api.onchange('record_id') - def onchange_record_id(self): - if self.record_id: - self.value = self.record_id.display_name - - @api.model - def default_get(self, fields): - result = super().default_get(fields) - if ( - not result.get("model_id") - or "record_id" not in fields - ): - return result - - model = self.env['ir.model'].browse(result.get("model_id")).model - res = self.env[model].search([], limit=1) - if res: - result["record_id"] = "%s,%s" % ( - model, - res.id, - ) - return result diff --git a/survey_record_generation/models/survey_record_creation.py b/survey_record_generation/models/survey_record_creation.py deleted file mode 100644 index c72aeb0..0000000 --- a/survey_record_generation/models/survey_record_creation.py +++ /dev/null @@ -1,66 +0,0 @@ -import logging - -from odoo import api, fields, models, _ - -_logger = logging.getLogger(__name__) - - -class SurveyRecordCreation(models.Model): - """Configure list of models for wich record will be created on survey submission - """ - _name = 'survey.record.creation' - - name = fields.Char('Name') - survey_id = fields.Many2one('survey.survey', string="Survey") - model_id = fields.Many2one('ir.model', "Model", help="Model of generated record") - field_values_ids = fields.One2many('survey.record.creation.field.values', 'survey_record_creation_id', string="Field values") - warning_message = fields.Html('Warning message', compute="_compute_warning_message") - sequence = fields.Integer("sequence") - - update_existing_records = fields.Boolean( - string="Update existing records", - ) - field_to_retrieve_existing_records = fields.Many2one( - "ir.model.fields", - domain="[('id', 'in', allowed_field_ids)]", - ondelete="cascade", - help="Choose the field you want to use to retrieve the existing record. " - "WARNING: We update only the first record found.", - ) - allowed_field_ids = fields.Many2many( - "ir.model.fields", - compute="_compute_allowed_field_ids", - store=True, - string="Allowed Fields", - ) - ignore_if_mandatory_field_is_missing = fields.Boolean( - string="Ignore creation if a mandatory field is missing", - help="If a mandatory field is missing when trying to create the record, " - "an error is raised when the survey is submitted. " - "If this option is activated, the error is ignored." - ) - - @api.depends("field_values_ids.field_id") - def _compute_allowed_field_ids(self): - for record in self: - record.allowed_field_ids = record.field_values_ids.mapped("field_id") - - @api.onchange("model_id") - def clear_field_values_ids(self): - self.field_values_ids = None - - @api.depends("model_id","field_values_ids") - def _compute_warning_message(self): - for record_creation in self: - # check if all mandatory fields set - if record_creation.model_id: - required_field_ids = self.model_id.field_id.filtered(lambda f:f.required and "property_" not in f.name) - set_field_ids = self.field_values_ids.field_id - missing_fields = required_field_ids - set_field_ids - - if missing_fields: - record_creation.warning_message = _("Some required fields are not set : %s",', '.join([f"{f.field_description} ({f.name})" for f in missing_fields])) - else: - record_creation.warning_message = None - else: - record_creation.warning_message = None diff --git a/survey_record_generation/models/survey_record_creation_field_values.py b/survey_record_generation/models/survey_record_creation_field_values.py deleted file mode 100644 index 2bc6ec9..0000000 --- a/survey_record_generation/models/survey_record_creation_field_values.py +++ /dev/null @@ -1,197 +0,0 @@ - -import logging - -from odoo import api, fields, models, _ -from odoo.exceptions import UserError -from odoo.tools.misc import format_date - -_logger = logging.getLogger(__name__) - - -type_mapping = { #field types on the left, question types on the right. TODO : what about booleans ? - "char": ["char_box", "numerical_box", "date", "datetime", "simple_choice", "multiple_choice"], - "text": ["char_box", "date", "simple_choice"], - "html": ["text_box", "numerical_box", "datetime", "simple_choice"], - "integer": ["numerical_box"], - "float": ["numerical_box"], - "date": ["date"], - "datetime": ["datetime"], - "many2one": ["simple_choice"], - "many2many": ["multiple_choice"], - "selection": ["char_box", "simple_choice"] -} - - -class SurveyRecordCreationFieldValues(models.Model): - """Configure default values of records created on survey submission - """ - _name = 'survey.record.creation.field.values' - - survey_record_creation_id = fields.Many2one('survey.record.creation') - survey_id = fields.Many2one('survey.survey', related="survey_record_creation_id.survey_id") - model_id = fields.Many2one('ir.model', related="survey_record_creation_id.model_id") - - field_id = fields.Many2one( - 'ir.model.fields', - domain="[('model_id','=',model_id),('ttype','in',['char','selection','text','html','integer','float','date','datetime','many2one','many2many', 'boolean'])]", - ondelete="cascade") - field_relation = fields.Char(related='field_id.relation') - field_type = fields.Selection(related="field_id.ttype") - field_help = fields.Html('Help', compute="_compute_field_help") - - value_origin = fields.Selection( - [('fixed','Fixed'),('question','Question'),('other_record','From other created record')], - string="Value origin", - required=True, - default='fixed', - help="""* Fixed: you can set the value in value field - * Question: Response of the question will set the value. If you do not see your question, maybe the type of question do not match the type of field - * From other created record: You can set other record creation to link several created records. Can only be used with many2one fields.""") - - fixed_value_many2one = fields.Reference(string='Record', selection='_selection_target_model') - fixed_value_many2many = fields.One2many('survey.record.creation.field.values.x2m', "survey_record_creation_field_values_id") - fixed_value_char = fields.Char("Value") - fixed_value_selection = fields.Char("Value") - fixed_value_text = fields.Text("Value") - fixed_value_html = fields.Html("Value") - fixed_value_integer = fields.Integer("Value") - fixed_value_float = fields.Float("Value") - fixed_value_date = fields.Date("Value") - fixed_value_datetime = fields.Datetime("Value") - fixed_value_boolean = fields.Boolean("Value") - - displayed_value = fields.Char("Value", compute="_compute_displayed_value") - other_created_record_id = fields.Many2one("survey.record.creation", string="Other record", domain="[('survey_id','=',survey_id),('model_id.model','=',field_relation)]") - - allowed_question_ids = fields.Many2many('survey.question', compute='_compute_allowed_question_ids') - question_id = fields.Many2one('survey.question', string="Question", domain="[('id','in',allowed_question_ids)]") - - unicity_check = fields.Boolean('Unicity constraint', help="On record creation, if another record exists with same value, record will not be created.") - - @api.depends("field_id") - def _compute_field_help(self): - for record in self: - field_help = _("Field type is : %s",record.field_type) - if record.field_type == "selection": - field_help += "
    "+_("possible values are %s",', '.join([f"{s.value} ({s.name})" for s in record.field_id.selection_ids])) - record.field_help = field_help - - - @api.depends('field_id') - def _compute_allowed_question_ids(self): - for record_creation_field_values in self: - if not record_creation_field_values.survey_id or not record_creation_field_values.field_id: - record_creation_field_values.allowed_question_ids = None - return - question_domain = [('survey_id','=',record_creation_field_values.survey_id.id)] - - if record_creation_field_values.field_id.ttype in ['many2one','many2many']: - question_domain.extend(['|','&',('answer_values_type','=','record'),('model_id','=',record_creation_field_values.field_id.relation),('answer_values_type','=','value')]) - if record_creation_field_values.field_id.ttype in type_mapping: - question_domain.append(('question_type','in',type_mapping[record_creation_field_values.field_id.ttype])) - - record_creation_field_values.allowed_question_ids = self.env['survey.question'].search(question_domain) - - - @api.model - def _selection_target_model(self): - return [(model.model, model.name) for model in self.env['ir.model'].sudo().search([])] - - def clean_values(self): - # clean values - self.fixed_value_many2many = None - self.fixed_value_many2one = None - self.fixed_value_char = None - self.fixed_value_selection = None - self.fixed_value_text = None - self.fixed_value_html = None - self.fixed_value_integer = None - self.fixed_value_float = None - self.fixed_value_date = None - self.fixed_value_datetime = None - self.other_created_record_id = None - self.question_id = None - - @api.onchange('field_id') - def _onchange_field_id(self): - # clean values - self.clean_values() - # Set reference field model and select first record - if self.field_id and self.field_id.ttype == 'many2one' and self.field_id.relation: - rec = self.env[self.field_id.relation].search([], limit=1) - if rec: - self.fixed_value_many2one = f"{self.field_id.relation},{rec.id}" - else: - model_name = self.env['ir.model'].search([('model','=',self.field_id.relation)]).name - self.fixed_value_many2one = None - raise UserError(_('You should append at least one record in %s',model_name)) - else: - self.fixed_value_many2one = None - - - def get_fixed_value_for_record_creation(self): - """return val used in create() method - - """ - if self.value_origin == 'fixed': - if self.field_type == 'many2one': - if self.fixed_value_many2one: - return self.fixed_value_many2one.id - elif self.field_type == 'many2many': - return [m2m.value_reference.id for m2m in self.fixed_value_many2many if m2m.value_reference] - else: - return self["fixed_value_"+self.field_type] - - - @api.onchange("fixed_value_char","fixed_value_selection","fixed_value_text","fixed_value_html","fixed_value_integer","fixed_value_float","fixed_value_date","fixed_value_datetime",'fixed_value_many2one', "fixed_value_many2many","other_created_record_id","question_id") - def _compute_displayed_value(self): - for record in self: - if record.field_id: - if record.value_origin == 'other_record' and record.other_created_record_id: - record.displayed_value = _("Other created record: ")+record.other_created_record_id.name - elif record.value_origin == 'fixed': - if record.field_id.ttype == "many2one": - if record.fixed_value_many2one: - record.displayed_value = record.fixed_value_many2one.display_name - else: - record.displayed_value = None - elif record.field_id.ttype == "many2many": - if record.fixed_value_many2many: - record.displayed_value = ", ".join([r.value_reference.display_name for r in record.fixed_value_many2many if r.value_reference]) - else: - record.displayed_value = None - elif record.field_id.ttype == "date": - record.displayed_value = format_date(self.env, record.fixed_value_date) - elif record.field_id.ttype == "datetime": - record.displayed_value = format_date(self.env, record.fixed_value_datetime) - else: - record.displayed_value = str(record['fixed_value_'+record.field_id.ttype]) - else: #value_origin = question - record.displayed_value = _('Answer to question: %s',record.question_id.title) - else: - record.displayed_value = "" - -class SurveyRecordCreationFieldValuesX2m(models.Model): - """O2m an M2m default values - """ - _name = 'survey.record.creation.field.values.x2m' - - survey_record_creation_field_values_id = fields.Many2one('survey.record.creation.field.values') - value_reference = fields.Reference(string='Record', selection='_selection_target_model') - - @api.model - def _selection_target_model(self): - return [(model.model, model.name) for model in self.env['ir.model'].sudo().search([])] - - - @api.onchange('survey_record_creation_field_values_id') - def _onchange_model_name(self): - # Set reference field model and select first record - field = self.survey_record_creation_field_values_id.field_id - if field and "2many" in field.ttype and field.relation: - rec = self.env[field.relation].search([], limit=1) - if rec: - self.value_reference = f"{field.relation},{rec.id}" - else: - model_name = self.env['ir.model'].search([('model','=',field.relation)]).name - raise ValueError(_('You should append at least one record in %s',(model_name,))) diff --git a/survey_record_generation/models/survey_survey.py b/survey_record_generation/models/survey_survey.py deleted file mode 100644 index e60a8c4..0000000 --- a/survey_record_generation/models/survey_survey.py +++ /dev/null @@ -1,13 +0,0 @@ - -import logging - -from odoo import api, fields, models, _ - -_logger = logging.getLogger(__name__) - - -class SurveySurvey(models.Model): - _inherit = 'survey.survey' - - survey_record_creation_ids = fields.One2many('survey.record.creation', 'survey_id', 'Records creation', help="List of records created when survey submitted") - \ No newline at end of file diff --git a/survey_record_generation/models/survey_user_input.py b/survey_record_generation/models/survey_user_input.py deleted file mode 100644 index 15dc299..0000000 --- a/survey_record_generation/models/survey_user_input.py +++ /dev/null @@ -1,339 +0,0 @@ -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from typing import TYPE_CHECKING, Any, Literal - -from odoo import _, fields, models -from odoo.exceptions import UserError -from odoo.fields import Command - -if TYPE_CHECKING: - from .survey_question import AnswerValuesType - from .survey_record_creation import SurveyRecordCreation - from .survey_record_creation_field_values import SurveyRecordCreationFieldValues - - -class SurveyUserInput(models.Model): - _inherit = "survey.user_input" - - generated_record_ids = fields.One2many( - "survey.generated.record", "user_input_id", "Generated records" - ) - generated_records_count = fields.Integer( - "Attempts Count", compute="_compute_generated_records_count" - ) - - def _compute_generated_records_count(self): - for user_input in self: - user_input.generated_records_count = len(user_input.generated_record_ids) - - def action_redirect_to_generated_records(self): - self.ensure_one() - - action = self.env["ir.actions.act_window"]._for_xml_id( - "survey_record_generation.survey_generated_record_action" - ) - - return action - - def _mark_done(self): - # generate records - for user_input in self: - created_records = {} - other_record_fields_to_update: list[SurveyRecordCreationFieldValues] = [] - - record_creation: SurveyRecordCreation - for ( - record_creation - ) in user_input.survey_id.survey_record_creation_ids.sorted("sequence"): - model: str = record_creation.model_id.model - vals: dict = {} - - field_value: SurveyRecordCreationFieldValues - for field_value in record_creation.field_values_ids: - value, other_record_fields_to_update = ( - self.get_value_based_on_value_origin( - field_value=field_value, - user_input=user_input, - created_records=created_records, - model=model, - other_record_fields_to_update=other_record_fields_to_update, - ) - ) - field_name: str = field_value.field_id.name - - vals[field_name] = value - - existing_record = self.find_existing_record(record_creation, vals) - - duplicate = self.find_duplicate_if_there_are_fields_with_unicity_check( - model, record_creation, vals - ) - - if duplicate: - record = duplicate - elif existing_record: - vals_with_keys_not_in_record = { - k: v - for k, v in vals.items() - if not getattr(existing_record, k, False) - } - existing_record.write(vals_with_keys_not_in_record) - record = existing_record - else: - try: - with self.env.cr.savepoint(): - record = self.env[model].create(vals) - if model == "res.partner" and not self.partner_id: - self.partner_id = record.id - except Exception: - # This a broad exception because it could be IntegrityError, - # EmptyNamesError in case partner_firstname is installed etc... - if record_creation.ignore_if_mandatory_field_is_missing: - continue - raise - # Link generated records to user input - self.env["survey.generated.record"].create( - { - "survey_record_creation_name": record_creation.name, - "survey_record_creation_id": record_creation.id, - "user_input_id": user_input.id, - "created_record_id": f"{model},{record.id}", - } - ) - - created_records[record_creation.id] = record - - # update linked record - for field_to_update in other_record_fields_to_update: - record_to_update = created_records.get( - field_to_update.survey_record_creation_id.id - ) - if record_to_update: - linked_record = created_records[ - field_to_update.other_created_record_id.id - ] - value = self.get_value_for_relational_field( - field_to_update, linked_record - ) - record_to_update.write({field_to_update.field_id.name: value}) - - return super()._mark_done() - - def find_existing_record( - self, record_creation: "SurveyRecordCreation", vals: dict - ) -> Any: - if record_creation.update_existing_records: - model = record_creation.model_id.model - search_field = record_creation.field_to_retrieve_existing_records - user_answer_value = vals.get(search_field.name) - if user_answer_value: - return self.env[model].search( - [(search_field.name, "=", user_answer_value)], limit=1 - ) - - return None - - def get_value_based_on_value_origin( - self, - field_value: "SurveyRecordCreationFieldValues", - user_input: "SurveyUserInput", - created_records: dict[Any, Any], - model: str, - other_record_fields_to_update: list["SurveyRecordCreationFieldValues"], - ) -> tuple[Any, list["SurveyRecordCreationFieldValues"]]: - value: Any = None - - if field_value.value_origin == "fixed": - value = field_value.get_fixed_value_for_record_creation() - elif field_value.value_origin == "question": - value = self.get_value_from_user_answer(field_value, user_input) - elif field_value.value_origin == "other_record": - # if the other_record value is a required field, get it or raise - value = self.get_required_value_from_other_record( - model, created_records, field_value - ) - # otherwise, we update the record later (out of this for loop) - if not value: - other_record_fields_to_update.append(field_value) - return value, other_record_fields_to_update - - @staticmethod - def get_value_for_relational_field( - field_to_update: "SurveyRecordCreationFieldValues", linked_record - ) -> Any: - field_type = field_to_update.field_id.ttype - if field_type == "many2one": - return linked_record.id - else: - # many2many or one2many - return [Command.set(linked_record.ids)] - - def find_duplicate_if_there_are_fields_with_unicity_check( - self, model: str, record_creation: "SurveyRecordCreation", vals: dict[Any, Any] - ) -> Any: - # check duplicates - unique_fields = [ - field_value.field_id.name - for field_value in record_creation.field_values_ids.filtered( - lambda r: r.unicity_check - ) - ] - duplicate = None - if unique_fields: - uniq_domain = [] - for uniq_field in unique_fields: - uniq_domain.append((uniq_field, "=", vals[uniq_field])) - duplicate = self.env[model].search(uniq_domain, limit=1) - return duplicate - - def get_required_value_from_other_record( - self, - model: str, - created_records: dict[Any, Any], - field_value: "SurveyRecordCreationFieldValues", - ) -> Any: - model_class = self.env[model] - if model_class._fields[field_value.field_id.name].required: - # check if the other record is already created, - # if yes add it to vals, else raise - if ( - len(created_records) > 0 - and created_records[field_value.other_created_record_id.id] - ): - linked_record = created_records[field_value.other_created_record_id.id] - return self.get_value_for_relational_field(field_value, linked_record) - else: - raise UserError( - _( - "The field %(field)s is mandatory for model %(model)s. " - "In Record Creation tab, drag %(record)s " - "on top of the model %(model)s." - ) - % { - "field": field_value.field_id.display_name, - "model": model, - "record": field_value.other_created_record_id.name, - } - ) - - def get_value_from_user_answer( - self, - field_value: "SurveyRecordCreationFieldValues", - user_input: "SurveyUserInput", - ) -> Any: - # find user_input_lines (which are user's answers) for the question - user_input_lines = [ - user_input_line - for user_input_line in user_input.user_input_line_ids - if user_input_line.question_id == field_value.question_id - ] - - if not user_input_lines: - # If the question has not been displayed to the user, - # there are no user_input_lines - return None - if user_input_lines[0].skipped: - # The question has been ignored by the user - return None - - question_type = field_value.question_id.question_type - - if question_type in [ - "char_box", - "text_box", - "numerical_box", - "date", - "datetime", - ]: - return user_input_lines[0][f"value_{user_input_lines[0].answer_type}"] - elif question_type in ["simple_choice", "multiple_choice", "matrix"]: - answer_values_type = field_value.question_id.answer_values_type - return self.get_value_based_on_answer_values_type( - answer_values_type, field_value, question_type, user_input_lines - ) - else: - raise UserError( - _( - "[Survey record generation] The question type %(type)s is not " - "recognized (for question %(question)s)." - ) - % {"type": question_type, "question": field_value.question_id.title} - ) - - def get_value_based_on_answer_values_type( - self, - answer_values_type: "AnswerValuesType", - field_value: "SurveyRecordCreationFieldValues", - question_type: Literal["simple_choice", "multiple_choice", "matrix"], - user_input_lines: list[Any], - ) -> Any: - if answer_values_type == "record": - answered_record_ids = [] - for user_input_line in user_input_lines: - if ( - user_input_line.suggested_answer_id - and user_input_line.suggested_answer_id.record_id - ): - answered_record_ids.append( - user_input_line.suggested_answer_id.record_id.id - ) - if not answered_record_ids: - return None - if question_type == "simple_choice": - return answered_record_ids[0] - elif question_type == "multiple_choice": - return answered_record_ids - else: - raise UserError( - _( - "[Survey record generation] The question type" - " %(type)s is not supported yet." - ) - % {"type": question_type} - ) - elif answer_values_type == "value": - answer_value_char = user_input_lines[0].suggested_answer_id.value_char - if field_value.field_id.ttype != "boolean": - return answer_value_char - else: - return self.get_boolean_value( - answer_value_char=answer_value_char, - question_title=field_value.question_id.title, - ) - else: - raise UserError( - _( - "[Survey record generation] The answer values type '%(type)s' " - "is not supported (for question %(question)s). Use 'record' or " - "'value' instead." - ) - % { - "type": answer_values_type, - "question": field_value.question_id.title, - } - ) - - @staticmethod - def get_boolean_value(answer_value_char: str, question_title: str) -> bool: - # Below code is a trick to be able to use "simple_choice" question - # with values 'yes' and 'no' and transform it to boolean. - if boolean_value := answer_value_char in [ - "1", - "True", - "true", - "Oui", - "oui", - "Yes", - "yes", - ]: - return boolean_value - else: - raise UserError( - _( - "[Survey record generation] The boolean value %s(value)s " - "is not supported (for question %(question)s)." - ) - % { - "value": answer_value_char, - "question": question_title, - } - ) diff --git a/survey_record_generation/readme/CONFIGURE.rst b/survey_record_generation/readme/CONFIGURE.rst deleted file mode 100644 index 99d1c5c..0000000 --- a/survey_record_generation/readme/CONFIGURE.rst +++ /dev/null @@ -1,40 +0,0 @@ -Record generation configuration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. |Image of record creation list| image:: ../static/description/record-creations.png - -#. Go to the the survey -#. In *Record creation* tab add a new line -#. Set a name for created record, select the Model of the record (eg: Prospect) -#. Add a field configuration. So for each field : - - .. |Image of record creation fields| image:: ../static/description/record-creation-customer.png - - #. You can check "unicity constraint" to prevent duplicates. - In case of duplicates and if other record use this record to fill a m2o field, the founded record will be used - #. You can configure explicitly where Odoo should retrieve the value of field : - * **fixed**: To set explicit value - * **question**: If value come from user's answer - For m2o or m2m links, question should be configured before. See Question answers configuration section below. - * **other created record**: If value come from other created record (m2o case only) - - - -Question answers configuration -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In a survey question : to configure value of choices - -.. |Question answers| image:: ../static/description/question-answers.png - -#. Configure a multiple choice question -#. Select value type associated to answer: - * **Value** > eg: to fill a selection field - * **Record** > to fill m2o or m2m field -#. In case of *record* type: - #. Select referenced model - #. You can directly fill answers (eventualy with help of the domain field) - #. Or create new answers and set associated record -#. In case of *value* type: - #. Add new selectable answers and set associated value - diff --git a/survey_record_generation/readme/CONTEXT.rst b/survey_record_generation/readme/CONTEXT.rst deleted file mode 100644 index 6887590..0000000 --- a/survey_record_generation/readme/CONTEXT.rst +++ /dev/null @@ -1,10 +0,0 @@ -In several cases we want to use survey application to create records. -Website form application give the same possibility but the design is integrated on the web site. -Futhermore this module add other functionnalities like "duplicate" check, or creation of several interconnected records - -Typical use case : Information request form - -#. Submitting the form will create a contact (partner) only if it does not already exist in the database. -#. Submitting the form will also create a crm opportunity linked to previously created partner - - diff --git a/survey_record_generation/readme/CONTRIBUTORS.rst b/survey_record_generation/readme/CONTRIBUTORS.rst deleted file mode 100644 index 6aaf080..0000000 --- a/survey_record_generation/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,4 +0,0 @@ -* `Elabore `_ - - * Clément Thomas - * Quentin Mondot diff --git a/survey_record_generation/readme/DESCRIPTION.rst b/survey_record_generation/readme/DESCRIPTION.rst deleted file mode 100644 index 2f732ef..0000000 --- a/survey_record_generation/readme/DESCRIPTION.rst +++ /dev/null @@ -1 +0,0 @@ -This module allows to generate any record from surveys answers. \ No newline at end of file diff --git a/survey_record_generation/readme/USAGE.rst b/survey_record_generation/readme/USAGE.rst deleted file mode 100644 index 6c9047c..0000000 --- a/survey_record_generation/readme/USAGE.rst +++ /dev/null @@ -1,6 +0,0 @@ -When a survey is properly configured, once it is submited by a user, records should be created. - -To find records generated from a participation go to: - -#. Survey > participation -#. Click on **# Generated records** button (top-right) diff --git a/survey_record_generation/security/ir.model.access.csv b/survey_record_generation/security/ir.model.access.csv deleted file mode 100644 index 8bd10dc..0000000 --- a/survey_record_generation/security/ir.model.access.csv +++ /dev/null @@ -1,5 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_survey_record_creation,survey.record.creation,survey_record_generation.model_survey_record_creation,survey.group_survey_user,1,1,1,1 -access_survey_record_creation_field_values,survey.record.creation.field.values,survey_record_generation.model_survey_record_creation_field_values,survey.group_survey_user,1,1,1,1 -access_survey_record_creation_field_values_x2m,survey.record.creation.field.values.x2m,survey_record_generation.model_survey_record_creation_field_values_x2m,survey.group_survey_user,1,1,1,1 -access_survey_generated_record,survey.generated.record,survey_record_generation.model_survey_generated_record,survey.group_survey_user,1,1,1,1 \ No newline at end of file diff --git a/survey_record_generation/static/description/index.html b/survey_record_generation/static/description/index.html deleted file mode 100644 index 8c697d4..0000000 --- a/survey_record_generation/static/description/index.html +++ /dev/null @@ -1,526 +0,0 @@ - - - - - -Survey record generation - - - -
    -

    Survey record generation

    - - -

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

    -

    This module allows to generate any record from surveys answers.

    -

    Table of contents

    - -
    -

    Use Cases / Context

    -

    In several cases we want to use survey application to create records. -Website form application give the same possibility but the design is integrated on the web site. -Futhermore this module add other functionnalities like “duplicate” check, or creation of several interconnected records

    -

    Typical use case : Information request form

    -
      -
    1. Submitting the form will create a contact (partner) only if it does not already exist in the database.
    2. -
    3. Submitting the form will also create a crm opportunity linked to previously created partner
    4. -
    -
    -
    -

    Configuration

    -
    -

    Record generation configuration

    -
      -
    1. Go to the the survey

      -
    2. -
    3. In Record creation tab add a new line

      -
    4. -
    5. Set a name for created record, select the Model of the record (eg: Prospect)

      -
    6. -
    7. Add a field configuration. So for each field :

      -
      -
        -
      1. -
        You can check “unicity constraint” to prevent duplicates.
        -
        In case of duplicates and if other record use this record to fill a m2o field, the founded record will be used
        -
        -
      2. -
      3. -
        You can configure explicitly where Odoo should retrieve the value of field :
        -
          -
        • fixed: To set explicit value
        • -
        • -
          question: If value come from user’s answer
          -
          For m2o or m2m links, question should be configured before. See Question answers configuration section below.
          -
          -
        • -
        • other created record: If value come from other created record (m2o case only)
        • -
        -
        -
        -
      4. -
      -
      -
    8. -
    -
    -
    -

    Question answers configuration

    -

    In a survey question : to configure value of choices

    -
      -
    1. Configure a multiple choice question
    2. -
    3. -
      Select value type associated to answer:
      -
        -
      • Value > eg: to fill a selection field
      • -
      • Record > to fill m2o or m2m field
      • -
      -
      -
      -
    4. -
    5. -
      In case of record type:
      -
        -
      1. Select referenced model
      2. -
      3. You can directly fill answers (eventualy with help of the domain field)
      4. -
      5. Or create new answers and set associated record
      6. -
      -
      -
      -
    6. -
    7. -
      In case of value type:
      -
        -
      1. Add new selectable answers and set associated value
      2. -
      -
      -
      -
    8. -
    -
    -
    -
    -

    Usage

    -

    When a survey is properly configured, once it is submited by a user, records should be created.

    -

    To find records generated from a participation go to:

    -
      -
    1. Survey > participation
    2. -
    3. Click on # Generated records button (top-right)
    4. -
    -
    -
    -

    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

    -
      -
    • Elabore
    • -
    -
    -
    -

    Contributors

    - -
    -
    -

    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.

    -

    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_record_generation/static/description/question-answers.png b/survey_record_generation/static/description/question-answers.png deleted file mode 100644 index 50d6e02..0000000 Binary files a/survey_record_generation/static/description/question-answers.png and /dev/null differ diff --git a/survey_record_generation/static/description/record-creation-customer.png b/survey_record_generation/static/description/record-creation-customer.png deleted file mode 100644 index 8fc8feb..0000000 Binary files a/survey_record_generation/static/description/record-creation-customer.png and /dev/null differ diff --git a/survey_record_generation/static/description/record-creations.png b/survey_record_generation/static/description/record-creations.png deleted file mode 100644 index 03a7c27..0000000 Binary files a/survey_record_generation/static/description/record-creations.png and /dev/null differ diff --git a/survey_record_generation/tests/__init__.py b/survey_record_generation/tests/__init__.py deleted file mode 100644 index 5b794a3..0000000 --- a/survey_record_generation/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import test_survey_record_creation diff --git a/survey_record_generation/tests/test_survey_record_creation.py b/survey_record_generation/tests/test_survey_record_creation.py deleted file mode 100644 index 5b84ce2..0000000 --- a/survey_record_generation/tests/test_survey_record_creation.py +++ /dev/null @@ -1,893 +0,0 @@ -from datetime import date - -from psycopg2 import IntegrityError - -from odoo.addons.survey.tests.common import SurveyCase - - -class TestSurveyRecordCreation(SurveyCase): - def setUp(self): - super().setUp() - # We create a survey - self.survey = self.env["survey.survey"].create( - { - "title": "Test Survey", - } - ) - # With a single question "name" - self.question_name = self._add_question( - page=None, - name="Name", - qtype="char_box", - survey_id=self.survey.id, - sequence=1, - ) - - self.res_partner_model = self.env["ir.model"]._get("res.partner") - # The administrator has set up a record creation on res.partner model - self.survey_record_creation = self.env["survey.record.creation"].create( - { - "name": "Contact", - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - } - ) - self.name_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "name")] - ) - # And linked the res_partner field "name" to the answer of question_name - self.name_survey_record_creation_field_values = self.env[ - "survey.record.creation.field.values" - ].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": self.name_field.id, - "value_origin": "question", - "question_id": self.question_name.id, - } - ) - - def test_record_is_created(self): - # Easy test to become familiar with the subject (check comments of setUp) - - # We simulate that jean@test.fr has answered the survey - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - # He answered "Jean" to the question_name - self._add_answer_line( - question=self.question_name, answer=self.answer, answer_value="Jean" - ) - # And validate the survey - self.answer._mark_done() - - # Thus, the res.partner with the name "Jean" has been created - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertTrue(partner.name == "Jean") - - def test_all_types_of_question(self): - # Still todo : "datetime" and "text_box" - # Also todo : "simple_choice" with answer_values_type "no" - # Also todo : "multiple_choice" with answer_values_type "no" and "value" - # Note : matrix question type is never proposed in the allowed_question_ids - - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - - ### "char_box" type of question, tested with field CHAR "name" ### - self._add_answer_line( - question=self.question_name, answer=self.answer, answer_value="Jean" - ) - - ### "numerical_box" type of question, - # tested with FLOAT field "partner_latitude" ### - self.question_partner_latitude = self._add_question( - page=None, - name="Partner latitude", - qtype="numerical_box", - survey_id=self.survey.id, - sequence=1, - ) - - partner_latitude_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "partner_latitude")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": partner_latitude_field.id, - "value_origin": "question", - "question_id": self.question_partner_latitude.id, - } - ) - - self._add_answer_line( - question=self.question_partner_latitude, - answer=self.answer, - answer_value=44.73333, - ) - - ### "date" type of question, tested with DATE field "date" ### - self.question_date = self._add_question( - page=None, name="Date", qtype="date", survey_id=self.survey.id, sequence=1 - ) - - date_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "date")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": date_field.id, - "value_origin": "question", - "question_id": self.question_date.id, - } - ) - - self._add_answer_line( - question=self.question_date, answer=self.answer, answer_value=date.today() - ) - - ### "simple_choice" type of question, tested with SELECTION field "type" ### - ### Here we also test answer_values_type "value" - self.question_type = self._add_question( - page=None, - name="Type", - qtype="simple_choice", - labels=[ - {"value": "contact"}, - {"value": "other"}, - ], - survey_id=self.survey.id, - sequence=1, - answer_values_type="value", - ) - - self.question_type.suggested_answer_ids[0].value_char = ( - self.question_type.suggested_answer_ids[0].value - ) - self.question_type.suggested_answer_ids[1].value_char = ( - self.question_type.suggested_answer_ids[1].value - ) - - type_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "type")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": type_field.id, - "value_origin": "question", - "question_id": self.question_type.id, - } - ) - - self._add_answer_line( - question=self.question_type, - answer=self.answer, - answer_value=self.question_type.suggested_answer_ids[0].id, - ) - - ### "simple_choice" type of question, tested with MANY2ONE field "title" ### - ### Here we also test answer_values_type "record" - - mister_title = self.env["res.partner.title"].create({"name": "Mister"}) - madam_title = self.env["res.partner.title"].create({"name": "Madam"}) - self.question_title = self._add_question( - page=None, - name="Title", - qtype="simple_choice", - labels=[ - {"value": mister_title.display_name}, - {"value": madam_title.display_name}, - ], - survey_id=self.survey.id, - sequence=1, - answer_values_type="record", - ) - - self.question_title.suggested_answer_ids[0].record_id = ( - f"res.partner.title,{mister_title.id}" - ) - self.question_title.suggested_answer_ids[1].record_id = ( - f"res.partner.title,{madam_title.id}" - ) - - title_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "title")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": title_field.id, - "value_origin": "question", - "question_id": self.question_title.id, - } - ) - - self._add_answer_line( - question=self.question_title, - answer=self.answer, - answer_value=self.question_title.suggested_answer_ids[0].id, - ) - - ### "multiple_choice" type of question, - # tested with MANY2MANY field "category" ### - adult_category = self.env["res.partner.category"].create({"name": "Adult"}) - teenager_category = self.env["res.partner.category"].create( - {"name": "Teenager"} - ) - child_category = self.env["res.partner.category"].create({"name": "Child"}) - self.question_category = self._add_question( - page=None, - name="Category", - qtype="multiple_choice", - labels=[ - {"value": adult_category.display_name}, - {"value": teenager_category.display_name}, - {"value": child_category.display_name}, - ], - survey_id=self.survey.id, - sequence=1, - answer_values_type="record", - ) - - self.question_category.suggested_answer_ids[0].record_id = ( - f"res.partner.category,{adult_category.id}" - ) - self.question_category.suggested_answer_ids[1].record_id = ( - f"res.partner.category,{teenager_category.id}" - ) - self.question_category.suggested_answer_ids[2].record_id = ( - f"res.partner.category,{child_category.id}" - ) - - category_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "category_id")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": category_field.id, - "value_origin": "question", - "question_id": self.question_category.id, - } - ) - - self._add_answer_line( - question=self.question_category, - answer=self.answer, - answer_value=self.question_category.suggested_answer_ids[0].id, - ) - self._add_answer_line( - question=self.question_category, - answer=self.answer, - answer_value=self.question_category.suggested_answer_ids[1].id, - ) - - self.answer._mark_done() - partner = self.env["res.partner"].search( - [ - ("name", "=", "Jean"), - ("partner_latitude", "=", 44.73333), - ("date", "=", date.today()), - ("type", "=", "contact"), - ("title", "=", mister_title.id), - ("category_id", "=", adult_category.id), - ("category_id", "=", teenager_category.id), - ("category_id", "!=", child_category.id), - ] - ) - self.assertTrue(partner.name == "Jean") - - def test_records_are_created(self): - # we test that several records can be created at the end of the same survey - # concurrently, we test the value_origin "other_record" and "fixed" - res_partner_bank_model = self.env["ir.model"]._get("res.partner.bank") - self.bank_survey_record_creation = self.env["survey.record.creation"].create( - { - "name": "Bank", - "survey_id": self.survey.id, - "model_id": res_partner_bank_model.id, - } - ) - # Below we test "value_origin": "other_record" with a required field - partner_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner.bank"), ("name", "=", "partner_id")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.bank_survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": res_partner_bank_model.id, - "field_id": partner_field.id, - "value_origin": "other_record", - "other_created_record_id": self.survey_record_creation.id, - } - ) - # Below we test "value_origin": "fixed" - acc_number_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner.bank"), ("name", "=", "acc_number")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.bank_survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": res_partner_bank_model.id, - "field_id": acc_number_field.id, - "value_origin": "fixed", - "fixed_value_char": "FR76 1444 5004 0004 0000 0000 000", - } - ) - # Below we test "value_origin": "other_record" with a NOT required field - bank_ids_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "bank_ids")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": bank_ids_field.id, - "value_origin": "other_record", - "other_created_record_id": self.bank_survey_record_creation.id, - } - ) - - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, answer=self.answer, answer_value="Jean" - ) - self.answer._mark_done() - - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertTrue(partner.name == "Jean") - bank_account = self.env["res.partner.bank"].search( - [("partner_id", "=", partner.id)] - ) - self.assertTrue(bank_account.acc_number == "FR76 1444 5004 0004 0000 0000 000") - - def test_records_of_same_model_are_created(self): - # When we have 2 survey.record.creation on res.partner, - # we check that 2 contacts are created - self.second_question_name = self._add_question( - page=None, - name="Name of second person", - qtype="char_box", - survey_id=self.survey.id, - sequence=1, - ) - - self.second_contact_creation = self.env["survey.record.creation"].create( - { - "name": "Contact 2", - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - } - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.second_contact_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": self.name_field.id, - "value_origin": "question", - "question_id": self.second_question_name.id, - } - ) - - self.first_answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, - answer=self.first_answer, - answer_value="Jean", - ) - self._add_answer_line( - question=self.second_question_name, - answer=self.first_answer, - answer_value="Jeanne", - ) - self.first_answer._mark_done() - - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertTrue(partner.name == "Jean") - partner = self.env["res.partner"].search([("name", "=", "Jeanne")]) - self.assertTrue(partner.name == "Jeanne") - - def test_survey_submitted_twice_by_same_user(self): - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, answer=self.answer, answer_value="Jean" - ) - self.answer._mark_done() - - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertTrue(partner.name == "Jean") - - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, answer=self.answer, answer_value="Jean" - ) - self.answer._mark_done() - - partners = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertTrue(len(partners) == 2) - - def test_unicity_check(self): - # In this test, we check the behavior of unicity_check - self.name_survey_record_creation_field_values.unicity_check = True - - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, answer=self.answer, answer_value="Jean" - ) - self.answer._mark_done() - - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertTrue(partner.name == "Jean") - - self.second_answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, answer=self.second_answer, answer_value="Jean" - ) - self.second_answer._mark_done() - - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertTrue(partner.name == "Jean") - self.assertTrue(len(partner) == 1) - - def test_some_questions_are_not_answered(self): - self.question_email = self._add_question( - page=None, - name="Email", - qtype="char_box", - survey_id=self.survey.id, - sequence=1, - ) - mister_title = self.env["res.partner.title"].create({"name": "Mister"}) - madam_title = self.env["res.partner.title"].create({"name": "Madam"}) - self.question_title = self._add_question( - page=None, - name="Title", - qtype="simple_choice", - labels=[ - {"value": mister_title.display_name}, - {"value": madam_title.display_name}, - ], - survey_id=self.survey.id, - sequence=1, - answer_values_type="record", - ) - self.question_title.suggested_answer_ids[0].record_id = ( - f"res.partner.title,{mister_title.id}" - ) - self.question_title.suggested_answer_ids[1].record_id = ( - f"res.partner.title,{madam_title.id}" - ) - - self.question_street = self._add_question( - page=None, - name="Street", - qtype="char_box", - survey_id=self.survey.id, - sequence=1, - ) - - email_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "email")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": email_field.id, - "value_origin": "question", - "question_id": self.question_email.id, - } - ) - title_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "title")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": title_field.id, - "value_origin": "question", - "question_id": self.question_title.id, - } - ) - street_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "street")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": street_field.id, - "value_origin": "question", - "question_id": self.question_street.id, - } - ) - - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, answer=self.answer, answer_value="Jean" - ) - self._add_answer_line( - question=self.question_email, - answer=self.answer, - answer_value=False, - skipped=True, - answer_type=False, - ) - self._add_answer_line( - question=self.question_title, - answer=self.answer, - answer_value=False, - skipped=True, - answer_type=False, - ) - self.answer._mark_done() - - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertTrue(partner.name == "Jean") - self.assertFalse(partner.email) - self.assertFalse(partner.title) - self.assertFalse(partner.street) - - def test_boolean_field(self): - self.question_employee = self._add_question( - page=None, - name="Employee", - qtype="simple_choice", - labels=[ - {"value": "yes"}, - {"value": "no"}, - ], - survey_id=self.survey.id, - sequence=1, - answer_values_type="value", - ) - - self.question_employee.suggested_answer_ids[0].value_char = ( - self.question_employee.suggested_answer_ids[0].value - ) - self.question_employee.suggested_answer_ids[1].value_char = ( - self.question_employee.suggested_answer_ids[1].value - ) - - employee_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "employee")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": employee_field.id, - "value_origin": "question", - "question_id": self.question_employee.id, - } - ) - - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, answer=self.answer, answer_value="Jean" - ) - self._add_answer_line( - question=self.question_employee, - answer=self.answer, - answer_value=self.question_employee.suggested_answer_ids[0].id, - ) - self.answer._mark_done() - - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertTrue(partner.employee) - - def test_update_existing_record(self): - # A contact with name 'Jean' already exists. - # We'll update the email of this partner (and not create a new one) - self.env["res.partner"].create({"name": "Jean"}) - - self.question_email = self._add_question( - page=None, - name="Email", - qtype="char_box", - survey_id=self.survey.id, - sequence=1, - ) - - self.survey_record_creation.write( - { - "update_existing_records": True, - "field_to_retrieve_existing_records": self.name_field.id, - } - ) - email_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "email")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": email_field.id, - "value_origin": "question", - "question_id": self.question_email.id, - } - ) - - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, answer=self.answer, answer_value="Jean" - ) - self._add_answer_line( - question=self.question_email, - answer=self.answer, - answer_value="jean@test.fr", - ) - self.answer._mark_done() - - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertTrue(len(partner) == 1) - self.assertTrue(partner.email == "jean@test.fr") - - def test_update_only_empty_fields_when_updating_records(self): - # A contact with name 'Jean' and email 'jean@test.fr' already exists. - # We'll update the field 'function' of this partner and won't update the email - # because it's already filled up - self.env["res.partner"].create( - { - "name": "Jean", - "email": "jean@test.fr", - # when the survey is submitted, email should not be updated - } - ) - self.question_email = self._add_question( - page=None, - name="Email", - qtype="char_box", - survey_id=self.survey.id, - sequence=1, - ) - self.question_function = self._add_question( - page=None, - name="Function", - qtype="char_box", - survey_id=self.survey.id, - sequence=1, - ) - - self.survey_record_creation.write( - { - "update_existing_records": True, - "field_to_retrieve_existing_records": self.name_field.id, - } - ) - email_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "email")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": email_field.id, - "value_origin": "question", - "question_id": self.question_email.id, - } - ) - function_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "function")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": function_field.id, - "value_origin": "question", - "question_id": self.question_function.id, - } - ) - - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, answer=self.answer, answer_value="Jean" - ) - self._add_answer_line( - question=self.question_email, - answer=self.answer, - answer_value="ThisEmailShouldNotBeUpdated@test.fr", - ) - self._add_answer_line( - question=self.question_function, - answer=self.answer, - answer_value="happiness office manager", - ) - self.answer._mark_done() - - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertTrue(len(partner) == 1) - self.assertTrue(partner.email == "jean@test.fr") - self.assertTrue(partner.function == "happiness office manager") - - def test_unicity_check_has_priority_over_update(self): - # In this test, we verify that if a field is set up with unicity_check - # it has priority over updating the existing record - self.name_survey_record_creation_field_values.unicity_check = True - - self.env["res.partner"].create({"name": "Jean"}) - - self.question_email = self._add_question( - page=None, - name="Email", - qtype="char_box", - survey_id=self.survey.id, - sequence=1, - ) - - self.survey_record_creation.write( - { - "update_existing_records": True, - "field_to_retrieve_existing_records": self.name_field.id, - } - ) - email_field = self.env["ir.model.fields"].search( - [("model", "=", "res.partner"), ("name", "=", "email")] - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.survey_record_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": email_field.id, - "value_origin": "question", - "question_id": self.question_email.id, - } - ) - - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, answer=self.answer, answer_value="Jean" - ) - self._add_answer_line( - question=self.question_email, - answer=self.answer, - answer_value="jean@test.fr", - ) - self.answer._mark_done() - - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertTrue(len(partner) == 1) - self.assertTrue(getattr(partner, "Email", None) is None) - - def test_required_fields_are_not_filled_up(self): - # In this test, we check the behavior when a required field (name) is missing - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - - with self.assertRaises(IntegrityError): - # TODO : propose a better user experience than IntegrityError when - # a mandatory field is missing - self.answer._mark_done() - - def test_ignore_if_mandatory_field_is_missing(self): - # In this test, we check the behavior of ignore_if_mandatory_field_is_missing - - self.survey_record_creation.write( - {"ignore_if_mandatory_field_is_missing": True} - ) - - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - - self.answer._mark_done() - - # No partner has been created, and no IntegrityError has been raised - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertEqual(len(partner), 0) - - def test_fill_up_partner_id_in_survey_input(self): - # In this test, we check that the field partner_id is filled up - # when we create a res.partner - - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, answer=self.answer, answer_value="Jean" - ) - - self.answer._mark_done() - - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertEqual(self.answer.partner_id, partner) - - def test_partner_id_in_survey_input_is_filled_up_by_first_contact_record_creation(self): - # In this test, we verify that when creating several contacts with the same survey, - # the 1st created contact is used to fill up survey_input.partner_id - self.second_question_name = self._add_question( - page=None, - name="Name of second person", - qtype="char_box", - survey_id=self.survey.id, - sequence=1, - ) - - self.second_contact_creation = self.env["survey.record.creation"].create( - { - "name": "Contact 2", - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - } - ) - self.env["survey.record.creation.field.values"].create( - { - "survey_record_creation_id": self.second_contact_creation.id, - "survey_id": self.survey.id, - "model_id": self.res_partner_model.id, - "field_id": self.name_field.id, - "value_origin": "question", - "question_id": self.second_question_name.id, - } - ) - - self.answer = self._add_answer( - survey=self.survey, partner=False, email="jean@test.fr" - ) - self._add_answer_line( - question=self.question_name, - answer=self.answer, - answer_value="Jean", - ) - self._add_answer_line( - question=self.second_question_name, - answer=self.answer, - answer_value="Jeanne", - ) - self.answer._mark_done() - - partner = self.env["res.partner"].search([("name", "=", "Jean")]) - self.assertEqual(self.answer.partner_id, partner) diff --git a/survey_record_generation/views/survey_generated_record_views.xml b/survey_record_generation/views/survey_generated_record_views.xml deleted file mode 100644 index 4196f8d..0000000 --- a/survey_record_generation/views/survey_generated_record_views.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - survey.generated.record.view.tree - survey.generated.record - - - - - - - - - - - survey.generated.record.view.search - survey.generated.record - - - - - - - - - - - - Generated records - survey.generated.record - tree - - {'search_default_active_input': True} - -

    - No generated records found -

    -
    -
    -
    -
    diff --git a/survey_record_generation/views/survey_question_views.xml b/survey_record_generation/views/survey_question_views.xml deleted file mode 100644 index 992f49a..0000000 --- a/survey_record_generation/views/survey_question_views.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - survey.question.view.form.inherit.record.generation - survey.question - - - - - - - - - - - - -