Search code examples
odooodoo-13

Table name is too long odoo 13


I am getting this error after adding a binary filed I remover the filed but getting the same error

Table name 'n_hesaby_subscription_manager_subscription_manager_res_users_rel' is too long

odoo.exceptions.ValidationError: ("Table name 'n_hesaby_subscription_manager_subscription_manager_res_users_rel' is too long", None) - - -

does anyone know what it means, I can't find it


Solution

  • From the look of the table name it's created from a many2many field between n_hesaby_subscription_manager_subscription_manager and res.users when you don't provide a name for the relation table Odoo will generate it for you model_1_name_model_2_name_rel.

    So in your many2many definition specify a shorter name

        m2m_field_name = fields.Many2many(comodel_name='res.users', 
               relation='put_nice_table_name_here',  
               column1='put_nice_and_short_field_name_here_to', 
               column2='user_id', 
               string='You field label')
    

    I'm using my phone sorry for my short answer I hope you get the idea, you can check Odoo standard modules you will find planty of examples. Always specify the name of the relation in your many2many field is a good practice prevent unexpected behavior.