Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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="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!
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
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 6/16/14, 3:06 PM|
|Seen: 1332 times|
|Last updated: 3/16/15, 8:10 AM|