Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
3587 Weergaven

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
2
jul. 25
4502
2
dec. 24
7674
2
nov. 24
28441
2
mei 24
7414
3
mrt. 24
6824