Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

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

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
modulereportvariable
2 Răspunsuri
8683 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
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.

Imagine profil
Theudric Enicar
Autor Cel mai bun răspuns

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
Imagine profil
Abandonează
Theudric Enicar
Autor

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!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Variable "docs" not set in custom template Rezolvat
module report odoo11
Imagine profil
Imagine profil
4
oct. 18
5547
Create a variable in xml template odoo14
xml report variable v14
Imagine profil
Imagine profil
Imagine profil
Imagine profil
3
mai 23
4786
Can't get report to appear on print menu after moving from <report> to <record>
module xml custom report
Imagine profil
Imagine profil
1
mai 23
3292
put report in module Rezolvat
module v7 reporting report
Imagine profil
Imagine profil
Imagine profil
2
apr. 23
21918
Anyone successfully installed Py3o Report Engine report template
module report template odoo10.0
Imagine profil
Imagine profil
1
sept. 22
8068
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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