Skip to Content
Menu
This question has been flagged
1 Reply
4221 Views

Hi,

I have two fields which i want to convert theme to sequences

the idea is to make a sequence named "rayon" depend on another sequence named "casier"

this casier will take just {1,2,3,4,5,6,7,8} and it will restart like a loop

but the rayon sequence will not do the increamentation until the casier restart from 1 

The Final result should be like this : 


Record 1 : rayon=1 | casier=1

Record 2 : rayon=1 | casier=2

....

Record 8 : rayon=1 | casier=8

Record 9 : rayon=2 | casier=1


I will be very grateful if anyone can transform this to an odoo code 10


Regards

Avatar
Discard
Best Answer

Hi Medmars,

     You have to create one record under "ir.sequence" model.

then use this code in your python file.

a = 1
@api.model
    def create(self, vals):
        global a
            if self.env['ir.sequence'].search([('name', '=', 'Record Name')]).number_next_actual == 9:
                self.env['ir.sequence'].search([('name', '=', 'Record Name')]).number_next_actual = 1
                a+=1
            t = self.env['ir.sequence'].next_by_code('Model name')
            inc =self.env['ir.sequence'].search([('name', '=', 'Record Name')]).number_next_actual
            vals['field name'] = t
            vals['rayon'] = "R"+str(a)
            vals['casier'] = "C"+str(inc)
            return super(Class name, self).create(vals)

you can change the value as per your requirement.


Hope this will help you...Thanks!

Avatar
Discard
Author

Thanks so much for your feedback

Should i create 3 records on ir.sequences ( Casier, Rayon, and T.seq )

and What to put under vals['field name'] = t

Author

Can you please give your email i want to share with you my model and ir.sequences if it is possible

if you want to display seq. for another field, then use "vals['field name'] = t", otherwise not.

Author

Sorry but i give me at each time

R1 | C1