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.

64 lines
2.3 KiB

11 years ago
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # This module copyright (C) 2014 Therp BV (<http://therp.nl>).
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. import logging
  22. from openerp.osv import orm, fields
  23. class CleanupPurgeLine(orm.AbstractModel):
  24. """ Abstract base class for the purge wizard lines """
  25. _name = 'cleanup.purge.line'
  26. _columns = {
  27. 'name': fields.char('Name', size=256, readonly=True),
  28. 'purged': fields.boolean('Purged', readonly=True),
  29. }
  30. logger = logging.getLogger('openerp.addons.database_cleanup')
  31. def purge(self, cr, uid, ids, context=None):
  32. raise NotImplementedError
  33. class PurgeWizard(orm.AbstractModel):
  34. """ Abstract base class for the purge wizards """
  35. _name = 'cleanup.purge.wizard'
  36. def default_get(self, cr, uid, fields, context=None):
  37. res = super(PurgeWizard, self).default_get(
  38. cr, uid, fields, context=context)
  39. if 'purge_line_ids' in fields:
  40. res['purge_line_ids'] = self.find(cr, uid, context=None)
  41. return res
  42. def find(self, cr, uid, ids, context=None):
  43. raise NotImplementedError
  44. def purge_all(self, cr, uid, ids, context=None):
  45. line_pool = self.pool[self._columns['purge_line_ids']._obj]
  46. for wizard in self.browse(cr, uid, ids, context=context):
  47. line_pool.purge(
  48. cr, uid, [line.id for line in wizard.purge_line_ids],
  49. context=context)
  50. return True
  51. _columns = {
  52. 'name': fields.char('Name', size=64, readonly=True),
  53. }