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.

70 lines
2.7 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2019 Coop IT Easy SCRL fs
  3. # Robin Keunen <robin@coopiteasy.be>
  4. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  5. import odoo.tests.common as common
  6. from odoo.fields import Date
  7. class TestCoop(common.TransactionCase):
  8. def setUp(self):
  9. super(TestCoop, self).setUp()
  10. self.request = self.browse_ref(
  11. "easy_my_coop.subscription_request_1_demo"
  12. )
  13. self.bank_journal_euro = self.env["account.journal"].create(
  14. {"name": "Bank", "type": "bank", "code": "BNK67"}
  15. )
  16. self.payment_method_manual_in = self.env.ref(
  17. "account.account_payment_method_manual_in"
  18. )
  19. def test_put_on_waiting_list(self):
  20. self.request.put_on_waiting_list()
  21. self.assertEquals(self.request.state, "waiting")
  22. def test_validate_subscription_request(self):
  23. self.request.validate_subscription_request()
  24. self.assertEquals(self.request.state, "done")
  25. self.assertTrue(self.request.partner_id)
  26. self.assertTrue(self.request.partner_id.coop_candidate)
  27. self.assertFalse(self.request.partner_id.member)
  28. self.assertEquals(self.request.type, "new")
  29. self.assertTrue(len(self.request.capital_release_request) >= 1)
  30. self.assertEquals(self.request.capital_release_request.state, "open")
  31. self.assertTrue(self.request.capital_release_request.sent)
  32. def test_register_payment_for_capital_release(self):
  33. self.request.validate_subscription_request()
  34. invoice = self.request.capital_release_request
  35. ctx = {"active_model": "account.invoice", "active_ids": [invoice.id]}
  36. register_payments = (
  37. self.env["account.register.payments"]
  38. .with_context(ctx)
  39. .create(
  40. {
  41. "payment_date": Date.today(),
  42. "journal_id": self.bank_journal_euro.id,
  43. "payment_method_id": self.payment_method_manual_in.id,
  44. }
  45. )
  46. )
  47. register_payments.create_payments()
  48. self.assertEquals(self.request.capital_release_request.state, "paid")
  49. partner = self.request.partner_id
  50. self.assertFalse(partner.coop_candidate)
  51. self.assertTrue(partner.member)
  52. self.assertTrue(partner.share_ids)
  53. self.assertEquals(self.request.partner_id.effective_date, Date.today())
  54. share = partner.share_ids[0]
  55. self.assertEquals(share.share_number, self.request.ordered_parts)
  56. self.assertEquals(
  57. share.share_product_id, self.request.share_product_id
  58. )
  59. self.assertEquals(share.effective_date, Date.today())