Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
2398 Переглядів

Hi,

I made a SQL Constraint in a form but unfortunately it didn't work very well, because we when enter something wrong it give us the constraint error( the Form still not saved), but the problem is behind  the system make the incrementation of the sequence.

How can make a validation of Constraint without incrementing the Sequence ?

 
Аватар
Відмінити
Автор Найкраща відповідь

Hi i found the solution :

It's the actually issue of sequence type.

There are two types (Implementation) of sequence used in odoo : - Standard an d -No Gap

Standard

If you selected this implementation type in sequence (it's default) then sequence will be created in postgresql and managed by postgresql. There is no such control over it. So in case any transactions gets failed then sequence (next number) won't rollbacked.

No Gap

If you select this implementation type then it will be managed by odoo, so in case any issue is there then no sequence number will be skipped.

Аватар
Відмінити
Найкраща відповідь

Hi ,

As far as i understood your problem is that, the sequence get  generated once the form is opening.

To solve this you can create the sequence to get created only once the from get saved. For that you can super the create function.

@api.model
def create(self, vals):
if vals.get('name', 'New') == 'New':
vals['name'] = self.env['ir.sequence'].next_by_code('model_name') or '/'
res = super(ClassName, self).create(vals)
return res

Thanks

Аватар
Відмінити