[6.1] GTK Client whitespace trimming (or maybe module, or maybe framework)

Bug #947670 reported by Graeme Gellatly
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo GTK Client (MOVED TO GITHUB)
New
Undecided
Unassigned

Bug Description

If you look at this function (although there are many more) the GTK client trims the whitespace in the return causing errors when the field only contains whitespace and annoying errors when it doesn't. This example os from sale_layout, however many other modules have a similar requirement to support whitespace e.g. ' - ' gets trimmed to just '-' by GTK in product_variant_multi so I report for GTK rather than specific module.

Note I am only assuming it is GTK behaviour as it doesn't exhibit when the value is set by defaults, but does when triggered by onchange or user input

    def onchange_sale_order_line_view(self, cr, uid, id, type, context={}, *args):
        temp = {}
        temp['value'] = {}
        if (not type):
            return {}
        if type != 'article':
            temp = {
                'value': {
                'product_id': False,
                'uos_id': False,
                'account_id': False,
                'price_unit': 0.0,
                'price_subtotal': 0.0,
                'quantity': 0,
                'discount': 0.0,
                'invoice_line_tax_id': False,
                'account_analytic_id': False,
                'product_uom_qty': 0.0,
                },
            }
            if type == 'line':
                temp['value']['name'] = ' '
            if type == 'break':
                temp['value']['name'] = ' '
            if type == 'subtotal':
                temp['value']['name'] = 'Sub Total'
            return temp
        return {}

affects: openobject-addons → openobject-client
Revision history for this message
Graeme Gellatly (gdgellatly) wrote :

Indeed here is the offending function in char.py line 43 I think
    def set_value(self, model, model_field):
        value = tools.ustr(self.widget.get_text()).strip()
        ## PyGTK functions always return strings as str objects. In most (all?) cases,
        ##the strings are encoded in UTF-8. Ideally,Python programs should use unicode strings internally,
        ## so it’s wise to convert the output of PyGTK function calls to unicode.
        ## for more info:http://sjohannes.wordpress.com/2009/04/24/unicode-with-python-2-and-pygtk/
        value = value.decode('utf-8')
        return model_field.set_client(model, value or False)

value = tools.ustr(self.widget.get_text()).strip()

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.