Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing-
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

How to invisible "Add a lines" button with conditions in order line odoo version18?

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
developmentrecieptcustomizeodoo18
2 Antworten
512 Ansichten
Avatar
PhongsakornChe
I am in odoo18 and currently on the Receipt page. At the bottom section of this page, there is a tab called Operations which contains the product lines. I want to make this entire section read-only except for the hamburger icon (the “lot” action button) that allows adding lots to the products.



In hamburger button:


First, I used this code to make the entire section read-only, but it also disabled the hamburger icon, so I could not add lots at all:

<xpath expr="//field[@name='move_ids_without_package']" position="attributes">
    <attribute name="readonly">
        state == 'done' or approval_editable_has_po != 'edit_approved'
    </attribute>
    <attribute name="force_save">1</attribute>
</xpath>

Then, I changed the code by setting each individual column to read-only, leaving only the hamburger icon editable:

<xpath expr="//field[@name='move_ids_without_package']/list/field[@name='product_id']" position="attributes">
    <attribute name="readonly">parent.state == 'done' or parent.approval_editable_has_po != 'edit_approved'</attribute>
    <attribute name="force_save">1</attribute>
</xpath>

(…and similar XPaths for other columns)

The result is: all columns are read-only, so users cannot add new products — which is correct — and the hamburger icon still works, which is also what I want.

However, I also want to hide the “Add a line” button.

I tried:


<xpath expr="//field[@name='move_ids_without_package']/list" position="attributes">
    <attribute name="create">0</attribute>
</xpath>

This hides Add a line, but it disappears permanently.


Then I tried adding conditions:

<xpath expr="//field[@name='move_ids_without_package']/list" position="attributes">
    <attribute name="create">
        parent.state != 'done' or parent.approval_editable_has_po == 'edit_approved'
    </attribute>
</xpath>


But this does not work — look like the create attribute seems to accept only True/False/1/0 and ignores domain-like expressions.

My question is:

Is it possible to hide the “Add a line” button conditionally (based on state and approval fields) while still keeping the hamburger icon editable?

0
Avatar
Verwerfen
Avatar
Vashmitha V
Beste Antwort

Hello there,

Check this,

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_picking_form_inherit_restrict_new" model="ir.ui.view">
<field name="name">stock.picking.restrict.new</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='move_ids_without_package']" position="attributes">
<attribute name="options">{'create':[('state','not in',['done','cancel'])]}</attribute>
</xpath>
</field>
</record>
</odoo>


Hope this helps you.

0
Avatar
Verwerfen
Avatar
Kunjan Patel
Beste Antwort
Hello PhongsakornChe
I hope you are doing well

Yes, but it requires JavaScript (Odoo 18)

XML alone cannot do this - create attribute only accepts True/False, not conditions.

Solution: JavaScript + XML
static/src/js/list_renderer.js
  /** @odoo-module **/
  import { patch } from "@web/core/utils/patch";
  import { ListRenderer } from "@web/views/list/list_renderer";

  patch(ListRenderer.prototype, {
      get canCreate() {
          const ctx = this.props.list.context;
          // Hide "Add a line" when state is done AND not edit_approved
          if (ctx.parent_state === 'done' && ctx.parent_approval !== 'edit_approved') {
              return false;
          }
          return super.canCreate;
      }
  });

views/stock_picking_view.xml (pass context)
  <xpath expr="//field[@name='move_line_ids']" position="attributes">
      <attribute name="context">{
          'parent_state': parent.state,
          'parent_approval': parent.approval_editable_has_po
      }</attribute>
  </xpath>

  __manifest__.py
  'assets': {
      'web.assets_backend': [
          'your_module/static/src/js/list_renderer.js',
      ],
  },

I hope this information helps you

Thanks & Regards
Kunjan Patel
0
Avatar
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
Chatter in Odoo 18 Gelöst
development chatter odoo18
Avatar
Avatar
1
Okt. 25
7259
Delete Fields From POS receipt
development pos reciept
Avatar
Avatar
Avatar
2
Okt. 22
3948
Customizing Payroll Features in Odoo 17 Community Edition
development payroll customize odoo17CE
Avatar
0
Aug. 24
5
How to increment stock in product page Odoo 18
development stock product odooonline odoo18
Avatar
Avatar
Avatar
2
März 25
1710
Custom Addons Odoo 17
development server addons customize odoo17
Avatar
Avatar
1
Juni 24
2339
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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