Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Food & Hospitality
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Guest House
    • Distribuidor de bebidas
    • Hotel
    Real Estate
    • Real Estate Agency
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consulting
    • Accounting Firm
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Trades
    • Handyman
    • Hardware y asistencia informática
    • Solar Energy Systems
    • Zapatero
    • Servicios de limpieza
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Move an ID to a transient model (second part)

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
wizardapimodelodooV8
2 Respuestas
9369 Vistas
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
Descartar
Avatar
Qutechs, Ahmed M.Elmubarak
Mejor respuesta

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
Descartar
Avatar
Krupesh Laiya
Mejor respuesta

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
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
How do you move an ID to a transient wizard model?
wizard model popup odooV8
Avatar
Avatar
Avatar
Avatar
9
feb 16
9554
How To Get selected invoices ids from a tree view using the new api ? Resuelto
api odooV8
Avatar
Avatar
Avatar
2
feb 22
6307
how can i add default image to wizard?? Resuelto
wizard odooV8
Avatar
Avatar
Avatar
Avatar
3
jun 19
5983
Developing new module. Recordset, how to filter by given id? Resuelto
module search api model odooV8
Avatar
Avatar
1
jul 18
4209
api.onchange v8 doesnt work Resuelto
api odooV8
Avatar
Avatar
2
sept 15
5536
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

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