Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
2134 Lượt xem

How can i make multi sequence based on another field

for example i have field named prefix and field named sequence 
the user can write any thing in prefix field
for example if the user write xx in prefix , then the sequence will be xx0001 
if he enter xx again then the sequence will be xx0002 , if he enter ff then the sequence will be ff0001......
the user can write any thing in prefix field , this field isn't selection it is Char field
any idea to make this?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

This can be achieved by inheriting the write method of your model and concatenating this two field values. 

def write(self, vals):
if vals.get('prefix'):
sequence = self.env['ir.sequence'].next_by_code('sale.order') or _('New')
vals['sequence'] = vals['prefix'] + sequence
return super().write(vals)

Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

but this will make one sequence
xx001
ff002

Tác giả

i need xx001
ff001
xx002
hh001
hh002
ff002

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 10 24
14045
0
thg 10 24
2474
1
thg 5 25
2370
1
thg 9 24
1308
1
thg 10 23
2487