Odoo: how to delete the saved model on cancelling/leaving form? - odoo

I have a form on odoo for scheduling appointments where the user clicks on a button to search available appointment slots.
When the button is clicked, the model is saved, that's how odoo works and I could not work around that.
But if the user gives up on scheduling the appointment, the model is already saved... So I need to delete it from the database if the user leaves the form, or clicks "cancel".
How do I do it?

A nice work around is to use The active field if this field is False Odoo by default will not show this record. and you can register a ir.cron to delete this records or leave them.
Hope you get the idea

Related

Check some field before opening confirmation box in ODOO

I want to check that if some fields in the form view has been checked or not. If they have been checked then show a confirmation message and if not then a error message saying that those fields must be checked. For this functionality I have created a button which calls a specific function in the model. The button has also attribute confirm which enables the confirmation pop up box. But all the time it first opens the confirmation message and then the checking for the fields. I want to have the other way around how to achieve this. Please help.

Need prompt to save changes in Windows form when changing displayed record

I am relatively new to programming, so this may be an easy one. I have a Windows form that connects to SQL Server and displays the data in a form where a user can edit and add or delete records (via databinding). The form works well, and has record navigation controls as well as context menus that allow the user to filter data on any field.
Currently, the user can make changes and switch to new records, etc... but changes are not applied until the user clicks the "save" button. However, I'd like to prompt the user to save records whenever the user navigates to a new record (either through navigator or through application of a filter which displays a different record).
What event can I use that will trigger whenever a different record is reflected in the form?
Thanks,
Jay

Odoo - Update record when click on button in email template

I am using Odoo 10-e. I create a simple email template which i am sending on a particular event from my class. What i want to know that is this possible in Odoo to create a email template and put button into it. When user click on that button my particular class field will be updated.
You could write a http controller which will update a database record. Just let the "email button" call a specific url.
But keep in mind that giving non odoo users (and that's what you're doing here) such access rights could end in a security disaster.

Issues saving current record from custom dialog

I am currently developing a custom app in Maximo Asset Management where i have form and an empty DataTable that have a button, when user clicks this button, a custom dialog appears and user can select a related record from this dialog on a data table to process it by clicking a button to launch an action script. The problem i am facing is when system finish process the record, it saves correctly, but application shows the first record of table and not the current saved record, so user gets confused when this happens.
Let me put an example, lets suppose the first record id of my custom table is CC1055 and the current saved generates as CC1156, when i close dialog after process record with automation script custom logic, the systems shows the record with id CC1055 and not the new saved record CC1156, postdata: I use Maximo 7.5.0.9
I had the same issue. The reason Maximo goes to the first record in the table is that it does not know which record to display after opening and closing your new custom dialog and saving the record.
The simplest solution is to add savemode="ONLOADUNLOAD" in your custom dialog tag in xml.
This will save the record before you open the dialog and Maximo will know to which record to return after closing it.

Setting up recycle bin functionality in Archer GRC

When deleting records within the platform, this action is not reversible via the front end. Is there a way to allow users to remove a record from their view without actually deleting the record?
You can simulate recycle bin functionality within Archer GRC by adding a record permission field that grants read access to "Everyone". If read access is no longer required then an editor of the record can go in and change "Everyone" to a group called "Recycle Bin."
Please note that if there are other record permission fields in the application, users or groups may still have access if they are selected in those fields. Perhaps You can set up a dropdown status field for the user to select "Recycle Bin" and use this condition for automatic record permissions to revoke permission to the record depending on the requirements or workflow of the application.
Solution shared by Igritte might be somewhat confusing for end users.
End user will see greyed out "Delete" button in the top toolbar, but he has to select "Recycle Bin" in the form. This solution was not accepted by my business owner at some point.
As a work around for "Soft delete", I wrote a custom object overriding "Delete" button functionality.
1. User doesn't have delete access to the record, so JavaScript code will make "Delete" button look like active and available.
2. Once the button is clicked, custom object will populate value in the
hidden value list and simulate the click on the "Save" button.
Update: Note that Custom object needs to hide the value list first once the page is loaded. Here you will need to use a JavaScript and do the following: [a] locate the value list DOM object and [b] set display attribute to none. I used jQuery library to do both. This way your value list is not displayed, but you still can use it to control data driven events.
3. With hidden value populated and submitted, record permission will hide this record from the end user.
Note that custom object hides one value list on the layout as well.
If for some reason JavaScript doesn't load properly, user simply will not be able to click on the grayed out "Delete" button.
Update: Hidden value list can be populated by custom object using JavaScript code as well. You need to identify the form tag "input" in HTML code of the page and set attribute "value" to the desired state. I used jQuery library to do this as well.
I have this solution in production working fine with IE11, FF and Chrome.
I can't share the code, but with WC3Schools JavaScript guides and 4 hours you can write and test it yourself with very little JavaScript skills.
Sometimes you have to use custom objects when you want to get a user-friendly solution of not available functionality.
Good luck!