Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

No action on function calling?

By
evon_dun
on 5/24/13, 7:25 AM 1,325 views

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.

patrick
on 6/2/13, 7:39 PM
0

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
On 5/24/13, 7:50 PM

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.

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.

evon_dun
on 5/27/13, 3:05 AM

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

patrick
on 6/2/13, 7:37 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 5/24/13, 7:25 AM
Seen: 1325 times
Last updated: 3/16/15, 8:10 AM