İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
5648 Görünümler

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. 


Avatar
Vazgeç
Üretici En İyi Yanıt

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.

Avatar
Vazgeç
En İyi Yanıt

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
Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Haz 25
15387
3
Nis 25
5561
Compute Fields Çözüldü
2
Tem 24
2612
1
Oca 24
1834
1
Tem 22
2245