콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
8480 화면

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.

베스트 답변

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.

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

작성자

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

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

베스트 답변

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">

작성자

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

Ok. No problem.

I refresh my ansver. Let's try.

작성자

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

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

작성자

sorry sir but i can't do that

작성자 베스트 답변

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>

아바타
취소
베스트 답변

Hi, you can follow following link for this:

https://youtu.be/oMnHpHH54QU

Thanks

아바타
취소