Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

How to use a variable from own module inside a report ?

Naroči se

Get notified when there's activity on this post

This question has been flagged
modulereportvariable
2 Odgovori
8680 Prikazi
Avatar
Theudric Enicar

As beginner with Odoo, I made the following module:

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',
        )

Now, inside my report, I would like to check whether my module is enabled and display one image.
Exactly like the external_layout does with " company.logo ", but with my variable " default_isEnabled "

<img t-if="company.logo" ...

<img t-if="default_isEnabled" .... => doesn't work
<img t-if="'myModule.myconfig.default_isEnabled" .... => doesn't work

I probably missed some steps, but I don't know where to find the information.
I am spending time and time... Tried % if, and lot of other stuff, without success...
Many thanks in advance for your help.

0
Avatar
Opusti
Yenthe Van Ginneken (Mainframe Monkey)

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.

Avatar
Theudric Enicar
Avtor Best Answer

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.


0
Avatar
Opusti
Theudric Enicar
Avtor

It looks using a variable starting with *default_* doesn't work inside xml. But probably working inside .py SOLUTION: I did inherit from *company* and it works

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Variable "docs" not set in custom template Solved
module report odoo11
Avatar
Avatar
4
okt. 18
5546
Create a variable in xml template odoo14
xml report variable v14
Avatar
Avatar
Avatar
Avatar
3
maj 23
4786
Can't get report to appear on print menu after moving from <report> to <record>
module xml custom report
Avatar
Avatar
1
maj 23
3292
put report in module Solved
module v7 reporting report
Avatar
Avatar
Avatar
2
apr. 23
21917
Anyone successfully installed Py3o Report Engine report template
module report template odoo10.0
Avatar
Avatar
1
sep. 22
8067
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now