Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Sociale media-marketing
    • E-mailmarketing
    • Sms-marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

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

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
developmentrecieptcustomizeodoo18
2 Antwoorden
508 Weergaven
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
Annuleer
Avatar
Vashmitha V
Beste antwoord

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
Annuleer
Avatar
Kunjan Patel
Beste antwoord
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
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
Chatter in Odoo 18 Opgelost
development chatter odoo18
Avatar
Avatar
1
okt. 25
7257
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
mrt. 25
1710
Custom Addons Odoo 17
development server addons customize odoo17
Avatar
Avatar
1
jun. 24
2339
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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