Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
10265 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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.

ผู้เขียน

Thanks.

คำตอบที่ดีที่สุด

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




อวตาร
ละทิ้ง
ผู้เขียน

Thanks for your response.

Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ต.ค. 19
3608
5
พ.ค. 21
21261
4
มี.ค. 15
6676
0
เม.ย. 25
2466
0
ก.ค. 24
1748