Allow user to create a pseudo custom field

Hello Tryton team,
I want allow my users to customize or create input data that they need. (field name and value)

My first idea was like create a One2Many field called “custom data” and a Many2One inside that field.

Does anyone know another approach or better idea? I know is not possible create field on the fly, but I would like my users to customize some part of their input.

You can use a Dict field an allow the user to setup the available attributes by configuration.

The product_attribute module has an implementation of Dict fields that can be used as reference

1 Like

Thanks @pokoli I’ll check right now.

I used the module as template and now my custom module works like a charm. Thanks !

Hello @pokoli, Just one last doubt:
is it possible to order the attributes when I click on “Add attributes to the variant.”)
I want by default to show 1,2,3,4 I know I can click on “Nombre” to order but by default?

I read on docs the search_order by name or attribute keyword but works only on configuration menu not in add product variant. Thanks for your help

attribute = fields.Many2One('health_custom.attribute', 'Campos',
    search_order = [('name', 'ASC')],


attributes = fields.Dict('my_custom.attribute', 'Campos',
        domain=[
            ('sets', '=', Eval('_parent_template', {}).get('attribute_set',
                    Eval('attribute_set', -1))),
            ],
        depends=['attribute_set'],
        help="Add attributes to the variant.")

For me, Dict keys are ordered by definition sequence since Issue 8373: Allow customizing Dict keys order - Tryton issue tracker

Well, seems that I’m sabotage myself. :sweat_smile:

I just created a new one with 1,2,3,4 and seems to work as expected. Thanks sorry for bother.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.