[IMP]bi_sql_editor: add parent menu as an editable parameter when creating UI elements

When creating the UI for the SQL view, it is now possible to set a specific Parent Menu which will be used when creating the UI Menu for the report itself. The default value will be the `SQL Reports` menu.
Also, added the explanation on the `CONFIGURE.rst` file to have the description updated.
This commit is contained in:
GuillemCForgeFlow
2024-06-04 10:49:03 +02:00
parent 2d54748ae5
commit 03029a0d09
4 changed files with 42 additions and 7 deletions

View File

@@ -162,7 +162,31 @@ class BiSQLView(models.Model):
model_id = fields.Many2one(
string="Odoo Model", comodel_name="ir.model", readonly=True
)
# UI related fields
# 1. Editable fields, which can be set by the user (optional) before
# creating the UI elements
@api.model
def _default_parent_menu_id(self):
return self.env.ref("bi_sql_editor.menu_bi_sql_editor")
parent_menu_id = fields.Many2one(
string="Parent Odoo Menu",
comodel_name="ir.ui.menu",
required=True,
readonly=True,
default=lambda self: self._default_parent_menu_id(),
states={
"draft": [("readonly", False)],
"sql_valid": [("readonly", False)],
"model_valid": [("readonly", False)],
},
help="By assigning a value to this field before manually creating the "
"UI, you're overwriting the parent menu on which the menu related to "
"the SQL report will be created.",
)
# 2. Readonly fields, non editable by the user
tree_view_id = fields.Many2one(
string="Odoo Tree View", comodel_name="ir.ui.view", readonly=True
)
@@ -540,7 +564,7 @@ class BiSQLView(models.Model):
self.ensure_one()
return {
"name": self.name,
"parent_id": self.env.ref("bi_sql_editor.menu_bi_sql_editor").id,
"parent_id": self.parent_menu_id.id,
"action": "ir.actions.act_window,%s" % self.action_id.id,
"sequence": self.sequence,
}