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

I have a weird problem in my view. The view functions like an excel table (editable one2many tree view in form view) where you have a few fields in a row where you can write values and a field that has the value of the calculations and it changes base to the values in other fields. All the data that is used, is in the same model.

Every field has a function that calculates its value based on the input. The weird thing is that it works until I add another if statement.

Working method:

@api.multi
@api.depends('field1_input')
def _field1_calc(self):
    for rec in self:
	if rec.pay_type == 'PL':
            rule = rec._get_rule('PRI')     if rule: rec.field1_value = rec._calculate_value(rule) elif rec.pay_type == 'RE':     rec.field1_value = 0

Non working method:

@api.multi
@api.depends('field1_input')
def _field1_calc(self):
    for rec in self:
	if rec.pay_type == 'PL':
	    if rec.gross_field1 > 0:
		rec.ure_field1_value = rec.gross_field1 * rec.field1_input
	    else:
		rule = rec._get_rule('PRI')
		if rule:
	    	    rec.field1_value = rec._calculate_value(rule)
	elif rec.pay_type == 'RE':
	    rec.field1_value = 0

Did I Fed up somewhere? I just can't see the problem or figure out why it doesn't work?

Does anyone see a problem or has an idea what can cause the problem? I'm at a total loss so any hint would be appreciated!

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 25
4500
2
thg 12 24
7670
2
thg 11 24
28436
2
thg 5 24
7411
3
thg 3 24
6823