Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
102 Zobrazení

I have created a custom module in Odoo 18 with a form view for my model.

When I open the form view (without entering any data) and then navigate to another menu or tab, Odoo automatically creates a new record with empty/default values in the database.

This results in multiple “null” or blank records being created unintentionally.


My questions:

  1. Why does Odoo create these empty records?
  2. Is this the default behavior of form views in Odoo, or is it caused by my form view setup?
  3. How can I prevent Odoo from saving a record until the user clicks Save?

Any guidance or best practices for preventing these unwanted blank records would be appreciated.

Avatar
Zrušit
Nejlepší odpověď

If you have default values defined, the form in fact is not empty when navigating away - thus the auto-save feature hits. 


You could define a required field, without an default value, so it can't save when not set.


Alternatively you could extend the create() method and check for whatever makes you feel that the form should get saved now.

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
srp 25
721
2
srp 25
311
3
srp 25
1054
1
srp 25
616
3
srp 25
919