Odoo Help


2 Answers

Muhammad Anees Saudi Arabia

--Muhammad Anees--

| 7 3 9
Riyadh, Saudi Arabia
--Muhammad Anees--

Odoo, Dynamics AX and Web Developer.

Muhammad Anees Saudi Arabia
11/17/19, 4:28 AM

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

class SCTAccountMove(models.Model):
_inherit = 'account.move'
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()
raise UserError(_('Please define a sequence on the journal.'))
return result
twanda AG, Ermin Trevisan Switzerland
11/18/19, 12:21 AM

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.

Muhammad Anees Saudi Arabia
11/18/19, 12:36 AM

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.

twanda AG, Ermin Trevisan Switzerland
11/18/19, 1:45 AM

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

Muhammad Anees Saudi Arabia
11/18/19, 1:47 AM

No problem. I am happy you commented.

twanda AG, Ermin Trevisan Switzerland
11/18/19, 1:47 AM

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

Muhammad Anees Saudi Arabia
11/18/19, 1:58 AM

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.


Lars Aam Norway

--Lars Aam--

| 2 2 6
Kolnes, Norway
--Lars Aam--

Taken my pension, but still got a lot of energy. 

Worked as General manager, Logistic manager and SAP functional consultant (In Nexans). 

I always used ERP systems as a tool to better control our business.  And specially in Logistic operations.  

Currently helping an earlier colleague to set up Odoo for a new manufacturing business. Interesting...

Lars Aam Norway
11/17/19, 11:50 AM

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.

1 Comment
Muhammad Anees Saudi Arabia
11/18/19, 12:32 AM

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.

Ask a Question
Keep Informed
1 follower(s)
About This Community

This platform 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.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now