Skip to Content
Menu
This question has been flagged

Please, i have this code  

def evaluate_transport(self):

print "computing transport information"

total_expense_no_affect_salary = 0

total_expense_affects_salary = 0

total_income = 0

for i in self:

for j in i.transport_invoice_ids:

total_income += j.inc_amount

if j.affects_salary:

total_expense_affects_salary += j.exp_amount

else:

total_expense_no_affect_salary += j.exp_amount

i.total_expense = total_expense_no_affect_salary + total_expense_affects_salary

i.total_expense_no_affect_salary = total_expense_no_affect_salary

i.total_expense_affects_salary = total_expense_affects_salary

i.total_income = total_income

print str(i.total_income) + " \n"

print str(i.total_expense) + " \n"

print str(i.total_expense_no_affect_salary) + " \n"

print str(i.total_expense_affects_salary) + " \n"

print "Done with total income and total expense"


The function is by a button click. 
Trying to sum based on a boolean field and i get the error 


Uncaught Error: QWeb2 - template['ShowPaymentInfo']: No enumerator given to foreach
http://192.168.1.122:8069/web/static/lib/qweb/qweb2.js:48
Traceback:
Error: QWeb2 - template['ShowPaymentInfo']: No enumerator given to foreach
    at Object.QWeb2.tools.exception (http://192.168.1.122:8069/web/static/lib/qweb/qweb2.js:48:19)
    at Object.QWeb2.tools.foreach (http://192.168.1.122:8069/web/static/lib/qweb/qweb2.js:195:22)
    at Engine.eval (eval at <anonymous> (http://192.168.1.122:8069/web/static/lib/qweb/qweb2.js:404:33), <anonymous>:20:23)
    at Engine.QWeb2.Engine.QWeb2.tools.extend._render (http://192.168.1.122:8069/web/static/lib/qweb/qweb2.js:393:58)
    at Engine.QWeb2.Engine.QWeb2.tools.extend.render (http://192.168.1.122:8069/web/static/lib/qweb/qweb2.js:385:26)
    at OdooClass.form_common.AbstractField.extend.render_value (http://192.168.1.122:8069/account/static/src/js/account_payment_widget.js:24:32)
    at OdooClass.<anonymous> (http://192.168.1.122:8069/web/static/src/js/views/form_common.js:704:22)
    at OdooClass.Class.extend.trigger (http://192.168.1.122:8069/web/static/src/js/framework/mixins.js:222:31)
    at OdooClass._.extend.trigger (http://192.168.1.122:8069/web/static/src/js/framework/mixins.js:272:42)
    at http://192.168.1.122:8069/web/static/src/js/framework/mixins.js:338:22


I have not used any javascript code. 

I have a transport.invoice and transport.invoice.line model, following same way account.invoice and account.invoice.line is implemented. 

    Want to sum all income and expense(determined by a checkbox) items on the transport.invoice.line 


Please, any help. 

Am still new to odoo so sorry if i have wrong convention. 

Avatar
Discard
Author

Using odoo 9

You need to put upload your code to github and provide us the link to determine what is causing your problem

Related Posts Replies Views Activity
1
Dec 24
127
2
Nov 24
84
1
Oct 24
264
0
Sep 24
213
2
Sep 24
648