Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
9283 Visualizzazioni

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
Abbandona
Autore Risposta migliore

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
Abbandona

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.

Autore

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.

Autore

No problem. I am happy you commented.

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

Autore

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.

Risposta migliore

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
Abbandona
Autore

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 correlati Risposte Visualizzazioni Attività
1
mar 15
3518
2
lug 25
1611
0
gen 24
1618
1
nov 23
1843
1
set 23
2538