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.

83 lines
3.1 KiB

  1. # Copyright 2020 Coop IT Easy SCRL fs
  2. # Robin Keunen <robin@coopiteasy.be>
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. from odoo.fields import Date
  5. from odoo.tests import TransactionCase
  6. class TestExternalIdMixin(TransactionCase):
  7. def test_res_partner_api_external_id(self):
  8. partner = self.env["res.partner"].create({"name": "Test Partner"})
  9. self.assertFalse(partner._api_external_id)
  10. self.assertFalse(partner.external_id_sequence_id)
  11. external_id = partner.get_api_external_id()
  12. self.assertTrue(bool(partner._api_external_id))
  13. self.assertTrue(bool(partner.external_id_sequence_id))
  14. self.assertEquals(external_id, partner.get_api_external_id())
  15. def test_subscription_request_api_external_id(self):
  16. share_type = self.browse_ref(
  17. "easy_my_coop.product_template_share_type_2_demo"
  18. ).product_variant_id
  19. sr = self.env["subscription.request"].create(
  20. {
  21. "name": "test create request",
  22. "email": "test@demo.net",
  23. "address": "schaerbeekstraat",
  24. "zip_code": "1111",
  25. "city": "Brussels",
  26. "country_id": self.ref("base.be"),
  27. "date": Date.today(),
  28. "source": "manual",
  29. "ordered_parts": 3,
  30. "share_product_id": share_type.id,
  31. "lang": "en_US",
  32. }
  33. )
  34. self.assertFalse(sr._api_external_id)
  35. self.assertFalse(sr.external_id_sequence_id)
  36. external_id = sr.get_api_external_id()
  37. self.assertTrue(bool(sr._api_external_id))
  38. self.assertTrue(bool(sr.external_id_sequence_id))
  39. self.assertEquals(external_id, sr.get_api_external_id())
  40. def test_account_journal_api_external_id(self):
  41. bank = self.env["res.partner.bank"].create(
  42. {
  43. "acc_number": "test",
  44. "partner_id": self.env.user.company_id.partner_id.id,
  45. }
  46. )
  47. journal = self.env["account.journal"].create(
  48. {
  49. "name": "test journal",
  50. "code": "123",
  51. "type": "bank",
  52. "company_id": self.env.ref("base.main_company").id,
  53. "bank_account_id": bank.id,
  54. }
  55. )
  56. self.assertFalse(journal._api_external_id)
  57. self.assertFalse(journal.external_id_sequence_id)
  58. external_id = journal.get_api_external_id()
  59. self.assertTrue(bool(journal._api_external_id))
  60. self.assertTrue(bool(journal.external_id_sequence_id))
  61. self.assertEquals(external_id, journal.get_api_external_id())
  62. def test_account_invoice_api_external_id(self):
  63. invoice = self.env["account.invoice"].create({"name": "create passes"})
  64. self.assertFalse(invoice._api_external_id)
  65. self.assertFalse(invoice.external_id_sequence_id)
  66. external_id = invoice.get_api_external_id()
  67. self.assertTrue(bool(invoice._api_external_id))
  68. self.assertTrue(bool(invoice.external_id_sequence_id))
  69. self.assertEquals(external_id, invoice.get_api_external_id())