community_membership: - Tiers get a fixed-term period (term_years), minimum age, a proof-document flag, a family-member flag and a signup description. - Members get first/last name (composing the contact name), month and year of birth with computed age, board approval state with approve/reject buttons, terms acceptance, a proof-of-eligibility upload and an inline family members list. Birth date and proof document are restricted to Membership Managers. - Constraints: plausible birth year; a tier's minimum age is enforced when the birth year is known. - Fix pre-existing tests that collided with deployment-seeded tier codes and member ID format. tncsc_deployment: - Five Yes/No eligibility questions from the tncsc.com registration form (manager-only), shown in an Eligibility section of the member form. - Tiers now match tncsc.com/membership-registration: Annual/Family $30, Long-Term (10 yr) $250, Life $500, Senior Annual (65+) $15, Senior Life (60+) $250, Student Annual $10 (CAD). - 19.0.1.1.0 post-migrate rewrites existing tiers (noupdate data) and archives the unused Individual tier. scripts/migrate_wp_members.py maps WordPress levels to the new LONG and SENLIFE tiers. .mcp.json (holds credentials) is now gitignored. Verified on the local Docker stack: -u on tncsc_site ran the migration cleanly, and a fresh install with --test-enable passed 32/32 tests for community_membership and tncsc_deployment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
109 lines
5.3 KiB
Python
109 lines
5.3 KiB
Python
from odoo.tests.common import TransactionCase, tagged
|
|
|
|
|
|
@tagged('post_install', '-at_install')
|
|
class TestTncscDeployment(TransactionCase):
|
|
|
|
def setUp(self):
|
|
super().setUp()
|
|
# Deterministic setup for testing: this Odoo build's own chart-
|
|
# template auto-install can race with post_init_hook's call to this
|
|
# same method within the install transaction (see
|
|
# models/res_company.py) - calling it again here, synchronously,
|
|
# from the test's own transaction avoids the test suite being
|
|
# sensitive to that race. The method is idempotent either way.
|
|
self.env.company._tncsc_setup_accounting()
|
|
|
|
def test_branding_config_seeded(self):
|
|
get_param = self.env['ir.config_parameter'].sudo().get_param
|
|
self.assertEqual(get_param('community_theme_base.primary_color'), '#05091E')
|
|
self.assertEqual(get_param('community_theme_base.secondary_color'), '#F97316')
|
|
self.assertEqual(get_param('community_theme_base.accent_color'), '#0EA5FF')
|
|
|
|
def test_membership_settings_seeded(self):
|
|
get_param = self.env['ir.config_parameter'].sudo().get_param
|
|
self.assertEqual(get_param('community_membership.org_name'), 'Tamil Nadu Cultural Society of Canada')
|
|
self.assertEqual(get_param('community_membership.member_id_format'), 'TNCSC-{year}-{seq}')
|
|
|
|
def test_six_membership_tiers_seeded(self):
|
|
tiers = self.env['community.membership.tier'].search([])
|
|
self.assertEqual(len(tiers), 6)
|
|
by_code = {tier.code: tier for tier in tiers}
|
|
self.assertEqual(by_code['FAM'].price, 30.0)
|
|
self.assertTrue(by_code['FAM'].allows_family_members)
|
|
self.assertEqual(by_code['LONG'].price, 250.0)
|
|
self.assertEqual((by_code['LONG'].period, by_code['LONG'].term_years), ('fixed_term', 10))
|
|
self.assertEqual(by_code['LIFE'].price, 500.0)
|
|
self.assertEqual(by_code['SEN'].price, 15.0)
|
|
self.assertEqual(by_code['SEN'].min_age, 65)
|
|
self.assertEqual(by_code['SENLIFE'].price, 250.0)
|
|
self.assertEqual((by_code['SENLIFE'].period, by_code['SENLIFE'].min_age), ('one_time', 60))
|
|
self.assertEqual(by_code['STU'].price, 10.0)
|
|
self.assertTrue(by_code['STU'].requires_proof)
|
|
for tier in tiers:
|
|
self.assertEqual(tier.currency_id.name, 'CAD')
|
|
self.assertTrue(tier.product_id, "Every seeded tier should still auto-create its product")
|
|
|
|
def test_eligibility_answers_stored(self):
|
|
partner = self.env['res.partner'].create({
|
|
'first_name': 'Kavya',
|
|
'last_name': 'Raman',
|
|
'tncsc_born_tamil_nadu': 'yes',
|
|
'tncsc_other_citizenship': 'no',
|
|
})
|
|
self.assertEqual(partner.name, 'Kavya Raman')
|
|
self.assertEqual(partner.tncsc_born_tamil_nadu, 'yes')
|
|
self.assertEqual(partner.tncsc_other_citizenship, 'no')
|
|
self.assertFalse(partner.tncsc_pio_oci, "Unanswered questions should stay empty, not 'no'")
|
|
|
|
def test_chart_of_accounts_loaded(self):
|
|
company = self.env.company
|
|
self.assertEqual(company.currency_id.name, 'CAD')
|
|
self.assertEqual(company.country_id.code, 'CA')
|
|
# The Canadian template seeds thousands of accounts; a small sanity count is enough.
|
|
account_count = self.env['account.account'].search_count([('company_ids', 'in', company.id)])
|
|
self.assertGreater(account_count, 100)
|
|
|
|
def test_custom_nonprofit_accounts_created(self):
|
|
Account = self.env['account.account']
|
|
names = {'Membership Dues Revenue', 'Event Revenue', 'Sponsorship Revenue',
|
|
'School Fees Revenue', 'Donations Revenue', 'Deferred Event Revenue',
|
|
'Stripe Clearing Account'}
|
|
for name in names:
|
|
account = Account.search([('name', '=', name)], limit=1)
|
|
self.assertTrue(account, f"Expected custom account '{name}' to exist")
|
|
|
|
def test_donations_journal_created(self):
|
|
journal = self.env['account.journal'].search([('code', '=', 'DON')], limit=1)
|
|
self.assertTrue(journal)
|
|
self.assertEqual(journal.type, 'sale')
|
|
|
|
def test_membership_tier_products_use_dues_account(self):
|
|
dues_account = self.env['account.account'].search([('name', '=', 'Membership Dues Revenue')], limit=1)
|
|
tiers = self.env['community.membership.tier'].search([])
|
|
for tier in tiers:
|
|
self.assertEqual(tier.product_id.property_account_income_id, dues_account)
|
|
|
|
def test_website_pages_published(self):
|
|
urls = (
|
|
'/', '/about', '/about/tamil-nadu', '/about/board-of-directors',
|
|
'/membership', '/membership/benefits', '/tamil-school',
|
|
'/sponsors', '/contact',
|
|
)
|
|
for url in urls:
|
|
page = self.env['website.page'].search([('url', '=', url)], limit=1)
|
|
self.assertTrue(page, f"Expected a website.page for {url}")
|
|
self.assertTrue(page.is_published)
|
|
|
|
def test_tncsc_role_groups_exist_and_imply_product_groups(self):
|
|
board_admin = self.env.ref('tncsc_deployment.group_tncsc_board_admin')
|
|
self.assertIn(
|
|
self.env.ref('community_membership.group_membership_manager'),
|
|
board_admin.implied_ids,
|
|
)
|
|
treasurer = self.env.ref('tncsc_deployment.group_tncsc_treasurer')
|
|
self.assertIn(
|
|
self.env.ref('community_interac.group_interac_verifier'),
|
|
treasurer.implied_ids,
|
|
)
|