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.

33 lines
1.0 KiB

7 years ago
7 years ago
7 years ago
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 LasLabs Inc.
  3. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
  4. from openerp import api, models
  5. class ModuleUpgrade(models.TransientModel):
  6. _inherit = 'base.module.upgrade'
  7. @api.model
  8. def get_module_list(self):
  9. Module = self.env["ir.module.module"]
  10. installed_modules = Module.search([('state', '=', 'installed')])
  11. upgradeable_modules = installed_modules.filtered(
  12. lambda r: r.checksum_dir != r.checksum_installed,
  13. )
  14. upgradeable_modules.button_upgrade()
  15. return super(ModuleUpgrade, self).get_module_list()
  16. @api.multi
  17. def upgrade_module_cancel(self):
  18. return super(
  19. ModuleUpgrade,
  20. self.with_context(retain_checksum_installed=True),
  21. ).upgrade_module_cancel()
  22. @api.multi
  23. def upgrade_module(self):
  24. # Compute updates by checksum when called in @api.model fashion
  25. if not self:
  26. self.get_module_list()
  27. return super(ModuleUpgrade, self).upgrade_module()