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.

34 lines
1.1 KiB

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 odoo import api, models
  5. class ModuleUpgrade(models.TransientModel):
  6. _inherit = 'base.module.upgrade'
  7. @api.model
  8. def get_module_list(self):
  9. if not self.env.context.get('module_uninstall'):
  10. Module = self.env["ir.module.module"]
  11. installed_modules = Module.search([('state', '=', 'installed')])
  12. upgradeable_modules = installed_modules.filtered(
  13. lambda r: r.checksum_dir != r.checksum_installed,
  14. )
  15. upgradeable_modules.button_upgrade()
  16. return super(ModuleUpgrade, self).get_module_list()
  17. @api.multi
  18. def upgrade_module_cancel(self):
  19. return super(
  20. ModuleUpgrade,
  21. self.with_context(retain_checksum_installed=True),
  22. ).upgrade_module_cancel()
  23. @api.multi
  24. def upgrade_module(self):
  25. # Compute updates by checksum when called in @api.model fashion
  26. if not self:
  27. self.get_module_list()
  28. return super(ModuleUpgrade, self).upgrade_module()