odooqwebodoo-15

Odoo access ir.config_paramter in report


I want to access and print a config parameter in a report.

I have tried this

<div t-if="ir.config_paramter"> 
    <span t-field="ir.config_paramter.mymodule.myhtmlfield"/>
</div>

But I get an error saying it does not know 'ir'

The report I am trying to edit is account.report_invoice_document

What do I need to do to correctly print the field on the report?


Solution

  • You can pass the value of your ir_config_parameter via data argument in get_report function, or include it via a computed field in your report related method.

    For example:

    ir_parameter_value = fields.Char(compute="_compute_ir_parameter_value")
    
      def _compute_ir_parameter_value(self):
        for record in self:
          record.ir_parameter_value = self.env['ir.config_parameter'].get_parameter("parameter_key")