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.

47 lines
1.3 KiB

  1. # Copyright 2017 LasLabs Inc.
  2. # Copyright 2018 ACSONE
  3. # Copyright 2018 Camptocamp
  4. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
  5. from odoo import fields, models
  6. def setup_test_model(env, model_cls):
  7. """Pass a test model class and initialize it.
  8. Courtesy of SBidoul from https://github.com/OCA/mis-builder :)
  9. """
  10. model_cls._build_model(env.registry, env.cr)
  11. env.registry.setup_models(env.cr)
  12. env.registry.init_models(
  13. env.cr, [model_cls._name],
  14. dict(env.context, update_custom_fields=True)
  15. )
  16. def teardown_test_model(env, model_cls):
  17. """Pass a test model class and deinitialize it.
  18. Courtesy of SBidoul from https://github.com/OCA/mis-builder :)
  19. """
  20. if not getattr(model_cls, '_teardown_no_delete', False):
  21. del env.registry.models[model_cls._name]
  22. env.registry.setup_models(env.cr)
  23. class ResPartner(models.Model):
  24. _name = 'res.partner'
  25. _inherit = 'res.partner'
  26. _teardown_no_delete = True
  27. social_security = fields.Char(
  28. compute=lambda s: s._compute_identification(
  29. 'social_security', 'SSN',
  30. ),
  31. inverse=lambda s: s._inverse_identification(
  32. 'social_security', 'SSN',
  33. ),
  34. search=lambda s, *a: s._search_identification(
  35. 'SSN', *a
  36. ),
  37. )