This question has been flagged

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"/>
Avatar
Discard

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.

Best Answer

Just checking everything went OK:

Steps to take when modify code / XML:

  • copy files to /addons/ directory
  • restart openERP server (or reboot computer), to let openERP see the changed code
  • within openERP, reload the modules
  • within openERP, search for installed module, select it, and click on upgrade. This will reload the XML file, so the changed/added button is functional.

If the above steps have been done, and you still encounter, issues, let us know.

Avatar
Discard
Author

I know how to upgrade when required and i did the same but my question is that i don't get an error there but there is no output also on the button so i am asking whether the code is correct or i missed something.

In that case, what does the logging file tell you, when you press the button? By default, the log file on Linux: /var/log/openerp/openerp-server.log