Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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

How to pass active id to a popup

Suscribirse

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

Se marcó esta pregunta
context7.0active_id
2 Respuestas
15549 Vistas
Avatar
Luis Filipe Castanheira

Hi, I am trying to pass the active id to a popup window so that in my function I can access the actual state of the caller object.

For that, I'm doing the following. In XML view:

<page string="Opinions">
    <field name="opinion_ids" context="{'generic_request_id': active_id}" >
        <tree delete="false"> 
            <field name="request_state" />
            <field name="opinion_request_date" />
            <field name="requestor" />
        (...)

In python I have:

_defaults={
    'state': 'requested',
    'opinion_request_date': lambda *a: datetime.date.today().strftime('%Y-%m-%d'),
    'request_state': lambda self, cr, uid, context: self._get_request_state(cr, uid, context=context), #store the state of the request when opinion was asked
    (...)
}
(...)
def _get_request_state(self, cr, uid, context=None):
    ids = context.get('generic_request_id', False)
    #import pdb; pdb.set_trace()        
    return self.pool.get('generic.request').browse(cr, uid, ids, context).state

In pdb I realize that "ids" is False because there is no generic_request_id variable in context...

(Pdb) p ids
False

(Pdb) p context
{'lang': 'en_US', 'no_store_function': True, 'tz': False, 'uid': 1}

Anyone knows a way to do this?

0
Avatar
Descartar
Avatar
Luis Filipe Castanheira
Autor Mejor respuesta

I finally managed to solve this in a very tortuous way. If anyone has a more straight forward way to do this, please help!

So, what I did was, create and save the opinion request and, in the function called by the workflow (request_opinion), I call an other function that checks the id of the request associated to this opinion an then it's actual state and, finally, updates the value in the opinion table.

Here is the code:

class opinion(osv.osv):
    _name='opinion'
    _description='opinion'
    _columns={
    (...)
        'state': fields.selection([('requested','Requested'),
            ('reviewing','Reviewing'),
            ('issued','Issued'),
            ('added','Added to the request')],
            'Status', readonly=True, track_visibility='onchange',
        ),
    (...)
        'request_state': fields.selection([('draft','Draft'),
            ('submitted','Submitted - Waiting for confirmation'),
            ('req_reformulation', 'Reformulation'),
            ('confirmed', 'Confirmed - Processing'),
            ('treatment', 'Processing'),
            ('wauth', 'Awaiting authorization'),
            ('wappr', 'Awaiting approval'),
            ('authorized','Authorized'),
            ('closed', 'Request closed'),
            ('closed_auth', 'Closed - Authorized'),
            ('closed_appr', 'Closed - Approved'),
            ('closed_disappr', 'Closed - Disapproved'),
            ('closed_nconf', 'Closed - Not confirmed'),
            ('closed_ref', 'Closed - Refused'),
            ('denied','Denied')],
            'Request Status', help="Status of the request when the opinion was requested", readonly=True, track_visibility='onchange',
        ),
        'generic_request_id': fields.many2one('generic.request', 'Request', required=True),
    }

    def _get_request_state(self, cr, uid, ids, context=None):
        res={}
        op = self.browse(cr, uid, ids, context=context)
        req_id = op[0].generic_request_id.id
        req = self.pool.get('generic.request').browse(cr, uid, req_id, context)
        #import pdb; pdb.set_trace()
        self.write(cr, uid, ids, {'request_state': req.state })
        return True

    def request_opinion(self, cr, uid, ids, context=None):
        self.write(cr, uid, ids, {'state': 'requested'})
        self._get_request_state(cr, uid, ids, context=context)
        return True

As I said before, if someone has a better sugestion to do this a more effective way, feel free to share!


Edit:

Changed it to be a little more effective (no need to call the _get_request_state() anymore). But still if anyone has better way to do this, fill free to share!

def request_opinion(self, cr, uid, ids, context=None):
    self.write(cr, uid, ids, {'state': 'requested', 'request_state': self.browse(cr, uid, ids, context=context)[0].generic_request_id.state })
    #self._get_request_state(cr, uid, ids, context=context)
    return True
0
Avatar
Descartar
Avatar
Weste
Mejor respuesta

I think you have to put your context="{'generic_request_id': active_id}" in the button that calls the wizard.

0
Avatar
Descartar
Luis Filipe Castanheira
Autor

Thanks for the quick answer, but in this case I have no buttons... The popup is opened by the "Add an item" present in the tree view of the page refering to "opinion" in my "generic request" form view.

¿Le interesa esta conversación? ¡Participe en ella!

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

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Not getting selected records from active_ids, returns empty list
pdf context active_id env
Avatar
0
sept 23
2000
Using both ref and active_id at once in record field? Resuelto
refrence context active_id eval
Avatar
1
ene 22
9066
context not work ???
context
Avatar
Avatar
1
ene 25
2095
How to get Active_id after url action
action context url active_id Actions
Avatar
Avatar
1
abr 24
2589
how to pass context from XML to JavaScript?
javascript xml context active_id pass
Avatar
Avatar
Avatar
2
dic 23
13596
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar 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