Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

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

By
Alcaline
on 7/25/14, 1:53 AM 1,599 views

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:

 

 

 

 

 

 

Please post your Code! xml and py.

klacus
on 7/25/14, 2:08 AM
1

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 7/30/14, 4:37 AM

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.

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.

Alcaline
on 7/30/14, 5:04 AM

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

Sudhir Arya (SA)
on 7/30/14, 5:48 AM

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

Alcaline
on 7/31/14, 2:14 AM
0
Alcaline
On 7/25/14, 3:26 AM

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
klacus
On 7/25/14, 2:16 AM

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
 

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
on 7/25/14, 3:25 AM

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

Alcaline
on 7/25/14, 3:32 AM

Ok. No problem.

klacus
on 7/25/14, 3:50 AM

I refresh my ansver. Let's try.

klacus
on 7/25/14, 3:52 AM

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? :(

Alcaline
on 7/25/14, 4:26 AM

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

klacus
on 7/25/14, 10:00 PM

sorry sir but i can't do that

Alcaline
on 7/30/14, 4:31 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 7/25/14, 1:53 AM
Seen: 1599 times
Last updated: 3/16/15, 8:10 AM