i have odoo17 enterprise project for managing questionaires and i wanna enhance it with detailed statistics and monitoring (solved/not solved/ answered/ which answer is choosen, and so on so on,../...), optimize by performance, if it needed create new model for better handling, do it logicly and approachto this task as your lifes task, follow best practices and make it happen in exterimely clean and clear way that cannot couse conflicts and logical errors, write code as google senior developer, we use odoo17 enterprise, i will provide you some of my related fiels and you in reponse will give me clean clear and working deploy ready, best practised, code, before responding double check everything, every bit, every dot, and give me final the best solution, no comment inside code, all updates with filenames and short descriptions, here we go:
questionaire.py:
from odoo import models, fields, api
from odoo.exceptions import ValidationError


class Questionnaire(models.Model):
    _name = 'questionnaire'
    _description = "So'rovnomalar"

    name = fields.Char(string='Name', translate=True)
    is_finished = fields.Boolean(default=False)
    user_id = fields.Many2one('res.partner', string='User')
    image = fields.Binary(string='Image')
    question_ids = fields.One2many('question', 'questionnaire_id', string='Questions')
    start_date = fields.Date(string='Start Date', default=fields.Date.today)
    end_date = fields.Date(string='End Date', default=fields.Date.today)
    
    location_type = fields.Selection([
        ('all', 'All'),
        ('region', 'Region'),
        ('district', 'District'),
        ('mahalla', 'Mahalla')
    ], string='Location Type', required=True, default='all')

    to_all = fields.Boolean(string='Is Republic')
    region_id = fields.Many2many('region', string="Region", required=False)
    to_region = fields.Boolean()
    district_id = fields.Many2many('district', string="District", required=False)
    to_district = fields.Boolean()
    mahalla_id = fields.Many2many('mahalla', string="Mahalla", required=False)
    to_mahalla = fields.Boolean()

    @api.onchange('to_all')
    def _onchange_to_all(self):
        if self.to_all:
            domain = []
            mahallas = self.env['mahalla'].search(domain)
            self.mahalla_id = [(6, 0, mahallas.ids)]
            self.region_id = False
            self.district_id = False
        else:
            self.mahalla_id = False

    @api.onchange('to_region', 'region_id')
    def _onchange_region_selection(self):
        if self.to_region and self.region_id:
            districts = self.env['district'].search([('region_id', 'in', self.region_id.ids)])
            mahallas = self.env['mahalla'].search([('district_id', 'in', districts.ids)])
            self.mahalla_id = [(6, 0, mahallas.ids)]
            self.district_id = False
        elif not self.to_region:
            if not self.to_all and not self.to_district:
                self.mahalla_id = False

    @api.onchange('to_district', 'district_id')
    def _onchange_district_selection(self):
        if self.to_district and self.district_id:
            mahallas = self.env['mahalla'].search([('district_id', 'in', self.district_id.ids)])
            self.mahalla_id = [(6, 0, mahallas.ids)]
        elif not self.to_district:
            if not self.to_all and not self.to_region:
                self.mahalla_id = False

    @api.onchange('location_type')
    def on_change_location_type(self):
        if self.location_type == 'all':
            self.to_all = True
            self.to_region = True
            self.to_district = True
            self.to_mahalla = True
            self._onchange_to_all()
        elif self.location_type == 'region':
            self.to_all = True
            self.to_region = False
            self.to_district = True
            self.to_mahalla = True
            self._onchange_region_selection()
        elif self.location_type == 'district':
            self.to_all = False
            self.to_region = False
            self.to_district = False
            self.to_mahalla = True
            self._onchange_district_selection()
        elif self.location_type == 'mahalla':
            self.to_all = False
            self.to_region = False
            self.to_district = False
            self.to_mahalla = False

    @api.constrains('location_type', 'region_id', 'district_id', 'mahalla_id')
    def _check_location_requirements(self):
        for record in self:
            if record.location_type == 'region' and not record.region_id:
                raise ValidationError("Specify the region for the announcement.")
            elif record.location_type == 'district':
                if not record.region_id:
                    raise ValidationError("Specify the region for the district announcement.")
                if not record.district_id:
                    raise ValidationError("Specify the district for the announcement.")
            elif record.location_type == 'mahalla':
                if not record.region_id:
                    raise ValidationError("Specify the region for the mahalla announcement.")
                if not record.district_id:
                    raise ValidationError("Specify the district for the mahalla announcement.")
                if not record.mahalla_id:
                    raise ValidationError("Specify the mahalla for the announcement.")
    
    @api.constrains('start_date', 'end_date')
    def _check_date_range(self):
        for record in self:
            if record.start_date > record.end_date:
                raise ValidationError("Start date cannot be higher than end date.")
question.py:
from odoo import models, fields


class Question(models.Model):
    _name = 'question'
    _description = 'Savol'

    name = fields.Char(string='Nomi', translate=True)
    description = fields.Text(string='Question', translate=True)
    image = fields.Binary(string='Image', required=True)
    type = fields.Selection(
        [
            ('text', 'Text'),
            ('multiple_choice', 'Multiple Choice'),
            ('single_choice', 'Single Choice'),
            ('numeric', 'Numeric'),
            ('date', 'Date'),
        ],
        string='Savol Turi',
        required=True,
        help="Select the type of the question"
    )
    questionnaire_id = fields.Many2one('questionnaire', string="Questionnaire")
    option_ids = fields.One2many('option', 'question_id', string='Tanlovlar')

question.xml:
<odoo>
    <!-- Tree View for Questions -->
    <record id="view_question_tree" model="ir.ui.view">
        <field name="name">question.tree</field>
        <field name="model">question</field>
        <field name="arch" type="xml">
            <tree string="Questions">
                <field name="name"/>
                <field name="type"/>
                <field name="questionnaire_id"/>
            </tree>
        </field>
    </record>

    <!-- Form View for Questions -->
    <record id="view_question_form" model="ir.ui.view">
        <field name="name">question.form</field>
        <field name="model">question</field>
        <field name="arch" type="xml">
            <form string="Question">
                <sheet>
                    <group>
                        <field name="name"/>
                        <field name="description"/>
                        <field name="image" widget="image"/>
                        <field name="type"/>
                        <field name="questionnaire_id"/>
                    </group>
                    <group string="Options">
                        <field name="option_ids">
                            <tree string="Options">
                                <field name="text"/>
                            </tree>
                            <form string="Option">
                                <sheet>
                                    <field name="text"/>
                                </sheet>
                            </form>
                        </field>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <!-- Action for Question Views -->
    <record id="action_question" model="ir.actions.act_window">
        <field name="name">Questions</field>
        <field name="res_model">question</field>
        <field name="view_mode">tree,form</field>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Create your first Question
            </p>
        </field>
    </record>

    <!-- Menu Items -->

    <menuitem id="menu_questionnaire_questions"
              name="Questions"
              parent="mahallam.menu_questionnaire_root"
              action="action_question"
              sequence="10"/>
</odoo>
questionaire.xml:
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <!-- Tree and Form Views for Questionnaire -->
    <record id="view_questionnaire_tree" model="ir.ui.view">
        <field name="name">questionnaire.tree</field>
        <field name="model">questionnaire</field>
        <field name="arch" type="xml">
            <tree string="So'rovnomalar">
                <field name="name"/>
                <field name="user_id"/>
                <field name="is_finished"/>
            </tree>
        </field>
    </record>

    <record id="view_questionnaire_form" model="ir.ui.view">
        <field name="name">questionnaire.form</field>
        <field name="model">questionnaire</field>
        <field name="arch" type="xml">
            <form string="So'rovnoma">
                <sheet>
                    <group>
                        <field name="name"/>
                        <field name="image" widget="image"/>
                    </group>
                    <group>
                        <field name="start_date"/>
                        <field name="end_date"/>
                    </group>

                    <group>
                        <field name="location_type"/>
                        <field name="region_id" invisible="to_region"/>
                        <field name="to_region" invisible="1"/>
                        <field
                                name="district_id"
                                invisible="to_district"
                                domain="[('region_id', '=', region_id)]"

                        />
                        <field name="to_district" invisible="1"/>
                        <field
                                name="mahalla_id"
                                invisible="to_mahalla"
                                domain="[('district_id', '=', district_id)]"

                        />
                        <field name="to_mahalla" invisible="1"/>
                    </group>
                    <notebook>
                        <page string="Savollar">
                            <!-- One2many Field to Show Questions in Tree View -->
                            <field name="question_ids">
                                <tree string="Savollar" editable="bottom">
                                    <field name="name"/>
                                    <field name="type"/>
                                </tree>
                            </field>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <!-- Form and Tree Views for Question (Inline in Questionnaire) -->
    <record id="view_question_form" model="ir.ui.view">
        <field name="name">question.form</field>
        <field name="model">question</field>
        <field name="arch" type="xml">
            <form string="Savol">
                <sheet>
                    <group>
                        <field name="name"/>
                        <field name="description"/>
                        <field name="type"/>
                    </group>
                    <group string="Tanlovlar">
                        <!-- One2many Field to Show Options in Tree View -->
                        <field name="option_ids">
                            <tree string="Tanlovlar" editable="bottom">
                                <field name="text"/>
                            </tree>
                        </field>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <!-- Tree View for Options (Inline in Question) -->
    <record id="view_option_tree" model="ir.ui.view">
        <field name="name">option.tree</field>
        <field name="model">option</field>
        <field name="arch" type="xml">
            <tree string="Tanlovlar">
                <field name="text"/>
            </tree>
        </field>
    </record>

    <!-- Action for Questionnaire -->
    <record id="action_questionnaire" model="ir.actions.act_window">
        <field name="name">So'rovnomalar</field>
        <field name="res_model">questionnaire</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" ref="view_questionnaire_tree"/>
    </record>

    <!-- Menu Item for Questionnaire -->
    <menuitem id="menu_questionnaire_root" name="So'rovnomalar" sequence="10" web_icon="mahallam,static/src/img/questionnaire.png"/>
    <menuitem id="menu_questionnaire" name="So'rovnomalar" parent="menu_questionnaire_root" action="action_questionnaire" sequence="10"/>
</odoo>


double check before responding, think twice and double check every piece of code and give me final result