Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

How to display dialog box

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
messagebox
19 Besvarelser
50796 Visninger
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
Kassér
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
Forfatter Bedste svar

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
Kassér
Stefan Reisich

thank you very much.

Atchuthan - Technical Consultant, Sodexis Inc

Is this module available in launchpad/github?

Avatar
Andreas Maertens
Bedste svar

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
Kassér
Maniganda
Forfatter

how to include in my module

Andreas Maertens

Did it work for you?

Maniganda
Forfatter

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
Forfatter

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
Bedste svar

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
Kassér
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!

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
How to add pop up message or message box with message every button clicked? Løst
popup messagebox
Avatar
Avatar
1
dec. 19
7566
Allowing Collapse and Expand the Body of message in Message Chatter
messagebox odoo12
Avatar
0
aug. 19
4236
Is it possible to block the communication of 2 users within the odoo 16 messaging app?
message messagebox conversation
Avatar
0
aug. 23
1925
Hide notifications after opening them
notifications chat messagebox chatbot
Avatar
0
maj 21
4204
How to change the e-mail indexing in "Discuss"
messaging index messagebox odooV9
Avatar
0
jan. 16
4335
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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