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.

0

Customized the invoice number to include the month of the invoice date

By
J4nus
on 8/1/14, 7:29 AM 1,622 views

I would like to customize the invoice number.

I found the tips to go in the following menu:

  1. login as admin Go to Settings / Users
  2. Choose "admin" in the first column of user list
  3. switch to form view and click on "Edit"
  4. On tab "access rights" activate "Technical Features"
  5. Save & Click on the company logo to reload menus
  6. Go to menu Settings / Technical / Sequences & Identifiers / Sequences
  7. Choose "Account Default Sales Journal" and switch to form view
  8. Now you have to configure the sequence details to your example.

(from the link here: https://www.odoo.com/forum/help-1/question/how-do-i-customize-next-invoice-number-2779)

My issue is that the suffix %(month)s  is the current month, and not necessarly the month of the invoice date.

For example if we are the 01/08 and that I would like to write an invoice of 31/07, i will get "08" in the invoice number in place of "07". Is there a legend for the month of the invoice date in place of the current month ?

 

 

 

5

Janeesh

--Janeesh--
1641
| 4 3 4
Cochin, India
--Janeesh--

Odoo Developer

Janeesh
On 8/12/14, 9:19 AM

Hi,

This can be done by editing the _next function in ir.sequence object.

First add 'date' in context of any function where you calling this sequence. eg: contex['date'] = invoice_date. Then modify the _next function like this. Need to add only two lines. These lines are highlighted.

    def _next(self, cr, uid, seq_ids, context=None):
        if not seq_ids:
            return False
        if context is None:
            context = {}
        force_company = context.get('force_company')
        if not force_company:
            force_company = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
        sequences = self.read(cr, uid, seq_ids, ['company_id','implementation','number_next','prefix','suffix','padding'])
        preferred_sequences = [s for s in sequences if s['company_id'] and s['company_id'][0] == force_company ]
        seq = preferred_sequences[0] if preferred_sequences else sequences[0]
        if seq['implementation'] == 'standard':
            cr.execute("SELECT nextval('ir_sequence_%03d')" % seq['id'])
            seq['number_next'] = cr.fetchone()
        else:
            cr.execute("SELECT number_next FROM ir_sequence WHERE id=%s FOR UPDATE NOWAIT", (seq['id'],))
            cr.execute("UPDATE ir_sequence SET number_next=number_next+number_increment WHERE id=%s ", (seq['id'],))
        d = self._interpolation_dict()

        if 'date' in context:
            d['month'] = str(context['date'])[5:7]

        interpolated_prefix = self._interpolate(seq['prefix'], d)
        interpolated_suffix = self._interpolate(seq['suffix'], d)
        return interpolated_prefix + '%%0%sd' % seq['padding'] % seq['number_next'] + interpolated_suffix

 

 

I tried but it's not working. I created today (15/09/2014)an invoice for the 01/10/2014. I was waiting -10 but it was -09 (because the current month is September) so ithe month of the invoice is not followed by well the current month..

Renaud Dubois
on 9/15/14, 3:09 PM
0

IBS

--IBS--
1302
| 4 5 8
Tétouan, Morocco
--IBS--

For more informations about IBS, please visit our website at www.ibs-na.com.

For a specific questions, collaboration or help, please send us an email to support@ibs-na.com

IBS
On 8/10/14, 2:14 PM

You can't achieve this by configuration, some development is required.

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

1 follower(s)

Stats

Asked: 8/1/14, 7:29 AM
Seen: 1622 times
Last updated: 12/13/15, 4:46 AM