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

How to open a record in new tab with a context ?

Odoberať

Get notified when there's activity on this post

This question has been flagged
newtabcontexturlopenv15
5 Replies
5614 Zobrazenia
Avatar
Dilaw bedj

Hi , please i want to know how to open a form view of another model on a new tab of the the browser by clicking on a button and passing it context

0
Avatar
Zrušiť
Avatar
Yahoo Baba Innovations Pvt.Ltd
Best Answer

Hi  Dilaw Bej ,


It will open a new window or tab with the URL provided in the link. Here is a slightly refined version:

return {
​ 'name': 'Go to New Window',
​ 'res_model': 'ir.actions.act_url', 'type': 'ir.actions.act_url', 'url': link, # Your URL here
  ​ 'context': context, 'target': 'new', # Opens in a new window/tab }

A few things to note:

  • 'res_model': 'ir.actions.act_url' is not needed. The 'type': 'ir.actions.act_url' already specifies that it's a URL action.
  • 'context': ctx is not required unless you specifically need to pass context for this URL. If you need it, ensure that ctx is defined beforehand. If not, you can remove this part.

Let me know if you need further modifications!


Thank you

1
Avatar
Zrušiť
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

Let's say you have a model called model1 and you want to open a form view of another model model2 in a new tab when a button is clicked. Here are the steps:

add a button to trigger the action:

<record id="view_my_model_form" model="ir.ui.view">
    <field name="name">my.model.form</field>
    <field name="model">my.model</field>
    <field name="arch" type="xml">
        <form>
            <!-- Your existing fields go here -->
            <footer>
                <button string="Open Other Model" class="oe_highlight" type="object" name="open_other_model"/>
            </footer>
        </form>
    </field>
</record>


python :

from odoo import models, fields, api

class MyModel(models.Model):
_name =model1'

# Your existing fields go here

@api.multi
def open_other_model(self):
    # You can pass context by defining a dictionary
    context = {
        'default_field_name': 'default_value',
        'additional_context_key': 'additional_context_value',
    }

    # Open the form view of the other model in a new tab
    return {
        'name': 'Other Model Form',
        'type': 'ir.actions.act_window',
        'res_model': 'model2',
        'view_mode': 'form',
        'view_id': self.env.ref('other_module.view_other_model_form').id,  # Replace with the actual view ID
        'target': 'new',
        'context': context,
    }


Create model 2 Python and xml files 


Hope it helps

1
Avatar
Zrušiť
Avatar
SunArc Technologies
Best Answer

Hi,

You can open record in new tab with below code if your problem still not fixed.

class YourClass1(models.Model):

    _name = 'model1'

   

    def action_open_record_new_tab(self):

        record_id = # define your record id to open record

        model = 'model2'  # Replace with the actual model name

        # Construct the URL to open the record in a new tab

        url = '/web#id=%s&model=%s' % (record_id, model)

        # You Can add context for passing values

​context = {

​ }

        # Redirect to the URL

        return {

            'type': 'ir.actions.act_url',

            'url': url,

            'target': 'new',  # Open in a new tab/window

            'context': context,

        }

 

In XML define button for method.


Thanks

0
Avatar
Zrušiť
Avatar
Sun Southern
Best Answer

if partner has already you can use below code:

base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') url = f"{base_url}/web#id={partner_Id}&model=res.partner&view_type=form"

return { 'type': 'ir.actions.act_url', 'url': url, 'target': '_blank' }

here is my code in odoo 17 model res.partner. hope it be can help you!

0
Avatar
Zrušiť
Avatar
Dilaw bedj
Autor Best Answer

But in this case it will open the second model as a wizard/pop-up ans not in a browser's new tab

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
Help ! How to open a view in new tab with context
newtab context open v15
Avatar
Avatar
1
jan 24
3148
How to open a record in new tab with a context ?
newtab context record url open
Avatar
Avatar
1
jan 24
2350
Odoo Window action apply multiple filters
context filters v15
Avatar
0
mar 24
2446
Context group_by and order
context groupby v15
Avatar
1
okt 22
4103
Odoo 15 - pre-fill field in one2many form
form context v15
Avatar
0
aug 22
3944
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