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

Odoo 10 | How to pass context from "ir.actions.act_window.view" to one2many field

Suscribirse

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

Se marcó esta pregunta
openerpodoo10.0
14926 Vistas
Avatar
Wiem

Hi,

in account.invoice i have done:

class AccountInvoice(models.Model):

    _inherit = "account.invoice"

   invoice_type = fields.Selection([

            ('simple_invoice','Simple Invoice'),

            ('progress_invoice','Progress Invoice'),

        ], string = "Invoice Type", readonly=True, index=True, change_default=True,

        default=lambda self: self._context.get('invoice_type', 'simple_invoice'),

        track_visibility='always')

class AccountInvoiceLine(models.Model):    

    _inherit = "account.invoice.line"

    amount_net_ht = fields.Monetary(string='Amount Net of the month HT', store=True, readonly=True)

    previous_amount_ht = fields.Monetary(string='Previous Cumulative amount HT', store=True, readonly=True)


in xml i made new action and new menuitem for that action that displays account invoice form for progress_invoice type that i added : 

<record id="account.action_invoice_tree1" model="ir.actions.act_window">

            <field name="name">Simple Invoices</field>

            <field name="res_model">account.invoice</field>

            <field name="view_type">form</field>

            <field name="view_mode">tree,kanban,form,calendar,pivot,graph</field>

            <field eval="False" name="view_id"/>

            <field name="domain">[('type','in',['out_invoice', 'out_refund']), ('invoice_type','=','simple_invoice')]</field>

            <field name="context">{'type':'out_invoice', 'journal_type': 'sale'}</field>

            <field name="search_view_id" ref="account.view_account_invoice_filter"/>

            <field name="help" type="html">

              <p class="oe_view_nocontent_create">

                Click to create a simple invoice.

              </p>

            </field>

        </record>

        

        <record id="action_situation_invoice" model="ir.actions.act_window">  # new action added for Progress Invoice

            <field name="name">Progress Invoices</field>

            <field name="res_model">account.invoice</field>

            <field name="view_type">form</field>

            <field name="view_mode">tree,kanban,form,calendar,pivot,graph</field>

            <field eval="False" name="view_id"/>

            <field name="domain">[('type','in',['out_invoice', 'out_refund']), ('invoice_type','=','progress_invoice')]</field>

            <field name="context">{'invoice_type':'progress_invoice'}</field> 

            <field name="search_view_id" ref="account.view_account_invoice_filter"/>

            <field name="help" type="html">

              <p class="oe_view_nocontent_create"> 

                Click to create a progress invoice.

              </p>

            </field>

        </record>


        <record id="action_situation_invoice_view1" model="ir.actions.act_window.view">

            <field eval="1" name="sequence"/>

            <field name="view_mode">tree</field>      

            <field name="view_id" ref="account.invoice_tree"/>

            <field name="act_window_id" ref="action_situation_invoice"/>

        </record>


        <record id="action_situation_invoice_view2" model="ir.actions.act_window.view">

            <field eval="2" name="sequence"/>

            <field name="view_mode">form</field>

            <field name="view_id" ref="account.invoice_form"/>

            <field name="act_window_id" ref="action_situation_invoice"/>

        </record>

Now what i want is when in tree field i want to show 

Now, i want to show the two fields amount_net_ht and previous_amount_ht (added in account.invoice.line) in invoice_line_ids when  invoice_type is progress_invoice and hide them when  invoice_type is simple_invoice. For that i added context in the action of Progress Invoice and using xpath i did:

<xpath expr="//form/sheet/notebook/page/field/tree/field[@name='price_subtotal']" position="after">

            <field name="cumulative_amount_ht" invisible="context.get('invoice_type','simple_invoice')"/>

                        <field name="previous_amount_ht" invisible="context.get('invoice_type','simple_invoice')"/>

                        <field name="amount_net_ht" invisible="context.get('invoice_type','simple_invoice')"/>

</xpath>


but this does not work, the two field are always shown in Simple invoice form ( not in progress invoice like i want)

I know i can achieve this by creating completely new form for Progress Invoice ( similar to the default odoo invoice form ) and adding to it the new fields but it would be a lot of duplicated code. So i want to achieve this with context if it is possible.

Thanks. 

0
Avatar
Descartar
Wiem
Autor

Problem solved, from here i get the answer : http://vitraining.com/show-hide-columns-in-openerp-tree-view-xml/

¿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
Chinese(HK) Language Pack Resuelto
openerp odoo10.0
Avatar
Avatar
1
oct 18
7627
count number of records based on condition Resuelto
odoo10.0
Avatar
Avatar
1
nov 24
21091
How to install odoo 10 in ubuntu 20.04? Resuelto
odoo10.0
Avatar
Avatar
1
sept 23
3919
Create selection type field dynamically?
openerp
Avatar
Avatar
Avatar
2
sept 23
8517
Question about action_confirm
odoo10.0
Avatar
Avatar
Avatar
3
may 23
6497
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