Odoo 11 필드 타입 1
기본타입
bollean (true / false)
fields.boolean('Field Name' [, Optional Parameters]),
integer (정수 타입.)
fields.integer('Field Name' [, Optional Parameters]),
float (부동적인 소수점 숫자.)
fields.float('Field Name' [, Optional Parameters]),
- TIP
선택적 매개변수 자리수는 숫자의 정밀도와 배율을 정의합니다. scale는 소수점 이하 자릿수이고 precision은 숫자의 유효 자릿수 (소수점의 앞뒤) 입니다. 매개변수 자릿수가 없으면 숫자는 배정 밀도 부동 소수점 자릿수가 됩니다. 이 부동 소수점 수는 정확하지 않으며 (값이 이진 표현으로 변환 될 수 없는 경우) 반올림 오류가 발생할 수 있습니다. 화폐 금액에는 항상 digits 매개변수를 사용해야합니다.
'rate': fields.float( 'Relative Change rate', digits=(12,6) [, Optional Parameters]),
char (제한된 길이의 문자열. 필요한 크기의 size에 따라 크기가 결정됩니다.)
'city' : fields.char('City Name', size=30, required=True),
text (길이 제한이 없는 텍스트 필드 입니다.)
fields.text('Field Name' [, Optional Parameters]),
date (날짜)
fields.date('Field Name' [, Optional Parameters]),
datetime (같은 필드에 날짜와 시간을 저장할 수 있습니다.)
fields.datetime('Field Name' [, Optional Parameters]),
binary (이진수 파일 *텍스트가 아닌 파일*)
fields.binary(),
selection (사용자가 미리 정의 된 값들 사이에서 선택할 수 있게합니다.)
fields.selection((('n','Unconfirmed'), ('c','Confirmed')), 'Field Name' [, Optional Parameters]),
- TIP
selection의 형식은 매개변수:튜플 형태의 문자열 입니다.
예)
(('key_or_value', 'string_to_display'), ... )
튜플을 반환하는 함수를 지정할 수 있습니다.
예 )
def _get_selection(self, cursor, user_id, context=None): return ( ('choice1', 'This is the choice 1'), ('choice2', 'This is the choice 2')) _columns = { 'sel' : fields.selection( _get_selection, 'What do you want ?') }
관계 필드를 사용하여 many2one을 선택합니다.
예 )
..., 'my_field': fields.many2one( 'mymodule.relation.model', 'Title', selection=_sel_func), ...,
그리고 필드 정의 앞에 다음과 같이 _sel_func을 정의하십시오
예 )
def _sel_func(self, cr, uid, context=None): obj = self.pool.get('mymodule.relation.model') ids = obj.search(cr, uid, []) res = obj.read(cr, uid, ids, ['name', 'id'], context) res = [(r['id'], r['name']) for r in res] return res
'Coding' 카테고리의 다른 글
Odoo 11 ::: Snippets Pagination (0) | 2018.04.17 |
---|---|
Odoo 11 ::: Fields Type에 대해 알아보자 (3) (0) | 2018.04.10 |
Odoo 11 ::: Fields Type에 대해 알아보자 (2) (1) | 2018.04.09 |
javascript ::: 도큐먼트 로드 순서 정의 (0) | 2018.03.29 |
Odoo 11 ::: Views (1) | 2018.03.06 |