Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

How to display dialog box

Odebírat

Get notified when there's activity on this post

This question has been flagged
messagebox
19 Odpovědi
50807 Zobrazení
Avatar
Maniganda

I have a requirement, to display the message box and update the current date and time but if I use raise.osv it's stopping the flow of control and the datetime is not updated.

4
Avatar
Zrušit
Rajiv

These are Module files. Maybe make an extra module with this and then just use it as written @ the buttom

Sehrish

this will helps: https://learnopenerp.blogspot.com/2017/12/how-to-display-confirmation-display-box.html

Avatar
Maniganda
Autor Nejlepší odpověď

crete py file in your module

from osv import osv
from osv import fields
from openerp.tools.translate import _

WARNING_TYPES = [('warning','Warning'),('info','Information'),('error','Error')]

class warning(osv.osv_memory):
_name = 'warning'
_description = 'warning'
_columns = {
    'type': fields.selection(WARNING_TYPES, string='Type', readonly=True),
    'title': fields.char(string="Title", size=100, readonly=True),
    'message': fields.text(string="Message", readonly=True),
}
_req_name = 'title'

def _get_view_id(self, cr, uid):
    """Get the view id
    @return: view id, or False if no view found
    """
    res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 
        'osc_integ', 'warning_form')
    return res and res[1] or False

def message(self, cr, uid, id, context):
    message = self.browse(cr, uid, id)
    message_type = [t[1]for t in WARNING_TYPES if message.type == t[0]][0]
    print '%s: %s' % (_(message_type), _(message.title))
    res = {
        'name': '%s: %s' % (_(message_type), _(message.title)),
        'view_type': 'form',
        'view_mode': 'form',
        'view_id': self._get_view_id(cr, uid),
        'res_model': 'warning',
        'domain': [],
        'context': context,
        'type': 'ir.actions.act_window',
        'target': 'new',
        'res_id': message.id
    }
    return res

def warning(self, cr, uid, title, message, context=None):
    id = self.create(cr, uid, {'title': title, 'message': message, 'type': 'warning'})
    res = self.message(cr, uid, id, context)
    return res

def info(self, cr, uid, title, message, context=None):
    id = self.create(cr, uid, {'title': title, 'message': message, 'type': 'info'})
    res = self.message(cr, uid, id, context)
    return res

def error(self, cr, uid, title, message, context=None):
    id = self.create(cr, uid, {'title': title, 'message': message, 'type': 'error'})
    res = self.message(cr, uid, id, context)
    return res

and create xml file

<openerp>
   <data>
    <record id="warning_form" model="ir.ui.view">
        <field name="name">warning.form</field>
        <field name="model">warning</field>
        <field eval="20" name="priority"/>
        <field name="arch" type="xml">
            <form string="Warning" version="7.0">
                <field name="message"  nolabel="1" />
                <footer>
                    <button string="OK" class="oe_highlight" special="cancel" />
                </footer>
            </form>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_warning">
        <field name="name">Warning</field>
        <field name="res_model">warning</field>
        <field name="view_type">form</field>
        <field name="view_mode">form</field>
        <field name="view_id" ref="warning_form" />
        <field name="target">new</field>
    </record>
</data>

</openerp>

and finally call the method

return self.pool.get('warning').info(cr, uid, title='Export imformation', message="%s products Created, %s products Updated "%(str(prod_new),str(prod_update)))
8
Avatar
Zrušit
Stefan Reisich

thank you very much.

Atchuthan - Technical Consultant, Sodexis Inc

Is this module available in launchpad/github?

Avatar
Andreas Maertens
Nejlepší odpověď

We made an addon to show warning messages and so on:

addon.py:

w_types = [('warning','Warning'),('info','Information'),('error','Error')]

class warning():
    ...
    _columns = {
        'title': fields.char(...),
        'message': fields.text(...),
    }
    _req_name = 'title'

    def _get_view_id(self, cr, uid):
        res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 
            'warning', 'warning_form')
        if res:
            return res[1]
        else:
            return False

    def message(self, cr, uid, id, context):
        message = self.browse(cr, uid, id)
        message_type = [t[1]for t in w_types if message.type == t[0]][0]
        res = {
            'name': '%s: %s' % (_(message_type), _(message.title)),
            'view_type': 'form',
            'view_mode': 'form',
            'view_id': self._get_view_id(cr, uid),
            'res_model': 'warning',
            'domain': [],
            'context': context,
            'type': 'ir.actions.act_window',
            'target': 'new',
            'res_id': message.id
        }
        return res

    def warning(self, cr, uid, title, message, context=None):
        id = self.create(... {'title': title, 'message': message, 'type': 'warning'})
        res = self.message(cr, uid, id, context)
        return res

    def info(self, cr, uid, title, message, context=None):
        ...
        return res

    def error(self, cr, uid, title, message, context=None):
        ...
        return res

and the view.xml:

        <record id="warning_form" model="ir.ui.view">
            ...
            <field name="arch" type="xml">
                <form string="Warning" version="7.0">
                    <field name="message"  nolabel="1" />
                    <footer>
                        <button string="OK" class="oe_highlight" special="cancel" />
                    </footer>
                </form>
            </field>
        </record>

        <record model="ir.actions.act_window" id="action_warning">
            ...
            <field name="view_id" ref="warning_form" />
            <field name="target">new</field>
        </record>

You may have to add functionallity to make it work as dialog.

        Just return this to a function that is called from client. 
        Usage:  return self.pool.get('warning').warning(cr, uid, title='Title', message='Text')
                                               .info(...)
                                               .error(...)

( this is an extract from a module made by our Team )

9
Avatar
Zrušit
Maniganda
Autor

how to include in my module

Andreas Maertens

Did it work for you?

Maniganda
Autor

ya its working and how to display a variable value with text

Andreas Maertens

You need to combine your text and values in one string: e.g. string = "value %s is wrong..."%str(value) You can also add new functionality to the module to do this. ;)

Maniganda
Autor

Thank you its working

Francesco OpenCode

Andreas: Why you don't release it as public module?

Andreas Maertens

We need to make clear, if our company releases the whole module. We come back on that.

Stefan Reisich

Does it works with create and write methods?

Stefan Reisich

I'm getting errors. Could you please tell me what i need to include at the "..."?

sepdau

didn't work in write or create function of object. Please help

Avatar
amine
Nejlepší odpověď

hello i have two date time field and i calculated difference both of them but sometimes i missed to enter date so it raise the error, but i want some msg instead of error can you please help me

0
Avatar
Zrušit
Atchuthan - Technical Consultant, Sodexis Inc

provide a default value for both the fields OR check whether the value is available at the field before calculating the difference

Víg János

Nice work, but I don't like to save the warning etc. to the database, only show it to my user, then drop it.

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

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
How to add pop up message or message box with message every button clicked? Vyřešeno
popup messagebox
Avatar
Avatar
1
pro 19
7579
Allowing Collapse and Expand the Body of message in Message Chatter
messagebox odoo12
Avatar
0
srp 19
4246
Is it possible to block the communication of 2 users within the odoo 16 messaging app?
message messagebox conversation
Avatar
0
srp 23
1947
Hide notifications after opening them
notifications chat messagebox chatbot
Avatar
0
kvě 21
4207
How to change the e-mail indexing in "Discuss"
messaging index messagebox odooV9
Avatar
0
led 16
4341
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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