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

I currently have a field called target price, and I want to take the product cost, divide it by a number and put the result in the filed.

This is my current script:

Field name: x_studio_target_price_1
Dependencies: standard_price
Compute: for record in self:
record[("x_studio_target_price_1)] = record.standard_price / 1.15

Standard_price is the field name for the cost in odoo product.template object. 

Whenever I use this script it doesn't give me any errors but nothing is being computed either. Can someone help?

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

@Chris TRINGHAM I don't have enough karma to comment to your post buy your solution worked! Thank you so much!

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

I got it working with this syntax: 

for record in self:
record['x_studio_target_price_1'] = record.standard_price / 1.15
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi!

Try to assign the 1.15 value to another field, for example, calling it "targetfactor"=1.15 

Then do:

record[("x_studio_target_price_1)] = record(standard_price)* record(targetfactor)


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
7
thg 11 15
14225
0
thg 9 17
3846
3
thg 9 24
1423
0
thg 12 23
1358
0
thg 10 21
2949