Odoo Help


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.


Create HR Expense Using Custom Module

Cyrus Waithaka
on 1/13/15, 11:38 PM 525 views

I am looking for information on how to create a record in hr_expense_expense table when my model is created. I have this code in my custom module:

   def create(self, cr, uid, vals, context=None):
        expense_id = super(hr_expense_expense, self).create(cr, uid,{
            'name': vals['project_name']+' Expenses' or 'No Name',
            'employee_id': vals['project_head'] or '',
        for tender in self.browse(cr, uid, ids, context=context):
           self.write(cr, uid, [tender.id], {'expenses_account': expense_id}, context=context)
        return expense_id

In this, I intend to create an expense, and then update a field in the current model with the returned hr_expenses_expenses id. This is however not creating the HR expense as intended.

Can anyone please help me fix this so that whenever I create my custom model, a hr expense record is also automatically created

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

1 follower(s)


Asked: 1/13/15, 11:38 PM
Seen: 525 times
Last updated: 3/18/15, 6:41 PM