# -*- coding: utf-8 -*- from odoo import fields, models, tools class HelpdeskTicketReport(models.Model): """ Extend helpdesk ticket report analysis to ensure proper 0-5 scale handling Requirements: 4.1, 4.2, 4.4, 4.5 - Requirement 4.1: Display ratings using the 0-5 scale in reports - Requirement 4.2: Calculate average ratings based on the 0-5 scale - Requirement 4.4: Use 0-5 scale for filtering and grouping - Requirement 4.5: Include 0-5 scale values in exports """ _inherit = 'helpdesk.ticket.report.analysis' # Override rating fields to ensure they display correctly with 0-5 scale rating_last_value = fields.Float( "Rating (1-5)", aggregator="avg", readonly=True, help="Last rating value on a 0-5 star scale" ) rating_avg = fields.Float( 'Average Rating (0-5)', readonly=True, aggregator='avg', help="Average rating value on a 0-5 star scale" ) def _select(self): """ Override the select clause to ensure rating calculations use 0-5 scale The parent class already calculates AVG(rt.rating) which will work correctly with our 0-5 scale ratings. We just need to ensure the field descriptions are clear about the scale being used. """ # Call parent to get the base select return super()._select() def _from(self): """ Override the from clause if needed to ensure proper rating joins The parent class already joins with rating_rating table correctly. Our extended rating model with 0-5 scale will be used automatically. """ return super()._from() def _group_by(self): """ Override the group by clause if needed The parent class grouping is already correct for our purposes. """ return super()._group_by()