Comment 0 for bug 553988

Revision history for this message
Blqt (benoit-luquet) wrote :

Hi,

There is a different behavior for on_change between web client and gtk (gtk works fine):
Environment : 5.07 Windows AND linux

When on_change modifies a float field in a form, the field is rounded with 2 decimals using the web client (windows).
On linux, I have not been able to understand how it is rounded.

Example (this example is simple and stupid, but this error prevents us from using web client for sale and purchase order with price_accuracy=3)
That example divides weight by 3 when volume is changed on a product form

     <record id="test_float_form_view" model="ir.ui.view">
            <field name="name">test.float.form</field>
            <field name="model">product.product</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="type">form</field>
            <field name="arch" type="xml">
                    <field name="volume" position="replace">
                           <field name="volume" on_change="onchange_volume(volume,weight)"/>
                    </field>
            </field>
        </record>

class product_product(osv.osv):
    _name = 'product.product'
    _inherit = 'product.product'
    def onchange_volume(self, cr, uid, ids,volume,weight):
        v = {}
        v['weight'] = weight/3
        return {'value': v}
product_product()

1) Create or edit a product
2) Enter weight = 1.000
3) Enter volume= whatever you want
4) on window weight becomes 0.33 where it should be 0.333. On linux, weight becomes 0 !!!

/Benoit