• Tek Siong, Hock

How to Have The Dynamic Sequence in Odoo

In the standard Odoo, the sequence number can be based on the date.

However, if you want the sequence number to be based on value of another field, then you have to override write method (you will never knows when the user will change the field value).

This is a simplistic codes to update the sequence no in the write method. You can add more validation if there is an existing sequence no and how you want to update it.

def write(self, vals):
    res = super(YourModel1, self).write(vals)
    for record in self:
        if vals.get('direction'):
           direction = vals.get('direction')
           new_sequence_no = direction + record.sequence_no
           record.write({'sequence': new_sequence_no})

67 views0 comments