Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2172 มุมมอง

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?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
ผู้เขียน

but this will make one sequence
xx001
ff002

ผู้เขียน

i need xx001
ff001
xx002
hh001
hh002
ff002

Related Posts ตอบกลับ มุมมอง กิจกรรม
Two Sequance For One Object แก้ไขแล้ว
3
ต.ค. 24
14120
0
ต.ค. 24
2521
1
พ.ค. 25
2436
1
ก.ย. 24
1341
1
ต.ค. 23
2529