Browse Source
Merge pull request #1080 from akretion/8.0-fix-many2x-variables
[8.0][sql_export] Allow to use many2one and many2many fields for query variables
pull/913/merge
beau sebastien
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
1 deletions
-
sql_export/wizard/wizard_file.py
|
@ -79,7 +79,12 @@ class SqlFileWizard(models.TransientModel): |
|
|
date = today_tz.strftime(DEFAULT_SERVER_DATETIME_FORMAT) |
|
|
date = today_tz.strftime(DEFAULT_SERVER_DATETIME_FORMAT) |
|
|
if sql_export.field_ids: |
|
|
if sql_export.field_ids: |
|
|
for field in 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: |
|
|
if "%(company_id)s" in sql_export.query: |
|
|
variable_dict['company_id'] = self.env.user.company_id.id |
|
|
variable_dict['company_id'] = self.env.user.company_id.id |
|
|
if "%(user_id)s" in sql_export.query: |
|
|
if "%(user_id)s" in sql_export.query: |
|
|