Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1908 Lượt xem

I would like to set a positive value field into negative value filed depends on selection of other field.


For ex: I have field1  = 50 

if I select other filed, select.field is option1 to get field1 = -50

I tried with automation from studio, on save, if select field is option1,  compute record.field1 = -abs(record.field1), but not works

Thanks

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Bogdan,

You can achieve your requirement by using a compute method in Odoo Studio. Here's how you can set it up:

Dependencies: x_studio_selection

Compute method:

for record in self:
    if record.x_studio_selection == 'option1':
        record['field1'] = -(record.field1)

This compute method checks the value of the x_studio_selection field for each record. If it equals 'option1', it negates the value of field1.

Hope it helps

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thanks so much, it works on this solution. Now, Let me know how to add record on compute for select option2 to get positive on field1. If i modify the option1 into option 2 the value of field1 remain negative and if i select again option1 the field 1 will be positive. It is normal because - with - is plus. My expectation is to have individual on each option:

option1 to get - field1

option2 to get +field1

Thanks for understanding

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 11 19
6753
1
thg 5 17
3252
1
thg 2 24
1626
2
thg 1 24
1943
1
thg 5 23
14341