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
    • Social 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 truncate text field ?

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
fieldsxmlviewwidgettruncate
2 Antwoorden
18953 Weergaven
Avatar
HIGHCO - Nicolas Clavier

Hi folks,

Is there a way to truncate text of a fields.text() (in tree view especially), so that lines aren't huge in height ? I was thinking of a widget attribute in xml maybe ?

Thanks for your time. Nicolas

5
Avatar
Annuleer
Avatar
Quentin THEURET
Beste antwoord

You can use a fields.function with type='char'. The function to compute this field will give the fields.text value and truncate it.

Then, in the tree view, if you want the whole text, you display the fields.text otherwise, display the fields.function.

3
Avatar
Annuleer
HIGHCO - Nicolas Clavier
Auteur

Hi, thanks for the trick. it's a good work around if you are not willing to have inline editing (e.i. editable="bottom"). Because we can't have an editable function field.

Yannick Payot

This is not true, you can define the parameter fnct_inv to create the write method of function field. However, in your case I agree that it wouldn't be conveniant as you would need a truncated field only in view mode and a full text in edit mode. A widget might be the best choice.

HIGHCO - Nicolas Clavier
Auteur

I stumbled upon fnct_inv this morning to find that out .. how do you mean "a widget" .. writing a widget ?

Yannick Payot

Yes it is what I meant. Creating a widget that extends the base text widget and hides parts of the text only in view mode.

HIGHCO - Nicolas Clavier
Auteur

I'm ok to get into writing widgets but have no time for now. Would it be complex ? Any link examples / repo ?

HIGHCO - Nicolas Clavier
Auteur

I'm marking this answer as a solution because in the end it's the only quick way to achieve this. Except that the list view won't be editable inline. I'll show the function field inline, and the original text field in the form. Thank @all

Avatar
Cyril Gaspard (GEM)
Beste antwoord

Hi, there is a function which do that in 6.0, function truncate_data, you can find it here :

http://bazaar.launchpad.net/~openerp/openobject-addons/6.0/view/head:/mail_gateway/mail_gateway.py

update with new informations given by comment after :

if you can have status of the page, editable or browse, you can use function I gave before :

create a new field text which is updated by onchange with first you are already created.

in tree view in function of state of the page (editable or browse), one is visible, the second no.

Bye

3
Avatar
Annuleer
HIGHCO - Nicolas Clavier
Auteur

Hi, thanks for pointing this out to me but the idea here is to have a text field that can be fully edited inline, and that only shows so many characters when in browse mode. If the behavior doesn't exist, I'll post a feedback on http://feedback.openerp.com. These features are lacking, along with placeholders, rich text, etc.

Cyril Gaspard (GEM)

I update my answer

HIGHCO - Nicolas Clavier
Auteur

ok, sounds like the answer I was looking for. Still have to detect the field/view state, any hint ? is it a variable available in xml (a bit like active_id, parent, etc) ?

HIGHCO - Nicolas Clavier
Auteur

I can't find in the view the boolean context variable set_editable mentioned here : http://doc.openerp.com/trunk/developers/web/list_view/#editability-status

Cyril Gaspard (GEM)

I believe you do not understood what I would say by editable/browse. Editable is when you push a button create or edit, browse is a view in state read (I wanted just use terms you used yourself). By regarding your other new questions, attribute set_editable is to have a tree with lines editable without wizard form opened to modify value of fields, this is not the same thing. I do not if it is possible to have the status edit/read mode of a view. bye

HIGHCO - Nicolas Clavier
Auteur

Hi GEM, thanks for coming back to me. I understand both contexts are different. The link above discusses a javascript context accessed from the client side which could as well be a completely different context from the server side context. I created a new question to dig and clarify this topic.

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
Add a signature field in my XML view with Odoo 16 and custom modules
modules xml view widget signature
Avatar
Avatar
Avatar
Avatar
3
okt. 23
8728
How can i customize float field? Opgelost
fields view widget customizing class
Avatar
Avatar
1
dec. 22
19195
how to make Integer field as a <input type="range" in odoo V11 Opgelost
javascript fields xml widget v11
Avatar
2
jul. 18
9252
How to import the field sale_selectable via XML? Opgelost
error fields import xml view
Avatar
Avatar
1
apr. 15
5279
Custom field widget not working, showing default widget instead.
fields widget
Avatar
0
aug. 25
3271
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