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.

29 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2017 Therp BV <http://therp.nl>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import inspect
  5. from openerp.models import MetaModel
  6. def post_load_hook():
  7. """
  8. We try to be smart here: If the crm module is to be loaded too
  9. (or is already loaded), we remove our own models again in order not to
  10. clash with the CRM ones: https://github.com/OCA/partner-contact/issues/283
  11. """
  12. for frame, filename, lineno, funcname, line, index in inspect.stack():
  13. # walk up the stack until we're in load_module_graph
  14. if 'graph' in frame.f_locals:
  15. graph = frame.f_locals['graph']
  16. package = frame.f_locals['package']
  17. if any(p.name == 'crm' for p in graph):
  18. # so crm is installed, then we need to remove the models
  19. # we pull from CRM again
  20. MetaModel.module_to_models['base_partner_merge'] = [
  21. cls
  22. for cls in MetaModel.module_to_models['base_partner_merge']
  23. if 'NoCRM' not in cls.__name__
  24. ]
  25. # and in this case, we also don't want to load our xml file
  26. package.data['data'].remove('views/base_partner_merge.xml')
  27. break