[IMP] survey_record_generation: link generated record to participations
This commit is contained in:
@@ -21,6 +21,8 @@ Allow to create record of any model when sending the form :
|
|||||||
"security/ir.model.access.csv",
|
"security/ir.model.access.csv",
|
||||||
"views/survey_survey_views.xml",
|
"views/survey_survey_views.xml",
|
||||||
"views/survey_question_views.xml",
|
"views/survey_question_views.xml",
|
||||||
|
"views/survey_user_input_views.xml",
|
||||||
|
"views/survey_generated_record_views.xml",
|
||||||
],
|
],
|
||||||
"installable": True,
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
@@ -3,4 +3,5 @@ from . import survey_question
|
|||||||
from . import survey_record_creation_field_values
|
from . import survey_record_creation_field_values
|
||||||
from . import survey_record_creation
|
from . import survey_record_creation
|
||||||
from . import survey_survey
|
from . import survey_survey
|
||||||
from . import survey_user_input
|
from . import survey_user_input
|
||||||
|
from . import survey_generated_record
|
15
survey_record_generation/models/survey_generated_record.py
Normal file
15
survey_record_generation/models/survey_generated_record.py
Normal file
@@ -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([])]
|
@@ -1,4 +1,5 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
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,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,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_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
|
|
@@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="survey_generated_record_view_tree" model="ir.ui.view">
|
||||||
|
<field name="name">survey.generated.record.view.tree</field>
|
||||||
|
<field name="model">survey.generated.record</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree>
|
||||||
|
<field name="survey_record_creation_name" />
|
||||||
|
<field name="survey_record_creation_id" />
|
||||||
|
<field name="user_input_id" />
|
||||||
|
<field name="created_record_id" />
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="survey_generated_record_view_form" model="ir.ui.view">
|
||||||
|
<field name="name">survey.generated.record.view.form</field>
|
||||||
|
<field name="model">survey.generated.record</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form>
|
||||||
|
<group>
|
||||||
|
<field name="survey_record_creation_name" />
|
||||||
|
<field name="survey_record_creation_id" />
|
||||||
|
<field name="user_input_id" />
|
||||||
|
<field name="created_record_id" />
|
||||||
|
</group>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="survey_generated_record_view_search" model="ir.ui.view">
|
||||||
|
<field name="name">survey.generated.record.view.search</field>
|
||||||
|
<field name="model">survey.generated.record</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search>
|
||||||
|
<field name="survey_record_creation_name" />
|
||||||
|
<field name="survey_record_creation_id" />
|
||||||
|
<field name="user_input_id" />
|
||||||
|
<field name="created_record_id" />
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<record id="survey_generated_record_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Generated records</field>
|
||||||
|
<field name="res_model">survey.generated.record</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
<field name="search_view_id" ref="survey_generated_record_view_search"/>
|
||||||
|
<field name="context">{'search_default_group_by_survey_record_creation_name': True}</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_empty_folder">
|
||||||
|
No generated records found
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
22
survey_record_generation/views/survey_user_input_views.xml
Normal file
22
survey_record_generation/views/survey_user_input_views.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<!-- USER INPUTS -->
|
||||||
|
|
||||||
|
<record id="survey_user_input_view_form_survey_record_generation" model="ir.ui.view">
|
||||||
|
<field name="name">survey.user_input.view.form.survey.record.generation</field>
|
||||||
|
<field name="model">survey.user_input</field>
|
||||||
|
<field name="inherit_id" ref="survey.survey_user_input_view_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//div[@name='button_box']" position="inside">
|
||||||
|
<button name="action_redirect_to_generated_records"
|
||||||
|
type="object"
|
||||||
|
class="oe_stat_button"
|
||||||
|
icon="fa-files-o">
|
||||||
|
<field string="Generated records" name="attempts_count" widget="statinfo"/>
|
||||||
|
</button>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
Reference in New Issue
Block a user