Skip to Content
Menu
This question has been flagged
3 Replies
9668 Views

We are trying to implement a confirmation dialog when saving records.

Eg. when a user creates/edits a partner and clicks "Save", we would like to check for existing partners with the same name. If any are found, a confirmation window would pop up with the options "OK" or "Cancel". If "Cancel" is pressed, the record will not be saved and the user can continue editing the partner. If "OK" is pressed, the record is saved.

This seems like a very simple functionality but I'm having trouble finding any examples of how to accomplish this. Any help pointing us in the right direction would be appreciated.

We are running Odoo 12 Enterprise.

Avatar
Discard

How to display confirmation display box / message box on button click: https://goo.gl/6P7aR1

Best Answer

Here is a syntax

<button name="method_name" type="object" string="Save" confirm="Are you sure you want to save this record." />


Avatar
Discard

it's not the precise answer because it will always show you confirm dialog box on save regardless of duplicate record( existing partners with the same name) or not

Best Answer

Sadly this isn't part of Odoo, though I've had similar requests from multiple clients. The confirm syntax above isn't conditional and only works on buttons you add, not the default save button, and the other solution of adding a save hook will prevent the record being saved at all if the condition occurs.

As the save button is created in JavaScript and by the time it calls the create function in python it's too late, you need a JavaScript based solution.

If you're not scared of a little bit of coding you can give the app store module I've developed a go, it's able to handle this kind of confirmation on save. It allows you to create dynamic warnings on the save of a record and give's you the option to proceed or cancel. It's a generic app that can apply to any model, but has partners with the same name as one of it's examples.

https://apps.odoo.com/apps/modules/13.0/pbj_save_dialog/

Avatar
Discard
Best Answer

This will helpful

 
 

Avatar
Discard