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.

57 lines
2.3 KiB

  1. # -*- encoding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # This module copyright (C) 2010 - 2014 Savoir-faire Linux
  6. # (<http://www.savoirfairelinux.com>).
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU Affero General Public License as
  10. # published by the Free Software Foundation, either version 3 of the
  11. # License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU Affero General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Affero General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. ##############################################################################
  22. from openerp.tests.common import TransactionCase
  23. class test_partner_contact_id(TransactionCase):
  24. def setUp(self):
  25. super(test_partner_contact_id, self).setUp()
  26. # Clean up registries
  27. self.registry('ir.model').clear_caches()
  28. self.registry('ir.model.data').clear_caches()
  29. # Get registries
  30. self.user_model = self.registry("res.users")
  31. self.partner_model = self.registry("res.partner")
  32. # Get context
  33. self.context = self.user_model.context_get(self.cr, self.uid)
  34. # Create values for test, contact also created
  35. contact_id = self.partner_model.create(self.cr, self.uid, {
  36. 'name': u'Astérix',
  37. 'title': 1,
  38. }, context=self.context)
  39. self.vals = {
  40. 'name': u'Obélix',
  41. 'type': 'contact',
  42. 'contact_id': contact_id,
  43. }
  44. def test_create_partner(self):
  45. cr, uid, vals, context = self.cr, self.uid, self.vals, self.context
  46. partner_id = self.partner_model.create(cr, uid, vals, context=context)
  47. partner = self.partner_model.browse(
  48. cr, uid, partner_id, context=context
  49. )
  50. # Creating the partner uses the name from the contact
  51. self.assertEqual(partner.name, u'Astérix')
  52. self.assertEqual(partner.lastname, u'Astérix')