Browse Source

[ADD] survey_template module

12.0
Rémi FRANÇOIS 5 years ago
parent
commit
097c10e662
  1. 1
      survey_template/__init__.py
  2. 32
      survey_template/__manifest__.py
  3. 1
      survey_template/models/__init__.py
  4. 17
      survey_template/models/survey_survey.py
  5. 173
      survey_template/views/survey_survey.xml

1
survey_template/__init__.py

@ -0,0 +1 @@
from . import models

32
survey_template/__manifest__.py

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Survey template',
'version': '0.1.0',
'summary': """
This module adds templating feature on surveys and their own menu item.
""",
'description': """ """,
'author': 'Sudokeys',
'website': 'http://www.sudokeys.com',
'license': 'AGPL-3',
'category': 'Marketing',
'depends': [
'survey',
],
'data': [
'views/survey_survey.xml',
],
'demo': [],
'auto_install': False,
'external_dependencies': [],
'application': False,
'css': [],
'images': [],
'js': [],
'installable': True,
'maintainer': 'Sudokeys',
'pre_init_hook': '',
'post_init_hook': '',
'uninstall_hook': '',
}

1
survey_template/models/__init__.py

@ -0,0 +1 @@
from . import survey_survey

17
survey_template/models/survey_survey.py

@ -0,0 +1,17 @@
from odoo import models, fields, api
from odoo.exceptions import UserError
class SurveySurvey(models.Model):
_inherit = 'survey.survey'
is_template = fields.Boolean(string="Est un modèle", default=False, copy=False)
# ACTIONS
@api.multi
def action_send_survey(self):
self.ensure_one()
if self.is_template:
raise UserError("Vous ne pouvez pas partager un modèle de sondage, créez un nouveau sondage à partir de ce modèle et vous pourrez le partager.")
return super(SurveySurvey, self).action_send_survey()

173
survey_template/views/survey_survey.xml

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- survey views and actions -->
<record id="survey_survey_form" model="ir.ui.view">
<field name="name">survey_template survey.survey form</field>
<field name="model">survey.survey</field>
<field name="inherit_id" ref="survey.survey_form"/>
<field name="priority">20</field>
<field name="arch" type="xml">
<field name="is_closed" position="after">
<field name="is_template" invisible="1"/>
</field>
<!-- Hide send button and stage on templates -->
<button name="action_send_survey" position="attributes">
<attribute name="attrs">{'invisible': [('is_template', '=', True)]}</attribute>
</button>
<field name="stage_id" position="attributes">
<attribute name="attrs">{'invisible': [('is_template', '=', True)]}</attribute>
</field>
<div name="button_box" position="after">
<h2 class="badge-pill badge-warning float-right" attrs="{'invisible': [('is_template', '=', False)]}">Ce sondage est un modèle</h2>
</div>
</field>
</record>
<record id="survey_survey_tree" model="ir.ui.view">
<field name="name">survey_template survey.survey tree</field>
<field name="model">survey.survey</field>
<field name="inherit_id" ref="survey.survey_tree"/>
<field name="priority">20</field>
<field name="arch" type="xml">
<tree position="attributes">
<attribute name="decoration-warning">is_template</attribute>
</tree>
<tree position="inside">
<field name="is_template" invisible="1"/>
</tree>
</field>
</record>
<record id="survey_survey_kanban" model="ir.ui.view">
<field name="name">survey_template survey.survey kanban</field>
<field name="model">survey.survey</field>
<field name="inherit_id" ref="survey.survey_kanban"/>
<field name="priority">20</field>
<field name="arch" type="xml">
<xpath expr="//div[hasclass('oe_kanban_bottom_left')]" position="inside">
<div t-if="record.is_template.raw_value" class="badge-pill badge-warning">Modèle</div>
</xpath>
</field>
</record>
<record model="ir.actions.act_window" id="survey.action_survey_form">
<field name="domain">[('is_template','=',False)]</field>
</record>
<!-- survey template views and actions -->
<record id="survey_survey_template_tree" model="ir.ui.view">
<field name="name">survey_template survey.survey template tree</field>
<field name="model">survey.survey</field>
<field name="priority">20</field>
<field name="arch" type="xml">
<tree decoration-warning="is_template">
<field name="active" invisible="1"/>
<field name="is_template" invisible="1"/>
<field name="title"/>
</tree>
</field>
</record>
<record id="survey_survey_template_kanban" model="ir.ui.view">
<field name="name">survey_template survey.survey template kanban</field>
<field name="model">survey.survey</field>
<field name="priority">20</field>
<field name="arch" type="xml">
<kanban>
<field name="designed"/>
<field name="title"/>
<field name="is_template"/>
<field name="color"/>
<templates>
<div t-name="kanban-box" t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_global_click">
<div class="o_dropdown_kanban dropdown" t-if="widget.editable">
<a role="button" class="dropdown-toggle o-no-caret btn" data-toggle="dropdown" data-display="static" href="#" aria-label="Dropdown menu" title="Dropdown menu">
<span class="fa fa-ellipsis-v"/>
</a>
<div class="dropdown-menu" role="menu">
<a role="menuitem" type="edit" class="dropdown-item">Modifieer le modèle</a>
<a t-if="widget.deletable" role="menuitem" type="delete" class="dropdown-item">Supprimer ce modèle</a>
<div role="separator" class="dropdown-divider"/>
<div role="separator" class="dropdown-item-text">Color</div>
<ul class="oe_kanban_colorpicker" data-field="color"/>
</div>
</div>
<div class="o_kanban_record_top">
<h4 class="o_kanban_record_title mb4 d-block"><field name="title"/></h4>
</div>
<div class="o_kanban_record_bottom">
<div class="oe_kanban_bottom_left">
<div t-if="record.is_template.raw_value" class="badge-pill badge-warning">Modèle</div>
</div>
<div class="oe_kanban_bottom_right">
<field name="activity_ids" widget="kanban_activity"/>
</div>
</div>
</div>
</templates>
</kanban>
</field>
</record>
<record id="survey_survey_template_act_window" model="ir.actions.act_window">
<field name="name">Modèles de sondages</field>
<field name="res_model">survey.survey</field>
<field name="view_type">form</field>
<field name="view_mode">kanban,tree,form</field>
<field name="domain">[('is_template','=',True)]</field>
<field name="context">{'default_is_template':True}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Créez un nouveau modèle de sondage.
</p>
</field>
</record>
<record id="survey_survey_template_act_window_view_kanban" model="ir.actions.act_window.view">
<field name="sequence" eval="1"/>
<field name="view_mode">kanban</field>
<field name="view_id" ref="survey_survey_template_kanban"/>
<field name="act_window_id" ref="survey_survey_template_act_window"/>
</record>
<record id="survey_survey_template_act_window_view_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="2"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="survey_survey_template_tree"/>
<field name="act_window_id" ref="survey_survey_template_act_window"/>
</record>
<!-- survey config menus rearrange -->
<record id="survey.menu_surveys_configuration" model="ir.ui.menu">
<field name="groups_id" eval="[(6,0,[ref('survey.group_survey_manager')])]"/>
</record>
<menuitem
id="survey_survey_template_menu"
name="Modèles"
action="survey_survey_template_act_window"
parent="survey.menu_surveys_configuration"
sequence="0"
groups="survey.group_survey_manager"/>
<record id="survey.menu_survey_page_form1" model="ir.ui.menu">
<field name="groups_id" eval="[(4, ref('base.group_no_one'))]"/>
</record>
<record id="survey.menu_survey_question_form1" model="ir.ui.menu">
<field name="groups_id" eval="[(4, ref('base.group_no_one'))]"/>
</record>
<record id="survey.menu_survey_label_form1" model="ir.ui.menu">
<field name="groups_id" eval="[(4, ref('base.group_no_one'))]"/>
</record>
<record id="survey.menu_survey_response_line_form" model="ir.ui.menu">
<field name="groups_id" eval="[(4, ref('base.group_no_one'))]"/>
</record>
</odoo>
Loading…
Cancel
Save