Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
27971 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 23
2778
1
thg 11 22
3057
Cannot create task Đã xử lý
2
thg 6 20
3302
2
thg 7 18
6809
4
thg 7 18
7644