This question has been flagged
2 Replies
3971 Views

Hi everybody, i am trying to have a specific behavior in odoo v8. I would like to create an analytic account automaticaly when i am creating an employee. This analytic account should have the same name that employee's.

Avatar
Discard
Best Answer

Just put hr.employee model to inherits from account.analytic.account like project.project does

Avatar
Discard
Author Best Answer

Hi alex,

i did it like you said but i get error. That what i do :

class hr_employee(osv.osv):
_name = "hr.employee"
_inherit = ['hr.employee']
_description = "Employee"
_inherits = {'account.analytic.account': "analytic_account_id"}
_columns = {
'date_start': fields.date('Date Embauche'),
'diplome': fields.many2one('diplome', 'Diplome'),
}
hr_employee()

the error i get is this :

Integrity Error

The operation cannot be completed, probably due to the following:

- deletion: you may be trying to delete a record while other records still reference it

- creation/update: a mandatory field is not correctly set

[object with reference: name - name]

thanks in advance.



Avatar
Discard

You need to put the field analytic_account_id in your column, like: 'analytic_account_id': fields.many2one( 'account.analytic.account', 'Contract/Analytic', help="Link this project to an analytic account if you need financial management on projects. " "It enables you to connect projects with budgets, planning, cost and revenue analysis, timesheets on projects, etc.", ondelete="cascade", required=True, auto_join=True),

copied from project.project definition

Author

Axel i copy the code in project.py file. So i create the account.analytic.account field but i still yhe same error.