Odoo Help

Welcome!

This community 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.

1

SEQUENCE IN ODOO

By
NIKHIL KRISHNAN
on 8/1/16, 11:27 PM 288 views

how to add current year in the sequence of a quotaion form name?

1

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 8/2/16, 6:20 AM

Hello

you can use SO%(y)s in the prefix field to include the current year ...

You can check the legend :

Legend (for prefix, suffix)


This will be the best method to add Year in Sequence.

Asmita Chavan
on 8/12/16, 9:05 AM
1
shameem@axon
On 8/2/16, 2:11 AM

It will help you

override create function in model sale.order

from openerp import models
import datetime

class SaleOrder(models.Model):
    _inherit = 'sale.order'

    def create(self, cr, uid, vals, context=None):
        if context is None:
            context = {}
        if vals.get('name', '/') == '/':
            vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'sale.order', context=context) or '/'
         # ================== ADDITIONAL LINES ================================================
            now = datetime.datetime.now()
            vals['name'] = vals['name'].replace('SO', now.year)
         # ====================================================================================
        if vals.get('partner_id') and any(f not in vals for f in ['partner_invoice_id', 'partner_shipping_id', 'pricelist_id', 'fiscal_position']):
            defaults = self.onchange_partner_id(cr, uid, [], vals['partner_id'], context=context)['value']
            if not vals.get('fiscal_position') and vals.get('partner_shipping_id'):
                delivery_onchange = self.onchange_delivery_id(cr, uid, [], vals.get('company_id'), None, vals['partner_id'], vals.get('partner_shipping_id'), context=context)
                defaults.update(delivery_onchange['value'])
            vals = dict(defaults, **vals)
        ctx = dict(context or {}, mail_create_nolog=True)
        new_id = super(sale_order, self).create(cr, uid, vals, context=ctx)
        self.message_post(cr, uid, [new_id], body=_("Quotation created"), context=ctx)
        return new_id




Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 8/1/16, 11:27 PM
Seen: 288 times
Last updated: 8/10/16, 4:43 AM