This question has been flagged
1 Reply
6719 Views

Hi,

I'm working with the website module in odoo 13 .

How is it done so that when I press the button "delete" and "update" , it will generate a second URL to delete or update patient with the specified Id.

//.xml

<table class="table table-striped">
    <thead>
        <tr>
            <td>Name</td>                        
            <td>ID</td>
            <td> Delete</td>
            <td>Update</td>
        </tr>
    </thead>
    <body>
        <t t-foreach="patients" t-as="patient">
        <tr>
        <td>
            <t t-esc="patient.name"/>
        </td>
        <td>
            <t t-esc="patient.id"/>
        </td>
         <td>
             <form action="/delete/patient" method="post">
                     <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
                      <button type="submit" class="btn btn-primary pull-left">Delete</button>
              </form>
        </td>
         <td>
              <form action="/update/patient" method="post">
                        <input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
                         <button type="submit" class="btn btn-primary pull-left">Update</button>

              </form>
        </td>
        </tr>
        </t>
    </body>
</table>


//.py

@http.route('/delete/patient', type="http", website=True, auth="public")
    def delete_patient(self, **kw):
        rec = request.env["hospital.patient"].search([])
        p_id = int(kw.get('id', patient.id))
       

@http.route('/update/patient', type="http", website=True, auth="public")
    def update_patient(self, **kw):


Any help please ?

Thanks.

Avatar
Discard
Best Answer

Hello,

Please try to using this way:


@http.route(''/delete/patient', type='http', methods=['POST'], auth="public", website=True, csrf=False)

def delete_patient(self, **kw):

        rec = request.env["hospital.patient"].search([])

        p_id = int(kw.get('id', patient.id))


Regards,




Email:   odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

Avatar
Discard