Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Confirming a dialogue box on a condition and with dynamic text in openerp

Odoberať

Get notified when there's activity on this post

This question has been flagged
messageconfirmationpopupdialogue
2 Replies
16915 Zobrazenia
Avatar
vivek

I found that the below pops me up a confirmation dialogue on button press action in openerp

<button name="action_button_confirm" states="draft" string="Confirm Sale" 
type="object" groups="base.group_user" confirm="Do you confirm this sale?"/>

I would like the confirm text to be displayed only if one of the products in the orderlines is service and the text should be

Do you like to confirm sale with service "AC Service"?

Where Ac Services is the service product name (i.e dynamic text based on the orderlines). Kindly suggest me a way to do this. Thanks

1
Avatar
Zrušiť
Avatar
vivek
Autor Best Answer

I've created a wizard for alert on a condition and that does a good job to me. For people with similar prob i am placing my idea below

My New Wizard class

class sale_order_confirm(osv.osv):
    _name = "sale.order.confirm"
    _description = "Sales Order Confirm"
    def action_confirm(self, cr, uid, ids, context=None):
        assert len(ids) == 1, 'This option should only be used for a single id at a time.'
        wf_service = netsvc.LocalService('workflow')
        wf_service.trg_validate(uid, 'sale.order', ids[0], 'order_confirm', cr)

        # redisplay the record as a sales order
        view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form')
        view_id = view_ref and view_ref[1] or False,
        return {
            'type': 'ir.actions.act_window',
            'name': _('Sales Order'),
            'res_model': 'sale.order',
            'res_id': ids[0],
            'view_type': 'form',
            'view_mode': 'form',
            'view_id': view_id,
            'target': 'current',
            'nodestroy': True,
        }
sale_order_confirm()

My view record

<record id="view_cancel_order" model="ir.ui.view">
            <field name="name">Cancel Repair</field>
            <field name="model">sale.order.confirm</field>
            <field name="arch" type="xml">
                <form string="Confirm Sale Order" version="7.0">
                    <group>
                        <label string="This Sale Order will be confirmed with service Product. Agree?"/>
                    </group>
                    <footer>
                        <button name="action_confirm" string="Yes" type="object" class="oe_highlight"/>
                        or
                        <button string="Cancel" class="oe_link" special="cancel" />
                    </footer>
                </form>
            </field>
        </record>

I've changed my action_button_confirm function in the sale_order.py slightly

def action_button_confirm(self, cr, uid, ids, context=None):
        assert len(ids) == 1, 'This option should only be used for a single id at a time.'
        is_optional_item_exists = False    # here i can check for wt ever condition and this variable will have the resul
        so_obj = self.browse(cr, uid, ids, context)
        if so_obj:
            for line in so_obj[0].order_line:
                print line.name
                if line.is_optional_item:
                     is_optional_item_exists = True

        if(is_optional_item_exists):
            return {
                'name': 'Order Confirmation',
                'view_type': 'form',
                'view_mode': 'form',
                'res_model': 'sale.order.confirm',
                'type': 'ir.actions.act_window',
                'nodestroy': True,
                'target': 'new',
                }
        else:
            wf_service = netsvc.LocalService('workflow')
            wf_service.trg_validate(uid, 'sale.order', ids[0], 'order_confirm', cr)

            # redisplay the record as a sales order
            view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form')
            view_id = view_ref and view_ref[1] or False,
            return {
                'type': 'ir.actions.act_window',
                'name': _('Sales Order'),
                'res_model': 'sale.order',
                'res_id': ids[0],
                'view_type': 'form',
                'view_mode': 'form',
                'view_id': view_id,
                'target': 'current',
                'nodestroy': True,
            }

Thanks All and Cheers!!

1
Avatar
Zrušiť
Avatar
Ximo
Best Answer

My problem was similar, I solved this way... I create a bolean field that its true or false depending of a many2one; if this many2one have records my boolean field is false and change the button depending this field...

 xml
     ...
        <header>
             <button string="Confirmar Devolucion" type="object" name="accion_confirmar_devolucion" class="oe_highlight" attrs="{'invisible':['|',('devol_vacio', '==', False),('state','!=','sent')]}"/>
             <button string="Confirmar Devolucion" type="object" name="accion_confirmar_devolucion" class="oe_highlight" attrs="{'invisible':['|',('devol_vacio', '!=', False),('state','!=','sent')]}" confirm="No hay productos en las devoluciones, ¿desea continuar?"/>
        </header>
        <div name="general" attrs="{'readonly': [('state', '==', 'cancel')]}">
           <separator string="Datos Generales"/>
              <group name="General">
                <field name="devol_vacio" invisible="1"/>
                <field name="devol_ids" on_change="onchange_devol_ids(devol_ids)"/>
        ...


    py

    ...
    columns={
    ...
    'devol_vacio'       : fields.boolean('devol_vacio'),
    ...}

    defaults={'devol_vacio'       :False}


    def onchange_devol_ids(self, cr, uid, ids, campo=False context=None):
            '''
            bla bla bla devol_ids change

            :param cr: Fila actual, para el cursor de la base de datos.
            :param uid: Id del usuario actual. Se utiliza para comprobaciones de seguridad.
            :param ids: Lista de ids del modelo sale.order.
            :param context: openerp request context.
            :return: {}
            '''
            val={}
            if campo != False:
                if campo!=[]:
                    val['devol_vacio']=True
                else:
                    val['devol_vacio']=False
            if val:
                return {'value':val}
            return {}
0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Showing popup without stoping function Solved
message python popup 13
Avatar
Avatar
1
dec 22
16662
JavaScript, how to show a popup message at record saving?
javascript message js popup controllers
Avatar
Avatar
1
mar 23
5863
Inquiry About Odoo Educational License and Free Access to Educational Program Solved
message
Avatar
Avatar
1
aug 25
1426
How to make pop ups after actions? Solved
popup
Avatar
Avatar
Avatar
2
júl 25
10029
"Something went wrong... " in new database
message
Avatar
Avatar
1
jún 25
2188
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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