Skip to Content
Menu
This question has been flagged
4 Replies
3473 Views

Hi,

Normaly seqeunces are made to make an incremention in any new record but what i'm looking for is to repeat the same number many times for exemple : 

Record 1 : sequence = 1 

Record 2 : sequence = 1 

Record 3 : sequence = 2

Record 4 : sequence = 2

Record 5 : sequence = 3

Record 6 : sequence = 3

PS : Using one and the same sequence each time

Avatar
Discard
Best Answer

Hi,

    I'm not sure if there is any predefined code for this, but you can achieve this by dividing your sequence number by number of times you need to repeat it and then adding 1 to it.

If you want to repeat it 3 times, the code should look like,

vals['seq_num'] =( vals['seq_num']/3)+1

Avatar
Discard
Best Answer

vals['seq_num'] =math.ceil(vals['seq_num']/2)

Avatar
Discard
Best Answer

Hi, 

i think when you create a new record, you make a call ir.sequence in create function, so its automatically call the function,

 def next_by_code(self, sequence_code):


this function make the number_next_actual to next number, so you do one think, super the create function and check with a condition(How many times its to repeat) and change number_next_actual in ir.sequence to the previous one.
it will works fine. 
thanks.
 

Avatar
Discard
Author

Thanks nikhil but the idea is not clear for me as you know i'm still new on odoo.