Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
9027 Zobrazení

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
Zrušit
Autor Nejlepší odpověď

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
Zrušit

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.

Autor

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.

Autor

No problem. I am happy you commented.

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

Autor

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.

Nejlepší odpověď

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
Zrušit
Autor

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.

Related Posts Odpovědi Zobrazení Aktivita
1
bře 15
3351
2
čvc 25
1403
0
led 24
1406
1
lis 23
1666
1
zář 23
2334