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.

50 lines
1.6 KiB

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