I can't open my webapp

<form>
    <button name="recognize_face" string="Get your Attendance"  type="object"/>
    <newline />
    <button name="action_initialize_face" string="Initialize Your Face"  type="object"/>
</form>

I can’t seem to get this two do their action, is this something wrong?


    def action_initialize_face(self):
        # Check user permission (optional)
        user_id = self.context.get('user')
        if not user_id:
            raise UserError('User context is not available.')

        # Open the web application for face recognition initialization
        for record in self:
            url = (f"http://localhost:8080/initialize-face?"
                   f"employee_id={record.id}")
            webbrowser.open(url)
    

    def action_open_webapp(self):
        # Check user permission (optional)
        user_id = self.context.get('user')
        if not user_id:
            raise UserError('User context is not available.')

        # Open the web application with parameters
        for record in self:
            url = (f"http://localhost:8080/face-recognition?"
                   f"employee_id={record.id}&"
                   f"face_id={record.face_recognition_id}")
            webbrowser.open(url)

This what happens in tryton:

The buttons must be declared on the ModelView._buttons to allow the client to call them via RPC.

Also you should not call webbrower.open on the module side because it is run on the server side. So it is the browser of the server that will be launched.

I suspect that you want the user to open a the URL from the form in the client. Then you must use a Function field that compute the value of a Char field which is the URL. And in the form view instead of buttons, you display the Function field with the widget url.

Could you give me an example of how to use that ModelView? I am rather clueless.