Update roadmap for v15 and make some usability improvements
Improve usability about variable creation and choice by hiding base wizard base fields and display simplified view Add a description on paramter fields to help the user to use parameters If not parameter are used for the query, display the wizard with the generated file directlypull/553/head
parent
8b863e6afe
commit
db29738411
|
@ -27,7 +27,22 @@ class SqlExport(models.Model):
|
||||||
"sql_id",
|
"sql_id",
|
||||||
"field_id",
|
"field_id",
|
||||||
"Parameters",
|
"Parameters",
|
||||||
domain=[("model", "=", "sql.file.wizard")],
|
domain=[("model", "=", "sql.file.wizard"), ("state", "=", "manual")],
|
||||||
|
help="Before adding parameters, make sure you have created one that fill your "
|
||||||
|
"need in the dedicated menu with the right type and label. \n"
|
||||||
|
"Then, when you add a parameter here, you have to include it in the SQL "
|
||||||
|
"query in order to have dynamic values depending on the user choice.\n"
|
||||||
|
"The format of the parameters in the SQL query must be like this :"
|
||||||
|
" %(parameter_field_name)s. \n"
|
||||||
|
"Example : from the variable menu, create an variable with type 'char', "
|
||||||
|
"having field name 'x_name' and field label : 'Name' \n"
|
||||||
|
"Then, you can create a SQL query like this : "
|
||||||
|
"SELECT * FROM res_partner WHERE name = %(x_name)s the variable "
|
||||||
|
"can be used in any number of different SQL queries. \n"
|
||||||
|
"In the SQL query, you can also include these 2 special parameters "
|
||||||
|
"%(user_id)s and %(company_id)s which will be replaced respectively by "
|
||||||
|
"the user executing the query and the company of the user executing the"
|
||||||
|
" query.",
|
||||||
)
|
)
|
||||||
|
|
||||||
encoding = fields.Selection(
|
encoding = fields.Selection(
|
||||||
|
@ -51,6 +66,10 @@ class SqlExport(models.Model):
|
||||||
def export_sql_query(self):
|
def export_sql_query(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
wiz = self.env["sql.file.wizard"].create({"sql_export_id": self.id})
|
wiz = self.env["sql.file.wizard"].create({"sql_export_id": self.id})
|
||||||
|
# no variable input, we can return the file directly
|
||||||
|
if not self.field_ids:
|
||||||
|
return wiz.export_sql()
|
||||||
|
else:
|
||||||
return {
|
return {
|
||||||
"view_mode": "form",
|
"view_mode": "form",
|
||||||
"res_model": "sql.file.wizard",
|
"res_model": "sql.file.wizard",
|
||||||
|
|
|
@ -15,4 +15,4 @@ See sql_request_abstract module to fix this issue.
|
||||||
since variables features has been introduced. This can be fixed by
|
since variables features has been introduced. This can be fixed by
|
||||||
overloading _prepare_request_check_execution() function.
|
overloading _prepare_request_check_execution() function.
|
||||||
|
|
||||||
* Move modules sql_request_abstract and sql_export to oca/reporting-engine
|
* Move modules sql_request_abstract and sql_export to oca/reporting-engine for version 15
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
states="draft"
|
states="draft"
|
||||||
string="Validate SQL Expression"
|
string="Validate SQL Expression"
|
||||||
class="oe_highlight"
|
class="oe_highlight"
|
||||||
|
groups="sql_request_abstract.group_sql_request_manager"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
name="button_set_draft"
|
name="button_set_draft"
|
||||||
|
@ -33,19 +34,30 @@
|
||||||
<sheet>
|
<sheet>
|
||||||
<group>
|
<group>
|
||||||
<h1>
|
<h1>
|
||||||
<field name="name" nolabel="1" placeholder="Request Name" />
|
<field
|
||||||
|
name="name"
|
||||||
|
nolabel="1"
|
||||||
|
placeholder="Request Name"
|
||||||
|
attrs="{'readonly': [('state', '!=', 'draft')]}"
|
||||||
|
/>
|
||||||
</h1>
|
</h1>
|
||||||
</group>
|
</group>
|
||||||
<group
|
<group
|
||||||
name="option"
|
name="option"
|
||||||
groups="sql_request_abstract.group_sql_request_user"
|
groups="sql_request_abstract.group_sql_request_user"
|
||||||
>
|
>
|
||||||
<field name="file_format" />
|
<field
|
||||||
|
name="file_format"
|
||||||
|
attrs="{'readonly': [('state', '!=', 'draft')]}"
|
||||||
|
/>
|
||||||
<field
|
<field
|
||||||
name="copy_options"
|
name="copy_options"
|
||||||
attrs="{'invisible': [('file_format', '!=', 'csv')], 'required': [('file_format', '=', 'csv')]}"
|
attrs="{'invisible': [('file_format', '!=', 'csv')], 'required': [('file_format', '=', 'csv')], 'readonly': [('state', '!=', 'draft')]}"
|
||||||
|
/>
|
||||||
|
<field
|
||||||
|
name="encoding"
|
||||||
|
attrs="{'readonly': [('state', '!=', 'draft')]}"
|
||||||
/>
|
/>
|
||||||
<field name="encoding" />
|
|
||||||
</group>
|
</group>
|
||||||
<group
|
<group
|
||||||
name="request"
|
name="request"
|
||||||
|
@ -56,6 +68,7 @@
|
||||||
name="query"
|
name="query"
|
||||||
nolabel="1"
|
nolabel="1"
|
||||||
placeholder="select * from res_partner"
|
placeholder="select * from res_partner"
|
||||||
|
attrs="{'readonly': [('state', '!=', 'draft')]}"
|
||||||
/>
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group
|
<group
|
||||||
|
@ -63,7 +76,13 @@
|
||||||
string="Parameters"
|
string="Parameters"
|
||||||
groups="sql_request_abstract.group_sql_request_user"
|
groups="sql_request_abstract.group_sql_request_user"
|
||||||
>
|
>
|
||||||
<field name="field_ids" nolabel="1" />
|
<field
|
||||||
|
name="field_ids"
|
||||||
|
nolabel="1"
|
||||||
|
options="{'no_create': True}"
|
||||||
|
context="{'tree_view_ref': 'sql_export.sql_parameter_view_tree', 'form_view_ref': 'sql_export.sql_parameter_view_form'}"
|
||||||
|
attrs="{'readonly': [('state', '!=', 'draft')]}"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
<group groups="sql_request_abstract.group_sql_request_manager">
|
<group groups="sql_request_abstract.group_sql_request_manager">
|
||||||
<group string="Allowed Users" name="users_allowed">
|
<group string="Allowed Users" name="users_allowed">
|
||||||
|
@ -163,7 +182,9 @@
|
||||||
name="context"
|
name="context"
|
||||||
eval="{'default_model_id': ref('sql_export.model_sql_file_wizard'), 'default_size': 64, 'search_default_state': 'manual', 'default_model': 'sql.file.wizard'}"
|
eval="{'default_model_id': ref('sql_export.model_sql_file_wizard'), 'default_size': 64, 'search_default_state': 'manual', 'default_model': 'sql.file.wizard'}"
|
||||||
/>
|
/>
|
||||||
<field name="domain">[('model','=','sql.file.wizard')]</field>
|
<field
|
||||||
|
name="domain"
|
||||||
|
>[('model','=','sql.file.wizard'), ('state', '=', 'manual')]</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="sql_parameter_action_view_tree" model="ir.actions.act_window.view">
|
<record id="sql_parameter_action_view_tree" model="ir.actions.act_window.view">
|
||||||
|
|
|
@ -70,12 +70,10 @@ class SqlFileWizard(models.TransientModel):
|
||||||
else:
|
else:
|
||||||
variable_dict[field.name] = self[field.name]
|
variable_dict[field.name] = self[field.name]
|
||||||
if "%(company_id)s" in sql_export.query:
|
if "%(company_id)s" in sql_export.query:
|
||||||
company_id = self.env.context.get(
|
company_id = self.env.company.id
|
||||||
"force_company", self.env.user.company_id.id
|
|
||||||
)
|
|
||||||
variable_dict["company_id"] = company_id
|
variable_dict["company_id"] = company_id
|
||||||
if "%(user_id)s" in sql_export.query:
|
if "%(user_id)s" in sql_export.query:
|
||||||
user_id = self.env.context.get("force_user", self._uid)
|
user_id = self.env.user.id
|
||||||
variable_dict["user_id"] = user_id
|
variable_dict["user_id"] = user_id
|
||||||
|
|
||||||
# Call different method depending on file_type since the logic will be
|
# Call different method depending on file_type since the logic will be
|
||||||
|
|
Loading…
Reference in New Issue