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

one2many problem: How to fix this?Button become readonly when it's shown on wizard object's one2many??

Subscribe

Get notified when there's activity on this post

This question has been flagged
4 Replies
8858 Views
Avatar
Alcaline

Problem with this button GET TOTAL:  I got a form that has a one2many relationship with the other class, when I  go to  the tree view of this one2many the button  GET TOTAL is disabled but when in the original form view it is enbled, I think the cuase of this is the widget  one2many because i tried it to many2many it works but i need it in one2many relationship. any idea please or have you encountered this kind of problem?? how can i fix this problem??

the form that has a one2many relationship and the button disabled:

 

 

 

 

 

 

2
Avatar
Discard
klacus

Please post your Code! xml and py.

Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Best Answer

Hello Lee,

The button will always be disabled for one2many field if record is not saved.

Try it after saving the record. It will work once it is saved.

1
Avatar
Discard
Alcaline
Author

thank you Sudhir Arya, thanks for the information i did that already. but one question why is it the button inside the one2many list is disabled? any explanation for this.

Sudhir Arya (ERP Harbor Consulting Services)

Its a default behavior of the Odoo. We cannot change it.

Alcaline
Author

thanks Mr. Arya this is really a big help in task:)

Pawan Kumar Sharma

Hello Sudhir, I have similar problem. Is there any way to enable this button in wizard for one2many field?

Avatar
klacus
Best Answer

Sorry but didn't clear me for the relation with one2many and the button.

Your form view has a button. it is clear.

Your model has a one2many relation this is also clear.

How you definie the button in xml? Do you have any extra atrributes? Do you have a acces rights? A lot of thinks is possible to miss, and the effect is the trouble. As I wrote down to you your prev. post, please post the xml, for the better understanding.

 

Please try this:

    <xpath expr="//field[@name='amount']" position="after">
                    <button name="get_total_bom_commit_button" string="Get Total" type="object" icon="gtk-o"/>
                </xpath>

 

I thin kyour problem is here:

states="" or atribute="" or readonly="False" >> just clear out
 

0
Avatar
Discard
Alcaline
Author

hi sir, this is my code in PY for button: (This button is belong to the class of "account.analytic.line.commit" ) and i want the whole form of this button will display in my project.project class. So, I did a one2many relationship between the two class ("account.analytic.line.commit" and "project.project") to call the form in project.project. The codes that i did is totally working without errors except for one problem the button GET TOTAL is disable. I don't understand why it is disabled. Can you please help me i don't know what to do? class account_analytic_line_commit(osv.osv): _inherit = "account.analytic.line.commit" def get_total_bom_commit_button(self, cr, uid, ids, context=None): bom_total_new = {} bom_prod_com_pool = self.pool.get('bom.product.components') for bom_total_ids in self.browse(cr,uid,ids): new_price = 0 bom_total_line = bom_prod_com_pool.search(cr,uid,[('commit_id','=',bom_total_ids.id)]) netsvc.Logger().notifyChannel("\n for bom_total_new in bom_prod_com_pool.browse(cr,uid,bom_total_line): new_price = new_price + bom_total_new.total_price self.write(cr,uid,bom_total_ids.id,{'amount': new_price}, context=context) return True and this is my code in XML: <xpath expr="//field[@name='amount']" position="after">

Alcaline
Author

I'm sorry sir for what I've been said a while ago.. I'm just only newbie here in ODOO.

klacus

Ok. No problem.

klacus

I refresh my ansver. Let's try.

Alcaline
Author

sir I've already try that one but it's not working.. I think the problem is the ONE2MANY relationship because when I tried to changes it to MANY2MANY the button GET TOTAL inside it works perfectly. but I need it to stay ONE2MANY. I also have this kind of problem with the other modules. how can i fix that one? :(

klacus

Hi. Please send the complett modul for me. at kozmalg@gmail.com

Alcaline
Author

sorry sir but i can't do that

Avatar
Alcaline
Author Best Answer

hi sir, this is my code in PY for button: (This button is belong to the class of "account.analytic.line.commit" ) and i want the whole form of this button will display in my project.project class. So, I did a one2many relationship between the two class ("account.analytic.line.commit" and "project.project") to call the form in project.project. The codes that i did is totally working without errors except for one problem the button GET TOTAL is disable. I don't understand why it is disabled. Can you please help me i don't know what to do?

 

class account_analytic_line_commit(osv.osv):

_inherit = "account.analytic.line.commit"

 def get_total_bom_commit_button(self, cr, uid, ids, context=None):
        
        
        bom_total_new = {}
        
        bom_prod_com_pool = self.pool.get('bom.product.components')
        
        for bom_total_ids in self.browse(cr,uid,ids):

            new_price = 0
            
            bom_total_line = bom_prod_com_pool.search(cr,uid,[('commit_id','=',bom_total_ids.id)])
            
            for bom_total_new in bom_prod_com_pool.browse(cr,uid,bom_total_line):
               
                new_price = new_price + bom_total_new.total_price
            
            self.write(cr,uid,bom_total_ids.id,{'amount': new_price}, context=context)
            
                
        return True    

 

And this is my code in XML:

    <xpath expr="//field[@name='amount']" position="after">
                    <button type="object"
                            icon="gtk-ok"
                            name="get_total_bom_commit_button"
                            string="Get Total" groups="" readonly="False" attrs="" states="" disable="False" button="True"/>
                </xpath>

0
Avatar
Discard
Avatar
Adil Akbar
Best Answer

Hi, you can follow following link for this:

https://youtu.be/oMnHpHH54QU

Thanks

0
Avatar
Discard
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
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