Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3576 Widoki

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!

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
lip 25
4491
2
gru 24
7668
2
lis 24
28433
2
maj 24
7405
3
mar 24
6816