diff --git a/bi_sql_editor/models/bi_sql_view.py b/bi_sql_editor/models/bi_sql_view.py
index 24c029f7f..42439bf68 100644
--- a/bi_sql_editor/models/bi_sql_view.py
+++ b/bi_sql_editor/models/bi_sql_view.py
@@ -168,6 +168,12 @@ class BiSQLView(models.Model):
sequence = fields.Integer(string="sequence")
+ option_context_field = fields.Boolean(
+ string="Use Context Field",
+ help="Check this box if you want to add a context column in the field list view."
+ " Custom Context will be inserted in the created views.",
+ )
+
# Constrains Section
@api.constrains("is_materialized")
def _check_index_materialized(self):
diff --git a/bi_sql_editor/models/bi_sql_view_field.py b/bi_sql_editor/models/bi_sql_view_field.py
index 039788a90..2a89e291f 100644
--- a/bi_sql_editor/models/bi_sql_view_field.py
+++ b/bi_sql_editor/models/bi_sql_view_field.py
@@ -127,6 +127,12 @@ class BiSQLViewField(models.Model):
"to alter the behaviour, choose an alternate Group Operator",
)
+ field_context = fields.Char(
+ default="{}",
+ help="Context value that will be inserted for this field in all the views."
+ " Important note : please write a context with single quote.",
+ )
+
# Constrains Section
@api.constrains("is_index")
def _check_index_materialized(self):
@@ -231,22 +237,34 @@ class BiSQLViewField(models.Model):
elif self.tree_visibility == "optional_show":
visibility_text = 'option="show"'
- return f"""\n"""
+ return (
+ f"""\n"""
+ )
def _prepare_graph_field(self):
self.ensure_one()
if not self.graph_type:
return ""
- return f"""\n"""
+ return (
+ f"""\n"""
+ )
def _prepare_pivot_field(self):
self.ensure_one()
graph_type_text = self.graph_type and f'type="{self.graph_type}"' or ""
- return f"""\n"""
+ return (
+ f"""\n"""
+ )
def _prepare_search_field(self):
self.ensure_one()
- return """\n""".format(self.name)
+ return """\n""".format(
+ self.name,
+ self.field_context,
+ )
def _prepare_search_filter_field(self):
self.ensure_one()
diff --git a/bi_sql_editor/views/view_bi_sql_view.xml b/bi_sql_editor/views/view_bi_sql_view.xml
index f2dfc9d0e..207440b4e 100644
--- a/bi_sql_editor/views/view_bi_sql_view.xml
+++ b/bi_sql_editor/views/view_bi_sql_view.xml
@@ -98,6 +98,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
name="cron_id"
attrs="{'invisible': ['|', ('state', 'in', ('draft', 'sql_valid')), ('is_materialized', '=', False)]}"
/>
+
@@ -160,6 +161,13 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
optional="hide"
attrs="{'invisible': [('field_description', '=', False)]}"
/>
+