コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
9127 ビュー

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

アバター
破棄
著作者 最善の回答

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
アバター
破棄

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.

著作者

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.

著作者

No problem. I am happy you commented.

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

著作者

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.

最善の回答

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.


アバター
破棄
著作者

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.

関連投稿 返信 ビュー 活動
1
3月 15
3414
2
7月 25
1488
0
1月 24
1469
1
11月 23
1755
1
9月 23
2424