콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
7973 화면

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?

아바타
취소
베스트 답변

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.

아바타
취소
작성자

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.

작성자

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

작성자

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

작성자

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

작성자

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.

작성자

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.

관련 게시물 답글 화면 활동
4
3월 15
12173
2
9월 17
8907
1
1월 24
13248
2
8월 25
4348
1
2월 22
3887