mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[IMP] sql_export : force user to set properties to avoid server error
This commit is contained in:
committed by
Sander Lienaerts
parent
49e1b7eeb0
commit
baf2c9e51d
@@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from odoo import fields, models
|
from odoo import _, fields, models
|
||||||
|
from odoo.exceptions import UserError
|
||||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
||||||
|
|
||||||
|
|
||||||
@@ -23,6 +24,15 @@ class SqlFileWizard(models.TransientModel):
|
|||||||
|
|
||||||
def export_sql(self):
|
def export_sql(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
|
|
||||||
|
# Check properties
|
||||||
|
bad_props = [x for x in self.query_properties if not x["value"]]
|
||||||
|
if bad_props:
|
||||||
|
raise UserError(
|
||||||
|
_("Please enter a values for the following properties : %s")
|
||||||
|
% (",".join([x["string"] for x in bad_props]))
|
||||||
|
)
|
||||||
|
|
||||||
sql_export = self.sql_export_id
|
sql_export = self.sql_export_id
|
||||||
|
|
||||||
# Manage Params
|
# Manage Params
|
||||||
@@ -30,7 +40,7 @@ class SqlFileWizard(models.TransientModel):
|
|||||||
now_tz = fields.Datetime.context_timestamp(sql_export, datetime.now())
|
now_tz = fields.Datetime.context_timestamp(sql_export, datetime.now())
|
||||||
date = now_tz.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
date = now_tz.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||||
for prop in self.query_properties:
|
for prop in self.query_properties:
|
||||||
if prop["type"] == "many2many" and prop["value"]:
|
if prop["type"] == "many2many":
|
||||||
variable_dict[prop["string"]] = tuple(prop["value"])
|
variable_dict[prop["string"]] = tuple(prop["value"])
|
||||||
else:
|
else:
|
||||||
variable_dict[prop["string"]] = prop["value"]
|
variable_dict[prop["string"]] = prop["value"]
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
nolabel="1"
|
nolabel="1"
|
||||||
columns="1"
|
columns="1"
|
||||||
hideKanbanOption="1"
|
hideKanbanOption="1"
|
||||||
|
required="1"
|
||||||
/>
|
/>
|
||||||
<separator
|
<separator
|
||||||
string="Export file"
|
string="Export file"
|
||||||
|
|||||||
Reference in New Issue
Block a user