Coverage for ingadhoc-odoo-saas-adhoc / saas_provider_upgrade / wizards / upgrade_code_help.py: 35%

19 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-09 18:15 +0000

1from odoo import fields, models 

2from odoo.exceptions import UserError 

3 

4 

5class CodeHelpWizard(models.TransientModel): 

6 _name = "code.help.wizard" 

7 _description = "Wizard to Edit Help Information" 

8 

9 code_help_html = fields.Html(string="Help Information") 

10 

11 def default_get(self, fields_list: list) -> dict: 

12 """ 

13 Loads HTML content from system parameters for wizard initialization. 

14 :param fields_list: List of field names to get defaults for 

15 

16 :return: Dict with default values 

17 """ 

18 defaults = super().default_get(fields_list) 

19 config_param = self.env["ir.config_parameter"].sudo() 

20 help_content = config_param.get_param("res.config.settings.code_help_html", default="") 

21 if not help_content: 

22 help_content = "<p>Default HTML field content.</p>" 

23 defaults.update( 

24 { 

25 "code_help_html": help_content, 

26 } 

27 ) 

28 return defaults 

29 

30 def action_save_help_information(self): 

31 """ 

32 Saves the modified HTML content to system parameters. 

33 """ 

34 if not self.code_help_html: 

35 raise UserError("HTML content cannot be empty.") 

36 config_param = self.env["ir.config_parameter"].sudo() 

37 config_param.set_param("res.config.settings.code_help_html", self.code_help_html)