Skip to Content
Menu
This question has been flagged
2 Replies
4564 Views

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
Discard
Author Best Answer

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
2
Jul 24
404
1
Jan 24
420
2
Apr 24
1918
1
Jul 22
890
0
Oct 24
12808