Hello,

I added an "on_change" event to a view, with a basic function to test, but 
nothing append when the field change, here is my code :

In sale order view I added tree fields 
<field name="height" on_change="dimensions_change&#40;&#41;"/>
<field name="width" on_change="dimensions_change&#40;&#41;"/>
<field name="m2_total" />

I created a sale_order_line class :

class sale_order_line&#40;osv.osv&#41;&#58;
&nbsp; &nbsp;_name = 'sale.order.line'
&nbsp; &nbsp;_inherit = 'sale.order.line'
&nbsp; &nbsp;
&nbsp; &nbsp;def _getM2Total &#40;self, cr, uid, ids, field_name, arg, 
context&#41; &#58;
&nbsp; &nbsp;&nbsp; &nbsp;""" M2 + m2 recharges """
&nbsp; &nbsp;&nbsp; &nbsp;res = &#123;&#125;
&nbsp; &nbsp;&nbsp; &nbsp;for id in ids&#58;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; res&#91;id&#93; = 11
&nbsp; &nbsp;&nbsp; &nbsp;
&nbsp; &nbsp;&nbsp; &nbsp;return res&nbsp; &nbsp;
&nbsp; &nbsp;&nbsp; &nbsp;
&nbsp; &nbsp;_columns = &#123;
&nbsp; &nbsp;&nbsp; &nbsp;'width'&#58; fields.integer&#40;'Width'&#41;,
&nbsp; &nbsp;&nbsp; &nbsp;'height'&#58; fields.integer&#40;'Height'&#41;,
&nbsp; &nbsp;&nbsp; &nbsp;'m2_total'&#58; fields.function&#40;_getM2Total, 
method=True, type="integer", string='M2 Total'&#41;,
&nbsp; &nbsp;&#125;
&nbsp; &nbsp;

&nbsp; &nbsp;def dimensions_change&#40;self, cr, uid, ids&#41;&#58;
&nbsp; &nbsp;&nbsp; &nbsp;v = &#123;&#125;
&nbsp; &nbsp;&nbsp; &nbsp;v&#91;'m2_total'&#93; = 36
&nbsp; &nbsp;&nbsp; &nbsp;
&nbsp; &nbsp;&nbsp; &nbsp;return &#123;'value'&#58; v&#125;
&nbsp; &nbsp;
sale_order_line&#40;&#41;




_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman/listinfo/tinyerp-users

Reply via email to