Use integer without grouping for year reporting

issue10731
review355501002
This commit is contained in:
Cédric Krier
2021-09-26 23:04:22 +02:00
parent 8db518f263
commit c762768ebe
3 changed files with 6 additions and 10 deletions
+4 -8
View File
@@ -692,7 +692,7 @@ class SaleOpportunityEmployeeContext(ModelView):
class SaleOpportunityMonthly(SaleOpportunityReportMixin, ModelSQL, ModelView):
'Sale Opportunity per Month'
__name__ = 'sale.opportunity_monthly'
year = fields.Char('Year')
year = fields.Integer("Year")
month = fields.Many2One('ir.calendar.month', "Month")
year_month = fields.Function(fields.Char('Year-Month'),
'get_year_month')
@@ -714,9 +714,7 @@ class SaleOpportunityMonthly(SaleOpportunityReportMixin, ModelSQL, ModelView):
query = super(SaleOpportunityMonthly, cls).table_query()
opportunity, = query.from_
type_id = cls.id.sql_type().base
type_year = cls.year.sql_type().base
year_column = Extract('YEAR', opportunity.start_date
).cast(type_year).as_('year')
year_column = Extract('YEAR', opportunity.start_date).as_('year')
month_index = Extract('MONTH', opportunity.start_date)
query.from_ = opportunity.join(
month, condition=month_index == month.index)
@@ -734,7 +732,7 @@ class SaleOpportunityEmployeeMonthly(
SaleOpportunityReportMixin, ModelSQL, ModelView):
'Sale Opportunity per Employee per Month'
__name__ = 'sale.opportunity_employee_monthly'
year = fields.Char('Year')
year = fields.Integer("Year")
month = fields.Many2One('ir.calendar.month', "Month")
employee = fields.Many2One('company.employee', 'Employee')
@@ -753,9 +751,7 @@ class SaleOpportunityEmployeeMonthly(
query = super(SaleOpportunityEmployeeMonthly, cls).table_query()
opportunity, = query.from_
type_id = cls.id.sql_type().base
type_year = cls.year.sql_type().base
year_column = Extract('YEAR', opportunity.start_date
).cast(type_year).as_('year')
year_column = Extract('YEAR', opportunity.start_date).as_('year')
month_index = Extract('MONTH', opportunity.start_date)
query.from_ = opportunity.join(
month, condition=month_index == month.index)
+1 -1
View File
@@ -2,7 +2,7 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="year"/>
<field name="year" grouping="0"/>
<field name="month" widget="selection"/>
<field name="employee" expand="1"/>
<field name="number"/>
+1 -1
View File
@@ -2,7 +2,7 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="year"/>
<field name="year" grouping="0"/>
<field name="month" widget="selection"/>
<field name="number"/>
<field name="converted"/>