Search code examples
pythonodooopenerp-7

What is the class/file that creates invoices in openerp 7


Im new in openerp, and i need to crete an hash when the invoice is created and add that hash to database. I've already created the hash, i just need to know where can i edit the method that creates invoices.

Thanks in advance.


Solution

  • The method is called Create, overwrite it:

    def create(self, cr, uid, values, context=None):
    
        values['your_hash_column'] = 'your_hash_result'
    
        res = super(YourClassName, self).create(cr, uid, ids, values, context)
    
        return res
    

    Be sure that the "YourClassName" is the name of the class that you are using.

    Explanation: The create method use the dictionary "values" to append the results in the db, if you add to that dict a new value (in that case your hash) and you call it again with super, you will have the same result with that value, then you return it.