__init__.py 1.0 KB

123456789101112131415161718192021222324252627
  1. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  2. from . import controllers
  3. from . import models
  4. from . import wizards
  5. from odoo import api, SUPERUSER_ID
  6. def post_init_hook(cr, registry):
  7. """ Create `account.payment.method` records for the installed payment providers. """
  8. env = api.Environment(cr, SUPERUSER_ID, {})
  9. PaymentProvider = env['payment.provider']
  10. installed_providers = PaymentProvider.search([('module_id.state', '=', 'installed')])
  11. for code in set(installed_providers.mapped('code')):
  12. PaymentProvider._setup_payment_method(code)
  13. def uninstall_hook(cr, registry):
  14. """ Delete `account.payment.method` records created for the installed payment providers. """
  15. env = api.Environment(cr, SUPERUSER_ID, {})
  16. installed_providers = env['payment.provider'].search([('module_id.state', '=', 'installed')])
  17. env['account.payment.method'].search([
  18. ('code', 'in', installed_providers.mapped('code')),
  19. ('payment_type', '=', 'inbound'),
  20. ]).unlink()