-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] web: Correctly aggregate values in exported parent groups
[FIX] web: Correctly aggregate values in exported parent groups -------------------- When exporting a grouped list view with some nested groups, the aggregate value of parent groups are not correct. It always sums aggregated values of children whether the group operator is 'sum' or not (could be 'max', 'avg', ...). This behavior is wrong and can even lead to a crash if the aggregated field is a date field (e.g. with group_operator='max'). (Try two sum two dates...) To avoid the crash a quick fix was merged 85cf47f just before OXP. This fix limited the support of aggregates to only int and float fields. This commit remove this limitation. This commit correctly implements the aggregation for parent group for all field types and all group_operator. This commit also improves the export feature tests. [FIX] base export: Manage False in groupby title -------------------- Before this commit, when we export a list with a groupby on boolean, the groupby title 'False' is replaced by 'Undefined' in xls document. After this commit, with an export and groupby on a boolean, we will have correct title: True and False. -- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr closes odoo#38373 Signed-off-by: Yannick Tivisse (yti) <[email protected]>
- Loading branch information
Showing
9 changed files
with
496 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
{ | ||
'name': 'test xlsx export', | ||
'version': '0.1', | ||
'category': 'Tests', | ||
'description': """A module to test xlsx export.""", | ||
'depends': ['web', 'test_mail'], | ||
'data': ['ir.model.access.csv'], | ||
'installable': True, | ||
'auto_install': False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" | ||
access_export_group_operator,access_export_group_operator,model_export_group_operator,,1,1,1,1 | ||
access_export_group_operator_one2many,access_export_group_operator_one2many,model_export_group_operator_one2many,,1,1,1,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo import api, fields, models | ||
|
||
class NewModel(models.Model): | ||
_name = 'export.integer' | ||
_description = 'Export: Integer' | ||
|
||
value = fields.Integer(default=4) | ||
|
||
def name_get(self): | ||
return [(record.id, "%s:%s" % (self._name, record.value)) for record in self] | ||
|
||
class GroupOperator(models.Model): | ||
_name = 'export.group_operator' | ||
_description = 'Export Group Operator' | ||
|
||
int_sum = fields.Integer(group_operator='sum') | ||
int_max = fields.Integer(group_operator='max') | ||
float_min = fields.Float(group_operator='min') | ||
float_avg = fields.Float(group_operator='avg') | ||
date_max = fields.Date(group_operator='max') | ||
bool_and = fields.Boolean(group_operator='bool_and') | ||
bool_or = fields.Boolean(group_operator='bool_or') | ||
many2one = fields.Many2one('export.integer') | ||
one2many = fields.One2many('export.group_operator.one2many', 'parent_id') | ||
|
||
class GroupOperatorO2M(models.Model): | ||
_name = 'export.group_operator.one2many' | ||
_description = 'Export Group Operator One2Many' | ||
|
||
parent_id = fields.Many2one('export.group_operator') | ||
value = fields.Integer() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
from . import test_export | ||
|
Oops, something went wrong.