Odoo Help


Adding Date To Sales Order Number

Alex Gallien
on 6/16/14, 3:06 PM 1,332 views

I am trying to change the naming scheme of Sales Orders to incorprate the date, in the format SOyymmdd###, where yy is the year, mm is the month, dd is the day, and ### is the padding for the orders created that day. I think I have found the code that creates the names in /addons/sales/sale_sequence.xml:

        <record id="seq_sale_order" model="ir.sequence">

            <field name="name">Sales Order</field>

            <field name="code">sale.order</field>

            <field name="prefix">SO</field>

            <field name="padding">3</field>

            <field name="company_id" eval="False"/>



Is it posible to add a dynamic name based on the date here? Or would it be somewhere in sale.py? Or is there an easier way to customize this? Thanks!

On sale.py you can find the 'name' field default in copy method.

on 6/17/14, 12:33 AM
Eva Pinter
On 6/16/14, 7:11 PM

Hi Alex

There is no need to change the code to do it. It is preferable to go to the settings ->Sequence and identifiers->Sequence. There you can choose sales.order and define what you want to see there.

Good luck

On 6/17/14, 12:31 AM

I think much better if you inherit the sale_order create def.

import datetime # must put this your import section

    def create(self, cr, uid, vals, context=None):
            if vals['name'] <> '':

                pad_s = self.pool.get('ir.sequence').get(cr, uid, 'sale.order') # get seq. like : 'SO111'

                pad_s = pad_s..replace('SO','') # remove the 'SO' from the seq number

                your_new_so_name = 'SO' + str(today.strftime("%y/%m/%d")) +'-' + str(pad_s)

                # >target is 'SO'SO14/06/17-001
                vals.update({'name': your_new_so_name})
        return super(sale_order, self).create(cr, uid, vals, context=context)

Please note I don't test it.. (print varaible for the check..)

I am sure you need to modify the copy method also, if somebody duplicate the SO the name must be prepare.


P.m.: for inheriting a model you can find a lot of good tutorial:




and so on...


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 6/16/14, 3:06 PM
Seen: 1332 times
Last updated: 3/16/15, 8:10 AM