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
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Managament
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    Others
    • 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
  • Help

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

Move an ID to a transient model (second part)

Odoberať

Get notified when there's activity on this post

This question has been flagged
wizardapimodelodooV8
2 Replies
9358 Zobrazenia
Avatar
E.M.

I am trying to move an ID to a transient model.

Using NEW API. If old api is required, I would like to understand where it is being used and why.

With this code I get the new tree view displayed, but no ID is moved to stock_picking_id in the transient model, why?


So I have the following button defined in stock picking view to launch a wizard:

# -*- coding: utf-8 -*-
from openerp import models, fields, api
class StockPicking(models.Model):
        _inherit = "stock.picking"
        @api.multi
        def view_tree_label_picking(self):
                return {
                        'type': 'ir.actions.act_window',
                        'name': 'view_tree_label_picking',
                        'view_type': 'tree',
                        'view_mode': 'tree',
                        'res_model': 'label.picking',
                        'context': {'stock_picking_id': self.id},
                        'target': 'new',
                }


Then I have the following class defined for the wizard,

how do I retrieve stock_picking_id assigned from the button code?


XML:

<?xml version="1.0" encoding="utf-8" ?>
<openerp>
        <data>
                <record id="view_tree_label_picking" model="ir.ui.view">
                        <field name="name">Labels Dispatch Items Tree</field>
                        <field name="model">label.picking</field>
                        <field name="arch" type="xml">
                                <tree>
                                        <field name="stock_picking_id"/>
                                </tree>
                        </field>
                </record>
        </data>
</openerp>



Transient Model:

# -*- coding: utf-8 -*-
from openerp import models, fields, api
class LabelPicking(models.TransientModel):
        _name = "label.picking"
        _inherit = "stock.picking"
        stock_picking_id = fields.Many2one('stock.picking', string='Stock Picking', 
                readonly=True,
                default=lambda self: self.env.id)
0
Avatar
Zrušiť
Avatar
Qutechs, Ahmed M.Elmubarak
Best Answer

Hi,

try this :

stock_picking_id = fields.Many2one('stock.picking', string='Stock Picking',readonly=True, default=lambda self: self.env['stock.picking'].browse(self._context.get('stock_picking_id', False)))

I didn't test it , but it should work like that. If not just post your feedback to really test it ...

Regards

0
Avatar
Zrušiť
Avatar
Krupesh Laiya
Best Answer

you can pass stock_picking_id directly in to the context like :

return {
                        'type': 'ir.actions.act_window',
                        'name': 'view_tree_label_picking',
                        'view_type': 'tree',
                        'view_mode': 'tree',
                        'res_model': 'label.picking',
                        'context': {'default_stock_picking_id': self.id},
                        'target': 'new',
                }

if not working then please remove the readonly from the transientModel field and upgrade the database and try it will work.
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
How do you move an ID to a transient wizard model?
wizard model popup odooV8
Avatar
Avatar
Avatar
Avatar
9
feb 16
9545
How To Get selected invoices ids from a tree view using the new api ? Solved
api odooV8
Avatar
Avatar
Avatar
2
feb 22
6263
how can i add default image to wizard?? Solved
wizard odooV8
Avatar
Avatar
Avatar
Avatar
3
jún 19
5976
Developing new module. Recordset, how to filter by given id? Solved
module search api model odooV8
Avatar
Avatar
1
júl 18
4202
api.onchange v8 doesnt work Solved
api odooV8
Avatar
Avatar
2
sep 15
5487
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