You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2015 Akretion (<http://www.akretion.com>)
  3. # @author: Florian da Costa
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from odoo import models, fields, api
  6. class SqlExport(models.Model):
  7. _name = "sql.export"
  8. _inherit = ['sql.request.mixin']
  9. _description = "SQL export"
  10. _sql_request_groups_relation = 'groups_sqlquery_rel'
  11. _sql_request_users_relation = 'users_sqlquery_rel'
  12. _check_execution_enabled = False
  13. copy_options = fields.Char(
  14. string='Copy Options', required=True,
  15. default="CSV HEADER DELIMITER ';'")
  16. field_ids = fields.Many2many(
  17. 'ir.model.fields',
  18. 'fields_sqlquery_rel',
  19. 'sql_id',
  20. 'field_id',
  21. 'Parameters',
  22. domain=[('model', '=', 'sql.file.wizard')])
  23. encoding = fields.Selection(
  24. [('utf-8', 'utf-8'), ('utf-16', 'utf-16'),
  25. ('windows-1252', 'windows-1252'), ('latin1', 'latin1'),
  26. ('latin2', 'latin2'), ('big5', 'big5'), ('gb18030', 'gb18030'),
  27. ('shift_jis', 'shift_jis'), ('windows-1251', 'windows-1251'),
  28. ('koir8_r', 'koir8_r')], string='Encoding', required=True,
  29. default='utf-8')
  30. @api.multi
  31. def export_sql_query(self):
  32. self.ensure_one()
  33. wiz = self.env['sql.file.wizard'].create({
  34. 'sql_export_id': self.id})
  35. return {
  36. 'view_type': 'form',
  37. 'view_mode': 'form',
  38. 'res_model': 'sql.file.wizard',
  39. 'res_id': wiz.id,
  40. 'type': 'ir.actions.act_window',
  41. 'target': 'new',
  42. 'context': self._context,
  43. 'nodestroy': True,
  44. }