Can a custom Button triggers a Wizard form?

Hi,

Continue from my question at here, is it possible for this custom button as coded below to trigger a Wizard form, instead of from Wizard Nav-bar button?

    @classmethod
    def __setup__(cls):
        super(SalesOrder, cls).__setup__()
        cls._buttons.update({
            'add_new_record': {
                'readonly': Eval('id', -1) < 0,
            }
        })

    @classmethod
    @ModelView.button
    def add_new_record(cls, object):
        logger.info('>>'*40)
        logger.info(f'>>>>>>>>>>>>>>>>>>>> {object}')
        sales_order = object[0]
        if sales_order:
            #------ OPEN A SALES ORDER WIZARD FORM ------
        logger.info('>>'*40)
        return True

Regards
Bromo

Yes, it is possible. You just need to declare your button with the @ModelView.button_action decorator pointing to the wizard action.

For example, in the sale module there is this implementation:

https://gitlab.com/tryton-upstream/modules/sale/-/blob/develop/sale.py?ref_type=heads#L987

2 Likes

A post was split to a new topic: Is it possible to pass the record ID to the Form class automatically when the user click the button?