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.

40 lines
1.2 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], dict(env.context, update_custom_fields=True)
  14. )
  15. def teardown_test_model(env, model_cls):
  16. """Pass a test model class and deinitialize it.
  17. Courtesy of SBidoul from https://github.com/OCA/mis-builder :)
  18. """
  19. if not getattr(model_cls, "_teardown_no_delete", False):
  20. del env.registry.models[model_cls._name]
  21. env.registry.setup_models(env.cr)
  22. class ResPartner(models.Model):
  23. _name = "res.partner"
  24. _inherit = "res.partner"
  25. _teardown_no_delete = True
  26. social_security = fields.Char(
  27. compute=lambda s: s._compute_identification("social_security", "SSN"),
  28. inverse=lambda s: s._inverse_identification("social_security", "SSN"),
  29. search=lambda s, *a: s._search_identification("SSN", *a),
  30. )