Ir al contenido
Menú
Se marcó esta pregunta
3124 Vistas

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 '',
            },context=context)
        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

Avatar
Descartar