Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REL] Migration: survey_append_filters to 11.0 #10

Merged
merged 1 commit into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions survey_append_filters/README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
.. |company| replace:: ADHOC SA

.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png
:alt: ADHOC SA
:target: https://www.adhoc.com.ar

.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png

.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

=====================
Expand All @@ -13,32 +21,31 @@ Installation

To install this module, you need to:

#. Only need to install the module

Configuration
=============

To configure this module, you need to:

#. In the survey page "options" select "Append filters in finished surveys"

Usage
=====

To use this module, you need to:

#. Go to survey result an select the filters in the rows.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.adhoc.com.ar/

.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "9.0" for example

:target: http://runbot.adhoc.com.ar/

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/ingadhoc/{project_repo}/issues>`_. In case of trouble, please
<https://github.com/ingadhoc/survey/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Expand All @@ -48,19 +55,16 @@ Credits
Images
------

* ADHOC SA: `Icon <http://fotos.subefotos.com/83fed853c1e15a8023b86b2b22d6145bo.png>`_.
* |company| |icon|

Contributors
------------


Maintainer
----------

.. image:: http://fotos.subefotos.com/83fed853c1e15a8023b86b2b22d6145bo.png
:alt: Odoo Community Association
:target: https://www.adhoc.com.ar
|company_logo|

This module is maintained by the ADHOC SA.
This module is maintained by the |company|.

To contribute to this module, please visit https://www.adhoc.com.ar.
2 changes: 1 addition & 1 deletion survey_append_filters/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import survey
from . import models
6 changes: 3 additions & 3 deletions survey_append_filters/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Survey Append Filters',
'version': '9.0.1.0.0',
'version': '11.0.1.0.0',
'category': 'Warehouse Management',
'sequence': 14,
'summary': '',
Expand All @@ -32,11 +32,11 @@
'survey'
],
'data': [
'survey_view.xml',
'views/survey_survey_views.xml',
],
'demo': [
],
'installable': False,
'installable': True,
'auto_install': False,
'application': False,
}
5 changes: 5 additions & 0 deletions survey_append_filters/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import survey_survey
21 changes: 11 additions & 10 deletions survey_append_filters/survey.py → ...ey_append_filters/models/survey_survey.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@
from odoo import fields, models, api


class survey_survey(models.Model):
class SurveySurvey(models.Model):
_inherit = 'survey.survey'

append_filter = fields.Boolean(
string='Append filters in finished surveys',
default=True)
default=True,
)

@api.model
def filter_input_ids(self, survey, filters, finished=False):
@api.multi
def filter_input_ids(self, filters, finished=False):
'''If user applies any filters, then this function returns list of
filtered user_input_id and label's strings for display data in web.
:param filters: list of dictionary (having: row_id, ansewr_id)
:param finished: True for completely filled survey,Falser otherwise.
:returns list of filtered user_input_ids.
'''
if survey.append_filter:
if self.append_filter:
input_lines = self.env['survey.user_input_line']
filtered_inputs = input_lines.user_input_id
if filters:
input_lines = self.env['survey.user_input_line']
filtered_inputs = input_lines.user_input_id
for filter in filters:
row_id, answer_id = filter['row_id'], filter['answer_id']
if row_id == 0:
Expand All @@ -42,11 +43,11 @@ def filter_input_ids(self, survey, filters, finished=False):
if finished:
if not filtered_inputs:
user_inputs = self.env['survey.user_input'].search([
('survey_id', '=', survey.id)])
('survey_id', '=', self.id)])
else:
user_inputs = filtered_inputs
return user_inputs.filtered(lambda x: x.state == 'done').ids
return filtered_inputs.ids
else:
return super(survey_survey, self).filter_input_ids(
survey, filters, finished)
return super(SurveySurvey, self).filter_input_ids(
filters, finished)
15 changes: 0 additions & 15 deletions survey_append_filters/survey_view.xml

This file was deleted.

13 changes: 13 additions & 0 deletions survey_append_filters/views/survey_survey_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="ir.ui.view" id="survey_form">
<field name="name">Form view for survey</field>
<field name="model">survey.survey</field>
<field name="inherit_id" ref="survey.survey_form"/>
<field name="arch" type="xml">
<field name="quizz_mode" position="after">
<field name="append_filter"/>
</field>
</field>
</record>
</odoo>