Odoo Help

Welcome!

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

0

Create a sequence number / internal reference for project task

By
Randall Risser
on 11/2/16, 2:47 PM 136 views

Odoo v9 online

How do I create sequence number for my projects task(s)?

I want to be able to have a new number generated for every new task I make and then be able to search/lookup my task from the search bar. The same as when you create a new Quote it creates a new quote number every time.

I have Odoo Saas online, so I can only add server actions to add any python code.

3

Nilmar Shereef

--Nilmar Shereef--
811
| 4 3 7
Calicut, India
--Nilmar Shereef--

Python Developer. Android Developer. .Net Developer

Nilmar Shereef
On 11/2/16, 11:28 PM

Hi Randall Risser,
If you want to add sequence number for every task, You have to add a field in task model and need to define a record in ir.sequence as xml.
For example:

in your project.task model please add one field and a function,

name = fields.Char(string="Task No", readonly=True, required=True, copy=False, default='New')

@api.model   

def create(self, vals):
        if vals.get('name', 'New') == 'New':
                vals['name'] = self.env['ir.sequence'].next_by_code('project.task') or 'New'       

        result = super(FlightReport, self).create(vals)       

        return result


In your XML:



Hope this may help you.

Thanks for your reply. What do you mean by "add a function"? Where do I do that?

I had already created a sequence under the technical menu in settings and I added The Char sequence field but I don't know how to trigger it. Thanks for your help.

Randall Risser
on 11/8/16, 10:00 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/2/16, 2:47 PM
Seen: 136 times
Last updated: 11/2/16, 11:28 PM