Skip to Content
Menu
This question has been flagged
4 Replies
4909 Views

As i had created two fields with different relations(res.partner and sale.order.line) in product and i am trying to get the data dynamically after clicking on the first field by using "onchange" but it is not working..type is many2one.

eg:-

xml

<field name="x_pen" class="oe_inline" on_change="onchange_pen(x_pen, parent_id)" />
<field name="x_Total" class="oe_inline" on_change="onchange_pen(x_pen, parent_id)" attrs="{'invisible': ['|', ('x_pen', '=', False),]}" />

and the error shows like this:

AttributeError: 'product.template' object has no attribute 'onchange_pen'
Avatar
Discard
Best Answer

Check whther the function is defined in your script or in the same model. You should define the onchange_pen() on the desired model in your script.

Avatar
Discard
Best Answer

Hy kumar,

Check this one: https://www.odoo.com/forum/help-1/question/how-to-create-a-onchange-with-many2one-solved-70977#answer-132855

Avatar
Discard
Best Answer

Hi Kumar,


If you're using version 8. You could at least try this one


@api.onchange('x_pen')

def onchange_x_pen(self):

     #insert code here


@api.onchange('x_Total')

def onchange_x_Total(self):

     #insert code here


Then in xml:

<field name="x_pen" class="oe_inline">

<field name="x_Total" class="oe_inline" attrs="{'invisible': ['|', ('x_pen', '=', False),]}" >

I hope this helps.


Avatar
Discard
Author Best Answer

Everything is fine as i had checked onchange_pen() is defined even though it is coming same error. And am using in Odoo V8

Avatar
Discard