I created a function in account_invoice.py to check whether the due date is over and if yes then add 2% of the amount_total/balance to the amount_to be paid. I tried this code in account_payment.account_invoice and created an automated action too but there is no error and result. Why am i missing something? here is the code and the xml on which i tried calling this function.
def check_penalty(self, cr, uid, ids,context):
'''Return the amount still to pay regarding all the payment orders'''
if not ids:
return {}
res = {}
for invoice in self.browse(cr, uid, ids, context=context):
res[invoice.id] = 0.0
if invoice.date_due or \
datetime.strptime(invoice.date_invoice, '%Y-%m-%d') \
>= datetime.strptime(invoice.date_due, '%Y-%m-%d'):
res[invoice.id][residual]+= invoice.residual * 0.02
self.write(cr, uid, ids, {'residual':'resudual'}, context=context)
return res
xml:
<button name="check_penalty" string="Penalty" type="object" icon="gtk-ok"/>
The comment for this methid is not completely correct. You are returning the amount to pay per order, not one big amount for all open orders, which I would expect given your comment.