تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3579 أدوات العرض

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!

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
يوليو 25
4491
2
ديسمبر 24
7669
2
نوفمبر 24
28433
2
مايو 24
7407
3
مارس 24
6817