mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[IMP] bi_sql_editor : Allow to use sum / avg operator on tree view
This commit is contained in:
@@ -8,4 +8,7 @@ from openupgradelib import openupgrade
|
||||
@openupgrade.migrate()
|
||||
def migrate(env, version):
|
||||
for view in env["bi.sql.view"].search([("state", "=", "ui_valid")]):
|
||||
# create new Form view
|
||||
view.form_view_id = env["ir.ui.view"].create(view._prepare_form_view()).id
|
||||
# Update tree view, to add sum / avg option
|
||||
view.tree_view_id.write(view._prepare_tree_view())
|
||||
|
||||
@@ -265,8 +265,14 @@ class BiSQLViewField(models.Model):
|
||||
elif self.tree_visibility == "optional_show":
|
||||
visibility_text = 'optional="show"'
|
||||
|
||||
operator_text = ""
|
||||
if self.group_operator == "sum":
|
||||
operator_text = f'sum="{_("Total")}"'
|
||||
elif self.group_operator == "avg":
|
||||
operator_text = f'avg="{_("Average")}"'
|
||||
|
||||
return (
|
||||
f"""<field name="{self.name}" {visibility_text}"""
|
||||
f"""<field name="{self.name}" {visibility_text} {operator_text}"""
|
||||
f""" context="{self.field_context}"/>\n"""
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user