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

Hide Rows in Tree inside Form View

Suscribirse

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

Se marcó esta pregunta
invoiceinvoice.line
2 Respuestas
11867 Vistas
Avatar
Mick Radakovic

I'm trying to hide the invoice lines where quantity is set to 0, so I edited account.invoice.form view, and tried with:

...
<page string="Invoice Lines">
  <field name="invoice_line" nolabel="1" widget="one2many_list" domain="[('quantity', '&gt;', 0)]">
    <tree string="Invoice Lines" editable="bottom">
      <field name="sequence" widget="handle"/>...

But this doesn't have any effect at all. No matter what I put into domain, the list remains the same.

Please advise. Thanks!

0
Avatar
Descartar
Avatar
Denis Baranov
Mejor respuesta

Hi!

Using domain would not lead you to required behavior. In case of tables it is used in case of many2many fields in order to restrict selection, not visibility of rows. So, it is a constraint to choose records

If I'm not mistaken, the only way to achieve the desired requirement, is to re-define the functions on the Python level. 

I guess, there are 2 alternatives:

1. TO re-define the get method of a related model. Technically better, but may influence other places, where lines are used in the interface

2. To create a new computed table, where to put only desired lines, and inverse them in original method. This is logically simplier, e.g.:

To the model account invoice:

@api.multi def _compute_new_line_ids(self)

for invoice in self:

 new_ids = invoice.line_ids.filtered(

                lambda t: t.quantity > 0,

            )

 invoice.new_line_ids = [(6,0,new_ids.ids )]

 new_ids = invoice.line_ids.filtered(

                lambda t: t.quantity == 0,

            )

 invoice.new_line_ids_zero = [(6,0,new_ids.ids )]

@api.multi def _inverse_new_line_ids(self):

for invoice in self:

invoice.line_ids = [(6,0,invoice.new_line_ids + invoice.new_line_ids_zero)]

new_line_ids = fields.One2many(

"account.invoice.line",

"invoice_new_id",

compute=_compute_new_line_ids,

inverse=_inverse_new_line_ids,

string="Invoice Lines) # invoice_new_id - is a new back reference in line model

new_line_ids_zero = fields.One2many(

"account.invoice.line",

"invoice_new_id_2",

compute=_compute_new_line_ids,

inverse=_inverse_new_line_ids,

string="Invoice Lines) # invoice_new_id_2 - is a new back reference in line model

On a xml form replace line_ids with new_line_ids


1
Avatar
Descartar
Denis Baranov

Depending on your requirements, it may be better not to just hide, but remove the lines. Just add inverse to line_ids, and in this function remove zero lines. It would be updated each time you create or write a record

عمر ابو ضيف

can you explain further, why you made two o2m fields
why did you make two different inverses,
how exactly are you going to replace the o2m in XML in this case?

Avatar
Salih Kalender
Mejor respuesta

You can write domain in the field you defined.

doctor_ids = fields.Many2many('example.a', 'example_a_b_rel', 'example_a_id', 'example_b_id', domain="[('is_doctor', '=', True)]")

0
Avatar
Descartar
Arian Shariat

This doesn't hide the filed. It prevents it to be created at the first place.

¿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
Item and Description Lines Not Showing When Invoice is Printed Resuelto
invoice invoice.line
Avatar
Avatar
Avatar
3
feb 24
4870
how can i make some space for a field in the invoice lines
invoice invoice.line
Avatar
0
may 16
4281
merge invoice lines by product when convert from multiple sales orders
invoice invoice.line sales.order
Avatar
Avatar
Avatar
Avatar
4
feb 25
8119
Fixed shipped costs are invoiceable when sale order is confirmed
invoice invoice.line shipping_cost
Avatar
Avatar
Avatar
2
feb 22
3929
Odoo 14 @api.onchange from a field of another class Resuelto
invoice onchange invoice.line
Avatar
Avatar
1
ene 22
4981
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