Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Hide Rows in Tree inside Form View

Subscribe

Get notified when there's activity on this post

This question has been flagged
invoiceinvoice.line
2 Replies
11868 Views
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
Discard
Avatar
Denis Baranov
Best Answer

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
Discard
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
Best Answer

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
Discard
Arian Shariat

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

Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
Item and Description Lines Not Showing When Invoice is Printed Solved
invoice invoice.line
Avatar
Avatar
Avatar
3
Feb 24
4870
how can i make some space for a field in the invoice lines
invoice invoice.line
Avatar
0
May 16
4281
merge invoice lines by product when convert from multiple sales orders
invoice invoice.line sales.order
Avatar
Avatar
Avatar
Avatar
4
Feb 25
8119
Fixed shipped costs are invoiceable when sale order is confirmed
invoice invoice.line shipping_cost
Avatar
Avatar
Avatar
2
Feb 22
3929
Odoo 14 @api.onchange from a field of another class Solved
invoice onchange invoice.line
Avatar
Avatar
1
Jan 22
4981
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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