콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
2416 화면

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

아바타
취소