From 72f6271147c61c3872b35862a23b9be4c8f3062e Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Thu, 30 Nov 2017 18:00:33 +0100 Subject: [PATCH] Allow to use many2one and many2many fields for query variables --- sql_export/wizard/wizard_file.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql_export/wizard/wizard_file.py b/sql_export/wizard/wizard_file.py index 3f62198a7..20a48a483 100644 --- a/sql_export/wizard/wizard_file.py +++ b/sql_export/wizard/wizard_file.py @@ -79,7 +79,12 @@ class SqlFileWizard(models.TransientModel): date = today_tz.strftime(DEFAULT_SERVER_DATETIME_FORMAT) if sql_export.field_ids: for field in sql_export.field_ids: - variable_dict[field.name] = self[field.name] + if field.ttype == 'many2one': + variable_dict[field.name] = self[field.name].id + elif field.ttype == 'many2many': + variable_dict[field.name] = tuple(self[field.name].ids) + else: + variable_dict[field.name] = self[field.name] if "%(company_id)s" in sql_export.query: variable_dict['company_id'] = self.env.user.company_id.id if "%(user_id)s" in sql_export.query: