I need import employees(hr.employee object) from xml and to tie them with users(res.users object) and contacts(res.partner object). Relation with user working is good(screen below after import).
But I have problem with contacts. When system import user she authomatically create new contact which applies to user. How I can to tie this contact with employee if I don't know ID?
I tried add contact record to xml file and set relations. But in this case system creates 2 contacts. And one of them is not related to user.
Here my xml for import from my module.
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="user_test" model="res.users">
<field name="name">My Name</field>
<field name="login">my_name</field>
<field name="password">1111</field>
</record>
<!-- I tried create contact like this...
but then will be created 2 contacts
instead 1 + one of them is not related with user -->
<!--<record id="contact_test" model="res.partner">-->
<!--<field name="name">My Name</field>-->
<!--<field name="user_id" ref="user_test"/>-->
<!--</record>-->
<record id="employee_test" model="hr.employee">
<field name="name">My Name</field>
<field name="work_email">[email protected]</field>
<field name="user_id" ref="user_test"/>
</record>
</data>
</openerp>
So, my question is: How I can to set contact(which was created authomatically from user) to employee?
user_id
. Because I can't remove contact from GUI. I get 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 link: Users - res.users]
– Danila Ganchar<record id="contact_my_name" model="res.partner"> <field name="name">My Name</field> </record>
. It is possible add some values to this record after tag </record>? – Danila Ganchar