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

Hello,

so i'v created  2 fields 

-Field 1 -> line (x_technical_info_line_ids_320ff) which contain a selection field (x_studio_gender)

-Field 2 -> integer (x_studio_num_of_female) to count the number of female (in the line)

so what i did is click on x_studio_num_of_female field -> More -> i went to compute and start coding this:


in dependecies:

x_technical_info_line_ids_320ff , x_technical_info_line_ids_320ff.x_studio_gender


in compute: 

t = 0
for record in self:
  for line in self.x_technical_info_line_ids_320ff:
    if line.x_studio_gender == 'female':
    t = t+1
    record['x_studio_num_of_female'] = t


but it's not working, so kindly i need any help

thank you.

Ảnh đại diện
Huỷ bỏ
Tác giả

Thank u so much mr.niyas, i wish that i could mark u'r answer as a best answer but i can't because of this " 5 karma is required to perform this action. "

Câu trả lời hay nhất

Hi,

Can you try with below code and see:

for record in self:
t = 0
for
line in self.x_technical_info_line_ids_320ff:
if line.x_studio_gender == 'female':
t += 1
record['x_studio_num_of_female'] = t

For more info, see this: add compute field from user interface in Odoo


Make sure that the key of the selection field is female.

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 3 24
2393
2
thg 11 19
7398
1
thg 5 17
3723
1
thg 2 24
2044
2
thg 1 24
2444