Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3049 Vistas

Hi friends,

I want to put a Reset button inside a form and if the user clicks this button in edit/draft mode then reset some fields to default values.

Here are my problems:

  1. Some fields in the form view are of the type required and when I press the Reset button, Odoo makes red these fields before executing my reset function!!! It's annoying.
  2. Fields are of different types (ex. Monetary and others). How can I reset all to the default value at once?
  3. Has Odoo any utility to Reset the form?


Avatar
Descartar
Mejor respuesta

Hi,

Why to have a new button when we already have a discard button by default in the header ?



Thanks

Avatar
Descartar
Autor

I have a form with many fields. If I click the Discard button, the form get closed and all filled fields get removed but I don't want that. Suppose we have 100 fields in a form and refilling those is not easy.

but by introducing a new button how will you distinguish which one to keep and which one to reset ?
coming to your question, if you need a make a button clickable bypassing the required fields, there was some apps in the store and also using js it can be done similar to current discard button

Autor

about your question in the first line of your comment, we will have a function that calls when the button is clicked. In the body, we can clear mentioned fields.
But, the main problem is that when you push any Odoo button, before the actual method is executed the current record is saved (either 'created' or 'written'). It means that a check for 'required' and being filled is made before you fill the value in your method.

Publicaciones relacionadas Respuestas Vistas Actividad
1
abr 24
1353
3
jun 23
1930
1
may 24
1044
1
sept 23
1759
0
abr 23
1430