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

For example I have a selection field like this :

'state': fields.selection([('start','Start'),('break','Break'),('finish','Finish')], 'State', readonly=True),

In the other condition I want to change 'Start' to be 'In Progress'.

How can I do it?

아바타
취소
베스트 답변

Go through this link:

https://www.odoo.com/forum/help-1/question/how-to-change-the-values-for-a-selection-field-72934

If your selection field is static list of tuples defined in field, then there is no way to do. If it is a method or global variable you can change it.

Using Global Variable:

GLOBAL_VALUE = [('1', 'Excellent'), ('2', 'Very Good')]

'your_field': fields.selection(GLOBAL_VALUE, 'Field Name')

Using Method:

    def _your_method(self, cr, uid, context=None):
        return [('1', 'Excellent'),('2', 'Very Good')]

'your_field': fields.selection(_your_method, string='Field Name')

Return the values based on your need.

아바타
취소
작성자

How to do it in method or global?

I have updated my answer.

작성자

Ok, thanks you Mr. Dhinesh

베스트 답변

Dhinesh has pointed you to the correct link.

Below I am giving an extract of the exact portion from the page in response to your query of how to do it in a method.

  1. Specifying using a method: 'field_1': fields.selection(_method_name, 'Field Label').  Where _method_name is defined beforehand:

def _method_name(self, cr, uid, context=None):

    return [('value1', 'String 1'), ('value2', 'String 2')]

아바타
취소