Waht do you mean with "object" ?
Already tried o.default_isEnabled and it really doesn't work.
I read this : http://www.mindissoftware.com/2014/10/17/How-to-save-and-load-module-configuration-in-odoo/
Is it because I use default_isEnabled to name my variable ? Not stored in the database as standard field ?
See below the full code for a better understanding (I made some minor changes):
__openerp__.py
{
'name': 'My Module',
'description': 'Test my module ',
'author': 'Theudric',
'depends' : ['base', 'report'],
'application': True,
'data': ['myModule_view.xml', 'header.xml'],
}
__init__.py
from . import myModule
myModule.py
# -*- coding: utf-8 -*-
from openerp import models, fields, api
class myconfig(models.TransientModel):
_name = 'mymodule.myconfig'
_inherit = 'res.config.settings'
default_isEnabled = fields.Boolean(
'Enable my module',
default=True,
default_model='mymodule.myconfig',
)
myModule_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_custom_config_settings" model="ir.ui.view">
<field name="name">custom settings</field>
<field name="model">mymodule.myconfig</field>
<field name="arch" type="xml">
<form string="Configure Accounting" version="7.0" class="oe_form_configuration">
<header>
<button string="Apply" type="object" name="execute" class="oe_highlight"/>
or
<button string="Cancel" type="object" name="cancel" class="oe_link"/>
</header>
<field name="default_isEnabled"/>
</form>
</field>
</record>
<record id="action_custom_config" model="ir.actions.act_window">
<field name="name">Custom Settings</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mymodule.myconfig</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
</record>
<menuitem id="menu_custom_config" name="Custom Settings" parent="base.menu_config"
sequence="16" action="action_custom_config"/>
</data>
</openerp>
header.xml
<?xml version="1.0"?>
<openerp>
<data>
<template id="mymodule_header" inherit_id="report.external_layout_header" >
<xpath expr="//div[@class='header']" position="inside">
<div t-if="company.logo">Hello it is working with company.logo</div>
<!--div t-if="res.config.settings.default_isEnabled">1 Not working !!!</div-->
<!--div t-if="config.settings.default_isEnabled">2 Not working !!!</div-->
<!--div t-if="settings.default_isEnabled">3 Not working !!!</div-->
<div t-if="default_isEnabled">4 Not working !!!</div>
<!--div t-if="o.res.config.settings.default_isEnabled">5 Not working !!!</div-->
<!--div t-if="o.config.settings.default_isEnabled">6 Not working !!!</div-->
<!--div t-if="o.settings.default_isEnabled">7 Not working !!!</div-->
<!--div t-if="o.default_isEnabled">8 Not working !!!</div-->
<!--div t-if="mymodule.myconfig.default_isEnabled">9 Not working !!!</div-->
<!--div t-if="myconfig.default_isEnabled">10 Not working !!!</div-->
</xpath>
</template>
</data>
</openerp>
And now, when I print one invoice, I have no access to my variable default_isEnabled
The goal is to display one image in the invoice header if my variable is enabled. But for now let's write some text instead an image.
All commented <div> just above generated errors. Text "4 Not working !!!" is never displayed : default_isEnabled=True or False
Hope this is more clear now.
You're not specifying the object that you'd like to use. By default you should be able to access it with o.FieldName, so o.default_isEnabled should work.