Incorrect behavior of on_change for floats on web client

Bug #553988 reported by Blqt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Web Client
New
Undecided
Unassigned

Bug Description

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 .
On linux, the rounding is different, but false too.

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

     <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 !!!
with gtk, everything is fine and weight is changed to 0.333

/Benoit

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

I have found a workaround by changing

class Float(Number):
    if_empty = False
    digit = 2
    ...
to
class Float(Number):
    if_empty = False
    digit = 5
    ...

in web/python/Lib/site-packages/openero_web.../openerp/validators/validators.py
Is it the right thing to do?

Benoit

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.