updated the error fix for deployement
Some checks failed
CI / Brand-leak check (push) Has been cancelled
CI / flake8 / pylint-odoo / manifest completeness (push) Has been cancelled
CI / Install all modules with --test-enable (push) Has been cancelled

This commit is contained in:
metatroncubeswdev 2026-09-26 19:56:35 -04:00
parent 7aca47ab15
commit 1b7b1710b5
4 changed files with 82 additions and 32 deletions

View File

@ -1,18 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1"> <odoo noupdate="1">
<!-- Settings may already exist before installation. Set by key to avoid
duplicate-key errors; noupdate preserves later administrator changes. -->
<!-- Membership settings --> <!-- Membership settings -->
<record id="config_parameter_membership_org_name" model="ir.config_parameter"> <function model="ir.config_parameter" name="set_param"
<field name="key">community_membership.org_name</field> eval="('community_membership.org_name', 'Tamil Nadu Cultural Society of Canada')"/>
<field name="value">Tamil Nadu Cultural Society of Canada</field> <function model="ir.config_parameter" name="set_param"
</record> eval="('community_membership.member_id_format', 'TNCSC-{year}-{seq}')"/>
<record id="config_parameter_membership_id_format" model="ir.config_parameter"> <function model="ir.config_parameter" name="set_param"
<field name="key">community_membership.member_id_format</field> eval="('community_membership.renewal_offsets', '30,14,7')"/>
<field name="value">TNCSC-{year}-{seq}</field>
</record>
<record id="config_parameter_membership_renewal_offsets" model="ir.config_parameter">
<field name="key">community_membership.renewal_offsets</field>
<field name="value">30,14,7</field>
</record>
<!-- Membership tiers (CAD) - figures from the implementation plan; <!-- Membership tiers (CAD) - figures from the implementation plan;
update via Settings once TNCSC confirms final pricing. --> update via Settings once TNCSC confirms final pricing. -->

View File

@ -1,26 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1"> <odoo noupdate="1">
<!-- Settings may already exist before installation. Set by key to avoid
duplicate-key errors; noupdate preserves later administrator changes. -->
<!-- Colours from the implementation plan. Logo is intentionally left <!-- Colours from the implementation plan. Logo is intentionally left
unset here - upload the real TNCSC logo via Settings > Theme once unset here - upload the real TNCSC logo via Settings > Theme once
the asset is available; there is no placeholder image shipped. --> the asset is available; there is no placeholder image shipped. -->
<record id="config_parameter_theme_primary" model="ir.config_parameter"> <function model="ir.config_parameter" name="set_param"
<field name="key">community_theme_base.primary_color</field> eval="('community_theme_base.primary_color', '#05091E')"/>
<field name="value">#05091E</field> <function model="ir.config_parameter" name="set_param"
</record> eval="('community_theme_base.secondary_color', '#F97316')"/>
<record id="config_parameter_theme_secondary" model="ir.config_parameter"> <function model="ir.config_parameter" name="set_param"
<field name="key">community_theme_base.secondary_color</field> eval="('community_theme_base.accent_color', '#0EA5FF')"/>
<field name="value">#F97316</field> <function model="ir.config_parameter" name="set_param"
</record> eval="('community_theme_base.heading_font', 'Inter, sans-serif')"/>
<record id="config_parameter_theme_accent" model="ir.config_parameter"> <function model="ir.config_parameter" name="set_param"
<field name="key">community_theme_base.accent_color</field> eval="('community_theme_base.body_font', 'Inter, sans-serif')"/>
<field name="value">#0EA5FF</field>
</record>
<record id="config_parameter_theme_heading_font" model="ir.config_parameter">
<field name="key">community_theme_base.heading_font</field>
<field name="value">Inter, sans-serif</field>
</record>
<record id="config_parameter_theme_body_font" model="ir.config_parameter">
<field name="key">community_theme_base.body_font</field>
<field name="value">Inter, sans-serif</field>
</record>
</odoo> </odoo>

View File

@ -1 +1,2 @@
from . import test_tncsc_deployment from . import test_tncsc_deployment
from . import test_config_seed

View File

@ -0,0 +1,61 @@
from odoo.tests.common import TransactionCase, tagged
from odoo.tools.convert import convert_file
@tagged('post_install', '-at_install')
class TestConfigSeed(TransactionCase):
"""Exercise the actual XML loader with settings saved before installation."""
SEEDS = {
'theme_data.xml': {
'community_theme_base.primary_color': '#05091E',
'community_theme_base.secondary_color': '#F97316',
'community_theme_base.accent_color': '#0EA5FF',
'community_theme_base.heading_font': 'Inter, sans-serif',
'community_theme_base.body_font': 'Inter, sans-serif',
},
'membership_data.xml': {
'community_membership.org_name': 'Tamil Nadu Cultural Society of Canada',
'community_membership.member_id_format': 'TNCSC-{year}-{seq}',
'community_membership.renewal_offsets': '30,14,7',
},
}
def _load(self, filename, mode='init'):
convert_file(self.env, 'tncsc_deployment', f'data/{filename}', {}, mode=mode)
def test_install_reuses_existing_parameters(self):
params = self.env['ir.config_parameter'].sudo()
for filename, expected in self.SEEDS.items():
original_ids = {}
for key in expected:
params.set_param(key, 'existing custom value')
record = params.search([('key', '=', key)])
# Reproduce keys created through Settings, without seed XML IDs.
self.env['ir.model.data'].search([
('model', '=', 'ir.config_parameter'), ('res_id', '=', record.id),
('module', '=', 'tncsc_deployment'),
]).unlink()
original_ids[key] = record.id
self._load(filename)
self._load(filename)
for key, value in expected.items():
self.assertEqual(params.get_param(key), value)
self.assertEqual(params.search([('key', '=', key)]).ids, [original_ids[key]])
def test_install_creates_missing_parameters(self):
params = self.env['ir.config_parameter'].sudo()
for filename, expected in self.SEEDS.items():
params.search([('key', 'in', list(expected))]).unlink()
self._load(filename)
for key, value in expected.items():
self.assertEqual(params.get_param(key), value)
def test_upgrade_preserves_custom_parameters(self):
params = self.env['ir.config_parameter'].sudo()
for filename, expected in self.SEEDS.items():
for key in expected:
params.set_param(key, 'administrator value')
self._load(filename, mode='update')
for key in expected:
self.assertEqual(params.get_param(key), 'administrator value')