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

I am trying to create a read-only field x_total_salary in hr.contract model in Odoo 10 in web debug mode (I dont have access to the module code files) which would show the total gross salary in the contract creation form. Value of x_total_salary should be simple addition of the fields: wage + x_conv_alw + x_med_alw + x_other_alw in the same model which I tried to put in the "Compute" box of x_total_salary. I put <field name=" x_total_salary"/> in the contract creation form which unfortunately shows 0.

Any idea how to put such simple calculation in the computed fields please?

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

The code is somewhat weird for a newbie like me:

for record in self:

    record['x_total_salary'] = record.wage + record.x_conv_alw + record.x_med_alw + record.x_other_alw
The weird part is it would be "record['x_total_salary']" not "record.x_total_salary" !!

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 10 25
471
1
thg 9 25
1043
0
thg 8 25
1564
1
thg 7 25
1382
0
thg 6 25
1236