[IMP] bi_sql_editor: create filters for date fields.

Date filters provide default options by serveral periods. We want to take advantage of this.
pull/850/head
Jordi Ballester Alomar 2024-01-26 02:27:46 +01:00
parent 598bffacad
commit a0227777e0
1 changed files with 16 additions and 7 deletions

View File

@ -292,10 +292,19 @@ class BiSQLViewField(models.Model):
def _prepare_search_filter_field(self):
self.ensure_one()
if not self.is_group_by:
return ""
return (
f"""<filter name="group_by_{self.name}" """
f"""string="{self.field_description}" """
f"""context="{{'group_by':'{self.name}'}}"/>\n"""
)
group_by_filter = ""
field_filter = ""
if self.is_group_by:
group_by_filter = (
f"""<filter name="group_by_{self.name}" """
f"""string="{self.field_description}" """
f"""context="{{'group_by':'{self.name}'}}"/>\n"""
)
if self.ttype in ["date", "datetime"]:
field_filter = (
f"""<filter name="filter_{self.name}" """
f"""string="{self.field_description}" """
f"""date="{self.name}"/>\n"""
)
res = "%s%s" % (field_filter, group_by_filter)
return res