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

I have developed a new module in openerp to enter the warranty details of the customer.Each entry made is displayed in the tree view.I want to set a unique no.in a specific format to each of the entry.Now there entries are generated with numbers 25,26,29.I want some recognizable number so that I can easily identify each entry when used in reference fields.How can this be done?

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

You can use sequence for generating unique number like SO001 if you want to auto generate. Or you can apply unique constraint for the field of the specific object in case of manual entry.

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

I want to autogenerate the no.But how to autogenerate unique numbers for each entry using sequence in warranty module?what are the steps involved?

For that you need to create sequence file with the sequence based on your requirement. Then apply that sequence in the field you want from .py file. You can refer sale_sequence.xml for the name field of sale order. You need to define 'name': lambda obj, cr, uid, context: '/', in _defaults of the object.

Tác giả

where to give the name of the sequence file created thus?

Tác giả

Can you be a bit descriptive?

Create sequece file in your module. Include that file in to _openerp_.py file in data tag. 'data': ['sale_sequence.xml',]. e.g. name': fields.char('Order Reference', size=64), and in _defaults = { 'name': lambda obj, cr, uid, context: '/', }. Then override the create method where you need to fill the sequence in name field. E.g. def create(self, cr, uid, vals, context=None): if vals.get('name','/')=='/': vals['name'] = self.pool.get('ir.sequence').get(cr, uid, 'sale.order') or '/' return super(sale_order, self).create(cr, uid, vals, context

Tác giả

where to give this code?e.g. name': fields.char('Order Reference', size=64), and in _defaults = { 'name': lambda obj, cr, uid, context: '/', }.

in object of your module. Suppose test.test object contains name field. then the code should be in test.test

Tác giả

and the module is to be upgrraded to reflect changes no?

You need to restart the server and upgrade the module as for .py changes server needs to be restarted and for .xml changes module to be upgraded.

Tác giả

what does the ir.sequence in the .xml file represents?should it be declared somewhere in the files?

ir.sequence is the Table where all sequences are defined. you need to use this object in your sequence file.

ir.sequence is the Table where all sequences are defined. you need to use this object in your sequence file.

ir.sequence is the Table where all sequences are defined. you need to use this object in your sequence file.

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 3 15
11954
2
thg 9 17
8696
1
thg 1 24
13071
2
thg 8 25
3289
1
thg 2 22
3704