Odoo Help


Create HR Expense Using Custom Module

Cyrus Waithaka
on 1/13/15, 11:38 PM 999 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

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


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