Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

How to hide a Sale Order Line based on "is_delivery"?

Odebírat

Get notified when there's activity on this post

This question has been flagged
attrsdomaintreeviewsale.order.line
4 Odpovědi
9925 Zobrazení
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
Zrušit
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
Nejlepší odpověď

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
Zrušit
Avatar
Phong Vy
Nejlepší odpověď

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
Zrušit
Avatar
D Enterprise
Nejlepší odpověď

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
Zrušit
Avatar
LoreColon
Nejlepší odpověď

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
Zrušit
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
How to access a field of another model in a button with the attrs attribute?
attrs sale.order.line
Avatar
Avatar
1
bře 16
9125
How to use Domain in tree view? Vyřešeno
domain treeview
Avatar
Avatar
Avatar
3
bře 15
53347
attrs not working????
attrs treeview
Avatar
Avatar
Avatar
Avatar
Avatar
4
bře 15
12235
How to domain a tree view to make admin show all data but other role only specific?
domain treeview odoo16
Avatar
Avatar
1
čvn 24
3170
What is diff between domain, domain filter and attr ?
filter attrs domain
Avatar
1
led 24
15981
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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