Add column to party.party

i am tryoig to add a field interest to party, the same like catégories.

si i made a module with

=========== interets.py ==================

class Interets(DeactivableMixin, tree(separator=' / '), ModelSQL, ModelView):
	"Interets"
	__name__ = 'party.formo_interets'
	name = fields.Char(
        "Name", required=True, translate=True,
        help="The main identifier of the Interets.")

the tables is created…

I tried to alter table party_party

class Party(DeactivableMixin, ModelSQL, ModelView, MultiValueMixin):
    __name__ = 'party.party'
    
    _order_name = 'write_date'
    _order = [('write_date', 'DESC')]
    
    interets = fields.Many2Many(
        'party.party-party.formo_interets', 'party', 'interet', "Interets",
        help="The interets the party belongs to.")

but nothing change in party.

why the rel table is party.party-party.formo_interets (like for categories) and not
party.party_party.formo_interets (with an underscore ) ?

i think the reason is that party.party is not in y module, but it works for party_siret

You should not reapply the models when extending an existing model, see Extend model — Tryton server

Probably because you did not defined nor register the model for it.
You must always define the model that you use for a Many2Many field.

1 Like

:wink:

the question is in the table name (saw in party)
categories = fields.Many2Many(
‘party.party-party.category’, ‘party’, ‘category’, “Categories”,
help=“The categories the party belongs to.”)

why a - (minus) and not an _ (underscore) i saw that elsewhere too.

Your code, your name.

We name model as we want so usually model to link two other models use - to symbolise the link.

ok the - is a pain for autocompletion in psql

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