From 42ef9f8a3b89f89606a11cf29c7e433726556997 Mon Sep 17 00:00:00 2001 From: benjamin <benjamin@le-filament.com> Date: Thu, 7 Nov 2024 15:19:14 +0100 Subject: [PATCH] [REF] move cgscop_survey into training_survey --- i18n/fr.po | 24 ++++++++++++++++++++++++ models/survey.py | 5 +++++ models/survey_user_input.py | 10 ++++++++++ security/survey_security.xml | 14 ++++++++++++++ views/survey.xml | 4 ++-- views/survey_user_input.xml | 6 ++++++ 6 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 i18n/fr.po create mode 100644 security/survey_security.xml diff --git a/i18n/fr.po b/i18n/fr.po new file mode 100644 index 0000000..6863df4 --- /dev/null +++ b/i18n/fr.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * survey +# +# Translators: +# Rémi CAZENAVE, 2022 +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-04-26 13:31+0000\n" +"PO-Revision-Date: 2022-09-22 05:55+0000\n" +"Language-Team: French \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fr\n" +"Plural-Forms: nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n" + +#. module: survey +#: model_terms:ir.ui.view,arch_db:survey.survey_fill_form_start +msgid "Start Survey" +msgstr "Démarrer le questionnaire" diff --git a/models/survey.py b/models/survey.py index 60c6fe8..5588317 100644 --- a/models/survey.py +++ b/models/survey.py @@ -56,6 +56,11 @@ class Survey(models.Model): default=False, help="Afficher un bouton pour pouvoir refaire le sondage une fois terminé", ) + company_id = fields.Many2one( + comodel_name="res.company", + string="Société", + default=lambda self: self.env.company, + ) # ------------------------------------------------------ # Constrains diff --git a/models/survey_user_input.py b/models/survey_user_input.py index 59b6f1e..b6179d9 100644 --- a/models/survey_user_input.py +++ b/models/survey_user_input.py @@ -7,6 +7,11 @@ from odoo import Command, fields, models class SurveyUserInput(models.Model): _inherit = "survey.user_input" + # Inherit parent + state = fields.Selection(tracking=1) + # New fields + answer_url = fields.Char(string="URL de la réponse", compute="_compute_answer_url") + comment = fields.Text("Notes") firstname = fields.Char("Prénom") company = fields.Char("Structure") is_duplicate_answer = fields.Boolean(default=False) @@ -116,6 +121,11 @@ class SurveyUserInput(models.Model): # ------------------------------------------------------ # Compute # ------------------------------------------------------ + def _compute_answer_url(self): + for answer in self: + answer.answer_url = url_join( + answer.survey_id.get_base_url(), answer.get_start_url() + ) # ------------------------------------------------------ # Actions diff --git a/security/survey_security.xml b/security/survey_security.xml new file mode 100644 index 0000000..641a52a --- /dev/null +++ b/security/survey_security.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8" ?> +<odoo noupdate="0"> + <record id="survey_server_rule" model="ir.rule"> + <field name="name">survey multi-company</field> + <field name="model_id" ref="survey.model_survey_survey" /> + <field name="perm_read" eval="True"/> + <field name="perm_write" eval="False"/> + <field name="perm_create" eval="False"/> + <field name="perm_unlink" eval="False"/> + <field + name="domain_force" + >[('company_id', 'in', company_ids + [False])]</field> + </record> +</odoo> diff --git a/views/survey.xml b/views/survey.xml index 198e3e2..de9a778 100644 --- a/views/survey.xml +++ b/views/survey.xml @@ -143,13 +143,13 @@ <!-- Actions --> <!-- Inherit parent action for domain --> <record model="ir.actions.act_window" id="survey.action_survey_form"> - <field name="domain">[("survey_type", "=", False)]</field> + <field name="domain">[("survey_type", "=", False), ("company_id", "in", allowed_company_ids)]</field> </record> <!-- New Actions --> <record model="ir.actions.act_window" id="action_training_survey"> <field name="name">Questionnaires formation</field> <field name="res_model">survey.survey</field> - <field name="domain">[("survey_type", "=", "training")]</field> + <field name="domain">[("survey_type", "=", "training"), ("company_id", "in", allowed_company_ids)]</field> <field name="view_mode">kanban,tree,form,activity</field> <field name="context">{"default_survey_type": "training"}</field> <field name="search_view_id" ref="training_survey_search" /> diff --git a/views/survey_user_input.xml b/views/survey_user_input.xml index 79b5df7..3140619 100644 --- a/views/survey_user_input.xml +++ b/views/survey_user_input.xml @@ -8,6 +8,12 @@ <field name="priority">60</field> <field name="arch" type="xml"> <xpath expr="//sheet/group/group" position="inside"> + <field name="comment" /> + <field + name="answer_url" + attrs="{'invisible': [('state', '=', 'done')]}" + widget="CopyClipboardChar" + /> <field name="is_resent" invisible="1" /> <div colspan="2"> <button -- GitLab