dynamical text fields have size=64 when show dynamically in a view

Bug #1053511 reported by Benoit Guillot - http://www.akretion.com
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Low
OpenERP Publisher's Warranty Team

Bug Description

Hello,

I have created a field dynamically. It's type is : "text". Let's call it : "x_text_field".

Then I have overriden the method fields_view_get() in order to show it dynamically.
So, in the method to update the fields of the view, I call the method fields_get() like this:

        result['fields'].update(self.fields_get(cr, uid, ['x_text_field'], context=context))

For this field, the method answers :

       {u'x_text_field': {'selectable': True, 'translate': True, 'type': 'text', 'string': u'text_field', 'size': 64}}

However, if I call the same method for a native text field like "description" (in product.template), I get :

       {'description': {'selectable': True, 'translate': True, 'type': 'text', 'string': 'Description'}}

Then, on the view (only the one that adds dynamically the field), the size of the field 'text_field' is limited to 64 chars, even if in the database the size isn't limited.

To make it more complicated, this bug seems to appear only with the web client, because the web client authorizes the size limitation of the fields of type "text" and not the gtk client. So, even if the answer of the method fields_get() is wrong, with the gtk client it is not considered.

Best regards,

Benoît

Tags: maintenance

Related branches

Changed in openobject-server:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hello,

This issue is more straightforward than the actual bug report.

It is very simple to reproduce:
 - Go to 'Settings > Customization > Database Structure > Fields'
 - Create a new field on any model with a 'text' field type
 -> You'll notice that: you can't change the size of the field

The default size of the field is 64, and can't be changed.

So the client just does what the server told it to do: it display a text widget with a length of 64 characters.

The size should certainly not be defined on 'text' fields (the size of the text fields created by the ORM is NULL).

Another thing, if I try to create a 'text' field directly with a python 'create' in ir.model.data and I put the 'size' key to False, the creation will fail. Because the ORM will put a 0 instead of a False (it goes like that with int), and the following constraint of ir.model.fields will be raised.

    def _size_gt_zero_msg(self, cr, user, ids, context=None):
        return _('Size of the field can never be less than 1 !')

    _sql_constraints = [
        ('size_gt_zero', 'CHECK (size>0)',_size_gt_zero_msg ),
    ]

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Note that a simple workaround would be to set the size to NULL in ir_model_fields for those fields, but the issue would reappear for each new field.

Revision history for this message
Chris Biersbach (OpenERP) (cbi-openerp) wrote :

I merged a fix for this into stable 7.0 server at revision 4908 (<email address hidden>)

Changed in openobject-server:
importance: Undecided → Critical
status: New → Fix Released
importance: Critical → Low
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote : Re: [Bug 1053511] Re: dynamical text fields have size=64 when show dynamically in a view

Hourra!!!

I'll remove the related patches in base_customer_attributes module of v7...

On Wed, Mar 27, 2013 at 11:03 AM, Chris Biersbach (OpenERP) <<email address hidden>
> wrote:

> I merged a fix for this into stable 7.0 server at revision 4908
> (<email address hidden>)
>
> ** Changed in: openobject-server
> Importance: Undecided => Critical
>
> ** Changed in: openobject-server
> Status: New => Fix Released
>
> ** Changed in: openobject-server
> Importance: Critical => Low
>
> --
> You received this bug notification because you are a member of OpenERP
> Drivers, which is subscribed to OpenERP Server.
> https://bugs.launchpad.net/bugs/1053511
>
> Title:
> dynamical text fields have size=64 when show dynamically in a view
>
> Status in OpenERP Server:
> Fix Released
>
> Bug description:
> Hello,
>
> I have created a field dynamically. It's type is : "text". Let's call
> it : "x_text_field".
>
> Then I have overriden the method fields_view_get() in order to show it
> dynamically.
> So, in the method to update the fields of the view, I call the method
> fields_get() like this:
>
> result['fields'].update(self.fields_get(cr, uid,
> ['x_text_field'], context=context))
>
> For this field, the method answers :
>
> {u'x_text_field': {'selectable': True, 'translate': True,
> 'type': 'text', 'string': u'text_field', 'size': 64}}
>
> However, if I call the same method for a native text field like
> "description" (in product.template), I get :
>
> {'description': {'selectable': True, 'translate': True, 'type':
> 'text', 'string': 'Description'}}
>
> Then, on the view (only the one that adds dynamically the field), the
> size of the field 'text_field' is limited to 64 chars, even if in the
> database the size isn't limited.
>
> To make it more complicated, this bug seems to appear only with the
> web client, because the web client authorizes the size limitation of
> the fields of type "text" and not the gtk client. So, even if the
> answer of the method fields_get() is wrong, with the gtk client it is
> not considered.
>
> Best regards,
>
> Benoît
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/openobject-server/+bug/1053511/+subscriptions
>

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.