Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
5647 Prikazi

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
Opusti
Avtor 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
Opusti
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
Opusti
Related Posts Odgovori Prikazi Aktivnost
1
jun. 25
15387
3
apr. 25
5560
2
jul. 24
2610
1
jan. 24
1834
1
jul. 22
2245