PRIMARY KEY and button

How to add a primary key to the model?
Ensure data uniqueness?
Can you add button method calls in the wizard?

you must use a SQL UNIQUE constraint


from trytond.model import ModelSQL, ModelView, fields, Unique

class YourModel(ModelSQL,ModelView)

        def __setup__(cls):
            super(YourModel, cls).__setup__()
            table = cls.__table__()
            cls._sql_constraints += [
                ('key', Unique(table, table.your_unique_col,table.your_unique_col2,...),
                    'your message')

Wizard — trytond 5.3 documentation

you can add buttons and on the transition_state (for StateTransition) and do_state (for StateAction and StateReport) methods you can write your code and call the Pool for get other models methods

Thank you very much for your answer.

Does this button method binding exist in mind?

you can by example:

class MyWizard(Wizard):
    "My Wizard"
    __name__ = "my_module.my_model.my_wizard"

    start = StateTransition()

    def transition_start(self):
        ShipmentInternal = Pool.get('stock.shipment.internal')
        Shipment = ShipmentInternal.browse([Transaction().context['active_id'])
        return 'end'

I used this for to jump steps on the sale process, maybe can help you of reference:

Tryton uses surrogate keys.
It’s the id column that is there for every Model.