Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
9023 Tampilan

We create new Journal Entries from 

1. Accounting > Accounting Entries > Journal Entries > Create
2. On save Journal Entry Number (name field) is created as /
3. On Journal Entry posting system generates its sequence number like GJ/2019/0004

How we can generate Journal Entry Number on Save? Odoo 12

Avatar
Buang
Penulis Jawaban Terbai

Here is, how I done it by overriding Create method,

class SCTAccountMove(models.Model):
_inherit = 'account.move'
@api.model
def create(self, values):
result = super(SCTAccountMove, self).create(values)
journal = values.get('journal_id') and self.env['account.journal'].browse(values.get('journal_id'))
if journal.sequence_id:
sequence = journal.sequence_id
result['name'] = sequence.with_context(ir_sequence_date=values.get('date')).next_by_id()
else:
raise UserError(_('Please define a sequence on the journal.'))
return result
Avatar
Buang

Allthough this may work, it is not a solution. Either it is an Odoo bug and should be properly reported, or Lars' suggestion should be applied.

Penulis

Hii twanda AG. Its default in odoo 12. On save journal entry number is not generated. It is generated in post method. But our customer need to generate it on Save method, so I tried to do it like this.

Ah, now I see, sorry for the misunderstanding and forget my comment.

Penulis

No problem. I am happy you commented.

What does happen then with the sequence, when you post the entry later?

Penulis

Good question.

In the post method there is if move.name == '/': but now in my case its not '/' its like 'GJ/2019/0004' so system will not generate any sequence.

So far working fine with us on posting.

Jawaban Terbai

Looks like something gone wrong woth the number sequence.

Activate developer tools.  Go to Accounting->Configuration->Journals. Open the journal you need to modify.

You find a field named Next Number. There you should see a link to the sequence related to the journal. Click on it and you can modify the sequence.

A sequence should be generated automatic when a journal is created.


Avatar
Buang
Penulis

Hii Lars. In Odoo 12 when we create a journal entry and save it, system do not generate next number sequence instead it assigns '/' to the name field. When Posting the entry at that time system generates number sequence. In the save method they are not calling number sequence, they are calling it in the post method.

What I did is to generate sequence in Save method to fulfill our requirements.

Post Terkait Replies Tampilan Aktivitas
I need a module. Diselesaikan
1
Mar 15
3350
2
Jul 25
1399
0
Jan 24
1404
1
Nov 23
1664
1
Sep 23
2329