Skip to Content
Menu
This question has been flagged
2806 Views

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!

Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
25061
2
May 24
5510
3
Mar 24
4961
0
Mar 24
261
3
Feb 24
11413