Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Hide Rows in Tree inside Form View

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
invoiceinvoice.line
2 Réponses
11865 Vues
Avatar
Mick Radakovic

I'm trying to hide the invoice lines where quantity is set to 0, so I edited account.invoice.form view, and tried with:

...
<page string="Invoice Lines">
  <field name="invoice_line" nolabel="1" widget="one2many_list" domain="[('quantity', '&gt;', 0)]">
    <tree string="Invoice Lines" editable="bottom">
      <field name="sequence" widget="handle"/>...

But this doesn't have any effect at all. No matter what I put into domain, the list remains the same.

Please advise. Thanks!

0
Avatar
Ignorer
Avatar
Denis Baranov
Meilleure réponse

Hi!

Using domain would not lead you to required behavior. In case of tables it is used in case of many2many fields in order to restrict selection, not visibility of rows. So, it is a constraint to choose records

If I'm not mistaken, the only way to achieve the desired requirement, is to re-define the functions on the Python level. 

I guess, there are 2 alternatives:

1. TO re-define the get method of a related model. Technically better, but may influence other places, where lines are used in the interface

2. To create a new computed table, where to put only desired lines, and inverse them in original method. This is logically simplier, e.g.:

To the model account invoice:

@api.multi def _compute_new_line_ids(self)

for invoice in self:

 new_ids = invoice.line_ids.filtered(

                lambda t: t.quantity > 0,

            )

 invoice.new_line_ids = [(6,0,new_ids.ids )]

 new_ids = invoice.line_ids.filtered(

                lambda t: t.quantity == 0,

            )

 invoice.new_line_ids_zero = [(6,0,new_ids.ids )]

@api.multi def _inverse_new_line_ids(self):

for invoice in self:

invoice.line_ids = [(6,0,invoice.new_line_ids + invoice.new_line_ids_zero)]

new_line_ids = fields.One2many(

"account.invoice.line",

"invoice_new_id",

compute=_compute_new_line_ids,

inverse=_inverse_new_line_ids,

string="Invoice Lines) # invoice_new_id - is a new back reference in line model

new_line_ids_zero = fields.One2many(

"account.invoice.line",

"invoice_new_id_2",

compute=_compute_new_line_ids,

inverse=_inverse_new_line_ids,

string="Invoice Lines) # invoice_new_id_2 - is a new back reference in line model

On a xml form replace line_ids with new_line_ids


1
Avatar
Ignorer
Denis Baranov

Depending on your requirements, it may be better not to just hide, but remove the lines. Just add inverse to line_ids, and in this function remove zero lines. It would be updated each time you create or write a record

عمر ابو ضيف

can you explain further, why you made two o2m fields
why did you make two different inverses,
how exactly are you going to replace the o2m in XML in this case?

Avatar
Salih Kalender
Meilleure réponse

You can write domain in the field you defined.

doctor_ids = fields.Many2many('example.a', 'example_a_b_rel', 'example_a_id', 'example_b_id', domain="[('is_doctor', '=', True)]")

0
Avatar
Ignorer
Arian Shariat

This doesn't hide the filed. It prevents it to be created at the first place.

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Item and Description Lines Not Showing When Invoice is Printed Résolu
invoice invoice.line
Avatar
Avatar
Avatar
3
févr. 24
4868
how can i make some space for a field in the invoice lines
invoice invoice.line
Avatar
0
mai 16
4281
merge invoice lines by product when convert from multiple sales orders
invoice invoice.line sales.order
Avatar
Avatar
Avatar
Avatar
4
févr. 25
8118
Fixed shipped costs are invoiceable when sale order is confirmed
invoice invoice.line shipping_cost
Avatar
Avatar
Avatar
2
févr. 22
3928
Odoo 14 @api.onchange from a field of another class Résolu
invoice onchange invoice.line
Avatar
Avatar
1
janv. 22
4979
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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