There are two additional ways I can think of:
- use models.NewId: This doesn't give you an actual ID (integer) but depending on your code you can use it as a placeholder.
Usage:
if isinstance(self.id, models.NewId):
# your code
(note that in this case self.id does not exist in the db yet, but you can imagine it is already "pre-ordered" in the cache)
- It helps to know that Odoo assigns IDs in a strictly linear way: The next record will always have the ID of the previously created record plus one. I guess it is a bit of a cheaty way to work with this fact & it is only useful if you are 101% sure that nobody creates or deletes records "in between". However if you decide to try this method a good approach would be:
recordset = self.env['your.model'].search([('id', '!=', False), limit=1, order="id desc")
This will give you exactly one recordset (the newest one) & accordingly exactly one ID.
previous_id = recordset.ids[0]
So the "not yet existing" ID you are looking for is: newest_id = previous_id + 1