Browse Source

[ADD] survey_input_dates module

12.0
Rémi FRANÇOIS 5 years ago
parent
commit
c8ac00dcf7
  1. 1
      survey_input_dates/__init__.py
  2. 32
      survey_input_dates/__manifest__.py
  3. 2
      survey_input_dates/models/__init__.py
  4. 14
      survey_input_dates/models/survey_survey.py
  5. 16
      survey_input_dates/models/survey_user_input.py
  6. 59
      survey_input_dates/views/survey_user_input.xml
  7. 2
      survey_select_input/views/survey_user_input.xml

1
survey_input_dates/__init__.py

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

32
survey_input_dates/__manifest__.py

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

2
survey_input_dates/models/__init__.py

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

14
survey_input_dates/models/survey_survey.py

@ -0,0 +1,14 @@
from odoo import models, fields, api
class SurveySurvey(models.Model):
_inherit = 'survey.survey'
@api.model
def next_page(self, user_input, page_id, go_back=False):
res = super(SurveySurvey, self).next_page(user_input, page_id, go_back)
if not user_input.date_start and page_id == 0:
user_input.write({
'date_start': fields.Datetime.now(),
})
return res

16
survey_input_dates/models/survey_user_input.py

@ -0,0 +1,16 @@
from odoo import models, fields, api
class SurveyUserInput(models.Model):
_inherit = 'survey.user_input'
date_start = fields.Datetime(string="Start date", readonly=True, help="This date is set when the user clicks on \"Start survey\" button for the first time.")
date_done = fields.Datetime(string="Date done", readonly=True, help="This date is set when the user input is set ton \"Done\" status.")
@api.multi
def write(self, vals):
if vals.get('state', False) == 'done':
vals.update({
'date_done': fields.Datetime.now(),
})
return super(SurveyUserInput, self).write(vals)

59
survey_input_dates/views/survey_user_input.xml

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="survey_user_input_form" model="ir.ui.view">
<field name="name">survey_select_input survey.user_input form</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.survey_user_input_form"/>
<field name="priority">26</field>
<field name="groups_id" eval="[(6,0,[ref('survey.group_survey_manager')])]"/>
<field name="arch" type="xml">
<field name="date_create" position="after">
<field name="date_start"/>
<field name="date_done"/>
</field>
</field>
</record>
<record id="survey_user_input_tree" model="ir.ui.view">
<field name="name">survey_select_input survey.user_input tree</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.survey_user_input_tree"/>
<field name="priority">26</field>
<field name="groups_id" eval="[(6,0,[ref('survey.group_survey_manager')])]"/>
<field name="arch" type="xml">
<field name="date_create" position="after">
<field name="date_start"/>
<field name="date_done"/>
</field>
</field>
</record>
<record id="view_survey_user_input_kanban" model="ir.ui.view">
<field name="name">survey_select_input survey.user_input kanban</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.view_survey_user_input_kanban"/>
<field name="priority">26</field>
<field name="groups_id" eval="[(6,0,[ref('survey.group_survey_manager')])]"/>
<field name="arch" type="xml">
<field name="date_create" position="after">
<field name="date_start"/>
<field name="date_done"/>
</field>
</field>
</record>
<record id="survey_user_input_search" model="ir.ui.view">
<field name="name">survey_select_input survey.user_input search</field>
<field name="model">survey.user_input</field>
<field name="inherit_id" ref="survey.survey_user_input_search"/>
<field name="priority">26</field>
<field name="groups_id" eval="[(6,0,[ref('survey.group_survey_manager')])]"/>
<field name="arch" type="xml">
<filter name="group_by_partner" position="after">
<filter string="Date done" name="by_date_done" domain="[]" context="{'group_by': 'date_done:week'}"/>
</filter>
</field>
</record>
</odoo>

2
survey_select_input/views/survey_user_input.xml

@ -43,7 +43,7 @@
</field>
<xpath expr="//div[hasclass('o_kanban_record_top')]" position="inside">
<span t-if="record.selected.raw_value" class="badge-pill badge-success">Selected</span>
</xpath>
</xpath>
</field>
</record>

Loading…
Cancel
Save