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

Hi. I've created two custom fields in my sale.order model:

  1. Order Prirority: Field Name: x_order_prirority, Field Type: selection, selection_ids (1 for '!', 2 for '!!', 3 for '!!!')

  2. Rush: Field Name: x_rush, Field Type: boolean.

What I want to do is this: I placed these two fields on the sales order form, and when the priority is selected as "!!!", I want the Rush field would be checked

I wrote these lines of codes in x_rush field compute area, and it gave me syntax error. I'm new to Python language. 

Dependencies: x_order_prirority

Compute: for record in self:
  if record ['x_order_prirority'] = 3 :
    self = true

Any help? Thanks. 


아바타
취소
작성자 베스트 답변

Thanks @Hilar for you answer, I tried to comment you answer directly, but I don't have enough Karma. (By the way, this Karma thing is bullshit!)

Your answer gave me some light on this matter, though I'm having the same syntax error.

I also tried this: 

Since the x_order_prirority is a selection, so I wrote the code like this: 

for record in self: 
    if record.x_order_prirority.selection_ids.value = '3' :  // selection_ids.value is actually a 'char' type, not an integer
        record.x_rush = True

But again, syntax error.

Any help? Thanks.

아바타
취소
베스트 답변

self will be the current model object. you must assign values as

self.field_name = x or self['field_name'] = x

In your case it must be

for record in self:
  if record ['x_order_prirority'] = 3 :
    record.x_rush = True
아바타
취소
관련 게시물 답글 화면 활동
1
6월 25
15393
3
4월 25
5573
Compute Fields 해결 완료
2
7월 24
2680
1
1월 24
1838
1
7월 22
2249