Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

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

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
modulereportvariable
2 Risposte
8682 Visualizzazioni
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
Abbandona
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
Autore Risposta migliore

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
Abbandona
Theudric Enicar
Autore

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

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Variable "docs" not set in custom template Risolto
module report odoo11
Avatar
Avatar
4
ott 18
5547
Create a variable in xml template odoo14
xml report variable v14
Avatar
Avatar
Avatar
Avatar
3
mag 23
4786
Can't get report to appear on print menu after moving from <report> to <record>
module xml custom report
Avatar
Avatar
1
mag 23
3292
put report in module Risolto
module v7 reporting report
Avatar
Avatar
Avatar
2
apr 23
21918
Anyone successfully installed Py3o Report Engine report template
module report template odoo10.0
Avatar
Avatar
1
set 22
8068
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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