6 changed files with 135 additions and 51 deletions
-
11survey_select_input/__manifest__.py
-
53survey_select_input/models/survey_survey.py
-
25survey_select_input/models/survey_user_input.py
-
24survey_select_input/static/src/js/survey_state_selection_field.js
-
26survey_select_input/views/survey_survey.xml
-
47survey_select_input/views/survey_user_input.xml
@ -1,13 +1,24 @@ |
|||
from odoo import models, fields, api |
|||
|
|||
|
|||
SELECT_OPTIONS = [ |
|||
("normal", "Undefined"), |
|||
("done", "Selected"), |
|||
("blocked", "Not selected"), |
|||
] |
|||
|
|||
|
|||
class SurveyUserInput(models.Model): |
|||
_inherit = "survey.user_input" |
|||
|
|||
selected = fields.Boolean(string="Selected", default=False) |
|||
|
|||
@api.multi |
|||
def toggle_selected(self): |
|||
unselect = self.filtered("selected") |
|||
unselect.write({"selected": False}) |
|||
(self - unselect).write({"selected": True}) |
|||
answer_selection = fields.Boolean( |
|||
related="survey_id.answer_selection", |
|||
store=True, |
|||
) |
|||
select = fields.Selection( |
|||
SELECT_OPTIONS, |
|||
string="Selection", |
|||
copy=False, |
|||
default="normal", |
|||
required=True, |
|||
) |
@ -0,0 +1,24 @@ |
|||
/** @odoo-module **/ |
|||
|
|||
import { Dropdown } from "@web/core/dropdown/dropdown"; |
|||
import { DropdownItem } from "@web/core/dropdown/dropdown_item"; |
|||
import { registry } from "@web/core/registry"; |
|||
import { StateSelectionField } from '@web/views/fields/state_selection/state_selection_field'; |
|||
import { _lt } from "@web/core/l10n/translation"; |
|||
import { standardFieldProps } from "@web/views/fields/standard_field_props"; |
|||
|
|||
export class SurveyStateSelectionField extends StateSelectionField { |
|||
// export class StateSelectionField extends StateSelectionField {
|
|||
setup() { |
|||
super.setup(); |
|||
} |
|||
/** |
|||
* @override |
|||
*/ |
|||
get showLabel() { |
|||
return !this.props.hideLabel; |
|||
} |
|||
|
|||
} |
|||
|
|||
registry.category("fields").add("form.survey_state_selection", SurveyStateSelectionField); |
@ -1,20 +1,32 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
|
|||
<record id="survey_survey_form" model="ir.ui.view"> |
|||
<record id="survey_survey_view_form" model="ir.ui.view"> |
|||
<field name="name">survey_select_input survey.survey form</field> |
|||
<field name="model">survey.survey</field> |
|||
<field name="inherit_id" ref="survey.survey_form"/> |
|||
<field name="inherit_id" ref="survey.survey_survey_view_form" /> |
|||
<field name="priority">26</field> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//field[@name='tot_comp_survey']/.." position="after"> |
|||
<xpath expr="//div[@name='button_box']" position="inside"> |
|||
<button type="object" name="action_survey_user_input" |
|||
attrs="{'invisible': [('tot_selected_survey','=',0)]}" |
|||
context="{'search_default_selected':1}" |
|||
class="oe_stat_button text-success" icon="fa-pencil-square-o"> |
|||
<field name="tot_selected_survey" string="Selected" widget="statinfo"/> |
|||
attrs="{'invisible': [('answer_selection','=',False)]}" |
|||
context="{'search_default_selected':1}" |
|||
class="oe_stat_button text-success" icon="fa-check-circle"> |
|||
<field name="answer_selected_count" string="Selected" widget="statinfo" /> |
|||
</button> |
|||
<button type="object" name="action_survey_user_input" |
|||
attrs="{'invisible': [('answer_selection','=',False)]}" |
|||
context="{'search_default_selected':1}" |
|||
class="oe_stat_button text-success"> |
|||
<field name="answer_selected_ratio" string="Selected" widget="percentpie" /> |
|||
</button> |
|||
</xpath> |
|||
<group name="participants" position="attributes"> |
|||
<attribute name="class">o_label_nowrap</attribute> |
|||
</group> |
|||
<group name="participants" position="inside"> |
|||
<field name="answer_selection" /> |
|||
</group> |
|||
</field> |
|||
</record> |
|||
|
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue