From 73d9f5c62be690b4b34f846b53ca634169be7480 Mon Sep 17 00:00:00 2001 From: clementthomas Date: Fri, 28 Feb 2025 14:03:27 +0100 Subject: [PATCH] [IMP] survey_record_generation: link generated record to participations --- survey_record_generation/__manifest__.py | 2 + survey_record_generation/models/__init__.py | 3 +- .../models/survey_generated_record.py | 15 +++++ .../security/ir.model.access.csv | 3 +- .../views/survey_generated_record_views.xml | 59 +++++++++++++++++++ .../views/survey_user_input_views.xml | 22 +++++++ 6 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 survey_record_generation/models/survey_generated_record.py create mode 100644 survey_record_generation/views/survey_generated_record_views.xml create mode 100644 survey_record_generation/views/survey_user_input_views.xml diff --git a/survey_record_generation/__manifest__.py b/survey_record_generation/__manifest__.py index e5ecaaf..05266f8 100644 --- a/survey_record_generation/__manifest__.py +++ b/survey_record_generation/__manifest__.py @@ -21,6 +21,8 @@ Allow to create record of any model when sending the form : "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/models/__init__.py b/survey_record_generation/models/__init__.py index 5f81d0c..e8d744a 100644 --- a/survey_record_generation/models/__init__.py +++ b/survey_record_generation/models/__init__.py @@ -3,4 +3,5 @@ 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 \ No newline at end of file +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 new file mode 100644 index 0000000..d199657 --- /dev/null +++ b/survey_record_generation/models/survey_generated_record.py @@ -0,0 +1,15 @@ +# 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/security/ir.model.access.csv b/survey_record_generation/security/ir.model.access.csv index 09d5d90..8bd10dc 100644 --- a/survey_record_generation/security/ir.model.access.csv +++ b/survey_record_generation/security/ir.model.access.csv @@ -1,4 +1,5 @@ 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 \ No newline at end of file +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/views/survey_generated_record_views.xml b/survey_record_generation/views/survey_generated_record_views.xml new file mode 100644 index 0000000..2fcb513 --- /dev/null +++ b/survey_record_generation/views/survey_generated_record_views.xml @@ -0,0 +1,59 @@ + + + + + survey.generated.record.view.tree + survey.generated.record + + + + + + + + + + + + survey.generated.record.view.form + survey.generated.record + +
+ + + + + + +
+
+
+ + + survey.generated.record.view.search + survey.generated.record + + + + + + + + + + + + + Generated records + survey.generated.record + tree,form + + {'search_default_group_by_survey_record_creation_name': True} + +

+ No generated records found +

+
+
+
+
diff --git a/survey_record_generation/views/survey_user_input_views.xml b/survey_record_generation/views/survey_user_input_views.xml new file mode 100644 index 0000000..8d0bb95 --- /dev/null +++ b/survey_record_generation/views/survey_user_input_views.xml @@ -0,0 +1,22 @@ + + + + + + + survey.user_input.view.form.survey.record.generation + survey.user_input + + + + + + + + +