Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions sql_export/wizard/wizard_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

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


Expand All @@ -23,14 +24,23 @@ class SqlFileWizard(models.TransientModel):

def export_sql(self):
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

# Manage Params
variable_dict = {}
now_tz = fields.Datetime.context_timestamp(sql_export, datetime.now())
date = now_tz.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
for prop in self.query_properties:
if prop["type"] == "many2many" and prop["value"]:
if prop["type"] == "many2many":
variable_dict[prop["string"]] = tuple(prop["value"])
else:
variable_dict[prop["string"]] = prop["value"]
Expand Down Expand Up @@ -60,5 +70,4 @@ def export_sql(self):
"type": "ir.actions.act_window",
"target": "new",
"context": self.env.context,
"nodestroy": True,
}
1 change: 1 addition & 0 deletions sql_export/wizard/wizard_file_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
nolabel="1"
columns="1"
hideKanbanOption="1"
required="1"
/>
<separator
string="Export file"
Expand Down