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
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • 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

How to pass context from wizard to view and to and other action after?

Suscribirse

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

Se marcó esta pregunta
actionwizardviewcontextpass
2 Respuestas
45549 Vistas
Avatar
Pascal Tremblay

Hello all,

I have a new wizard who run well. This wizard allow user to choose a category.

When the user confirms the wizard, a new board.board view is started with the value of the choosen category in the context. Many graphs will be on this board according to the choosen category.

When the board.board view receive the context, how can it pass the context to the first graph action?

After this, how could the graph action use this context in its own domain?

I have a new field on stock.quant model (product_categ_id) and I want the first graph of my board only has quants with the category choosen by the user in the wizard.

Could you help please?


The wizard python (context has the choosen category in it) :

class wizard_choose_category(models.TransientModel):
    _name = 'wizard.choose.category'
    _description = 'Wizard that allow to choose a category'
    choose_category = fields.Many2one('product.category', string='Product category', domain=[('parent_id','!=', 1)])        #date = fields.Datetime('Date', default=fields.Datetime.now, required=True)        @api.multi    def open_table(self):
        self.ensure_one()
        ctx = dict(
            self._context,
            category=self.choose_category.id
            )
            
            res = {
            'domain': "[]",           
                'name': _('My dashboard by category'),
                'view_type': 'form',
                'view_mode': 'form',
                'res_model': 'board.board',
                'type': 'ir.actions.act_window',
                'context': ctx,
                'view_id': self.env.ref('vtm2_cavavin_inventory_graphs.inventory_by_category_form').id,
                'target': 'current',
            }

The view of boards (how to pass the received context to the called action?) :

<record id="inventory_by_category_form" model="ir.ui.view">
    <field name="name">Inventory dashboard form</field>
    <field name="model">board.board</field>
    <field name="arch" type="xml">
      <form string="Inventory dashboard">
            <board style="1-0">
                <column>
                    <action context="get.context()" string="Inventory pivot table"
                        name="%(action_inventory_pivot_1)d" />
                            
                </column>
            </board>
        </form>
    </field>
</record>


The action of the first graph (how to use the received context in the domain?) :

<record id="action_inventory_pivot_1" model="ir.actions.act_window">
            <field name="name">My inventory pivot #1</field>
            <field name="res_model">stock.quant</field>
            <field name="view_type">form</field>
            <field name="view_mode">graph</field>
            <field name="domain">[]</field>
            <field name="view_id" ref="inventory_pivot_1" />
        </record>


EDIT #1

I was certain that this line would work... But it is not the case...

<action string="Inventory of your choosen category - pivot table" name="%(action_inventory_pivot_1)d" 
    context="{'category': context.get('category')}" />



EDIT #2

With this line, all works fine. My graph displays all the quant from de category = 9. So the action tag of in a board view can pass the context to the called action. But the context.get() method doesn't seem to work in it...

<action string="Inventory of your choosen category - pivot table" name="%(action_inventory_pivot_1)d"
     context="{'category': 9}" />
4
Avatar
Descartar
Sehrish

How to to use context: http://learnopenerp.blogspot.com/2018/01/get-parent-form-value-in-one2many-form.html

Avatar
Pascal Tremblay
Autor Mejor respuesta

Here is our solution.


The action of the first graph (with the new domain who uses the context value) :

<record id="action_inventory_pivot_1" model="ir.actions.act_window">
            <field name="name">My inventory pivot #1</field>
            <field name="res_model">stock.quant</field>
            <field name="view_type">form</field>
            <field name="view_mode">graph</field>
            <field name="domain">[('product_category_id','=',context.get('category'))]</field>
            <field name="view_id" ref="inventory_pivot_1" />
        </record>


And we use Python to override the context of the board.board action because it doesn't want to understand context.get() method.

from lxml import etree

class board_board(osv.osv):
    _inherit = 'board.board'
    def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):

        result = super(board_board,self).fields_view_get(cr, user, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
       
        doc = etree.XML(result['arch'])
       
        for node in doc.xpath("//action"):
            set_context = "{'choosen_category': %s}" % context.get('category')
            node.set("context", set_context)
                result["arch"] = etree.tostring(doc)
        
        return result




3
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 to disable wizard call in specific views ?
action wizard view
Avatar
0
mar 15
4665
How to pass context to a called action with kanban view links or buttons? Resuelto
action view kanban context
Avatar
Avatar
1
oct 21
19266
Triggering an action from a function?
action function wizard trigger view
Avatar
Avatar
Avatar
2
mar 15
12653
How to use the previous context in the action definition? Resuelto
action context
Avatar
Avatar
1
abr 25
4371
Problem with opening full composer in send message
action wizard
Avatar
0
ene 25
1996
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