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 hide a Sale Order Line based on "is_delivery"?

Suscribirse

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

Se marcó esta pregunta
attrsdomaintreeviewsale.order.line
4 Respuestas
9965 Vistas
Avatar
Travis Waelbroeck

I want to update the existing Sales Order Line tree view that is embedded in the default Odoo 9 Sales Order form view to hide a row based on a condition of the sales order line. 


View being modified: sale.view_order_form

<notebook>

<page string="Order Lines">

<field name="order_line" mode="tree,kanban" attrs="{'readonly': [('state', 'in', ('done','cancel'))]}">

...

<tree string="Sales Order Lines" editable="bottom" decoration-info="invoice_status=='to invoice'">

<field name="sequence" widget="handle"/>

<field name="product_id"/>

<field name="name"/>

...

<field name="is_delivery" invisible="1"/>

...


Generally, there is only one item which "is_delivery", so I still want to see the rest of the items for the order.


I have tried using domain and attrs but so far I haven't had any success whatsoever. I think it is because the view is using the sale.order model, but the embedded tree view is using records from sale.order.line?


How can I hide the line item if "is_delivery" is True?


1
Avatar
Descartar
Ali Mahmoud

have you found a way to do so?

GORTHI VEKATA LAXMANA SASTRY

I am in the exact same situation, how did you came over this problem?
Thanks in advance

Avatar
Qutechs, Ahmed M.Elmubarak
Mejor respuesta

Hello,

Just as a suggestion: try to add a new field to sale.order.line which is 'active', the active field toggle the global visibility of the record as in the documentation , and you can do some changes that when the order line set to is_delivery toTrue then set the active to False

hope this could helps

1
Avatar
Descartar
Avatar
Phong Vy
Mejor respuesta

I resolved it by adding the following function to sale.order, tested on v17, 18 and 19

class SaleOrder(models.Model):

    _inherit = "sale.order"

    def web_read(self, specification: dict[str, dict]) -> list[dict]:

        res = super().web_read(specification)

        for so_data in res:

            if so_data.get('order_line', False):

                order_line = [item for item in so_data['order_line'] if not item['is_delivery']]

                so_data['order_line'] = order_line

        return res

0
Avatar
Descartar
Avatar
D Enterprise
Mejor respuesta

Hii,

Inherit the sale.order model and add a computed One2many field:

from odoo import models, fields, api


class SaleOrder(models.Model):

    _inherit = 'sale.order'


    filtered_order_line = fields.One2many(

        comodel_name='sale.order.line',

        compute='_compute_filtered_order_line',

        string='Filtered Order Lines',

        store=False,  # not stored, always computed

    )


    @api.depends('order_line.is_delivery')  

    def _compute_filtered_order_line(self):

        for order in self:

            order.filtered_order_line = order.order_line.filtered(lambda l: not l.is_delivery)


Inherit the original Sales Order form view (sale.view_order_form) and replace the existing order_line field with your new computed field filtered_order_line.


<record id="view_order_form_hide_delivery" model="ir.ui.view">

    <field name="name">sale.order.form.hide.delivery.lines</field>

    <field name="model">sale.order</field>

    <field name="inherit_id" ref="sale.view_order_form"/>

    <field name="arch" type="xml">

        <xpath expr="//page[@string='Order Lines']/field[@name='order_line']" position="replace">

            <field name="filtered_order_line" mode="tree,kanban" attrs="{'readonly': [('state', 'in', ('done','cancel'))]}">

                <tree editable="bottom" string="Sales Order Lines">

                    <field name="sequence" widget="handle"/>

                    <field name="product_id"/>

                    <field name="name"/>

                    <field name="product_uom_qty"/>

                    <field name="price_unit"/>

                    <field name="tax_id"/>

                    <field name="price_subtotal"/>

                    <!-- Optional: include is_delivery as invisible just for context -->

                    <field name="is_delivery" invisible="1"/>

                </tree>

            </field>

        </xpath>

    </field>

</record>


i hope it is usefull



0
Avatar
Descartar
Avatar
LoreColon
Mejor respuesta

Interesting question! I've tackled similar visibility issues. One approach is customizing the view definition using XPath expressions based on the 'is_delivery' boolean. Another simpler method might be leveraging computed fields & conditional formatting within Odoo's interface. If you're a fan of puzzles, this is like a code-based  

-1
Avatar
Descartar
¿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
How to access a field of another model in a button with the attrs attribute?
attrs sale.order.line
Avatar
Avatar
1
mar 16
9159
How to use Domain in tree view? Resuelto
domain treeview
Avatar
Avatar
Avatar
3
mar 15
53417
attrs not working????
attrs treeview
Avatar
Avatar
Avatar
Avatar
Avatar
4
mar 15
12289
How to domain a tree view to make admin show all data but other role only specific?
domain treeview odoo16
Avatar
Avatar
1
jun 24
3231
What is diff between domain, domain filter and attr ?
filter attrs domain
Avatar
1
ene 24
16020
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