Odoo Migrations
Completed
recruitment app
Complete Process Documentation
Here's the complete documentation of the process for migrating recruitment data from Odoo 16 to Odoo 18:
1. Connecting to Odoo via API
First, we need to establish a connection to both Odoo instances using their XML-RPC API. This requires:
- URL of the Odoo instance
- Database name
- Username/email
- Password
2. Export Process from Odoo 16
- Connect to Odoo 16:
python
Copy
odoo16 = OdooAPI( url='https://16.caltek.net', db='ctnov9', username='kmw@caltek.net', password='your_password' ) odoo16.connect()
- Fetch all job applications:
python
Copy
applicants = odoo16.get_job_applications()
- Process applicants in batches:
- For each applicant:
- Get their basic information (name, email, phone, job position)
- Get attachments (resumes)
- Get communication history (messages)
- Get activities
- For each applicant:
- Save data to JSON files:
python
Copy
with open(os.path.join(export_dir, batch_filename), 'w') as f: json.dump(export_data, f, indent=2)
3. Analyzing Odoo 18 Structure
Before importing, we needed to understand the structural differences between Odoo 16 and 18:
- Examine fields in Odoo 18:
python
Copy
applicant_fields = odoo18.get_model_fields('hr.applicant')
- Key Differences Found:
- Odoo 18 introduces a new hr.candidate model
- Each applicant must be linked to a candidate via candidate_id
- The candidate model stores the person's information, while the applicant model represents a specific job application
4. Import Process to Odoo 18
- Connect to Odoo 18:
python
Copy
odoo18 = Odoo18ImportAPI( url='https://caltek.net', db='caltek_18a', username='kmw@caltek.net', password='your_password' ) odoo18.connect()
- Import process for each applicant:
- Create or find a job position
- Create a hr.candidate record (or find existing by email)
- Create a hr.applicant record linked to the candidate
- Upload resume files to both candidate and applicant
- Create message history
5. Key API Methods
- Search and Read Records:
python
Copy
def search_read(self, model, domain=None, fields=None, limit=None): return self.models.execute_kw( self.db, self.uid, self.password, model, 'search_read', [domain], kwargs )
- Create Records:
python
Copy
def create(self, model, values): return self.models.execute_kw( self.db, self.uid, self.password, model, 'create', [values] )
- Upload Attachments:
python
Copy
def upload_attachment(self, file_path, res_model, res_id, description=None): # Read file as binary data with open(file_path, 'rb') as file: file_data = file.read() # Create attachment record with base64 encoded data attachment_data = { 'name': os.path.basename(file_path), 'datas': base64.b64encode(file_data).decode('utf-8'), 'res_model': res_model, 'res_id': res_id, } return self.create('ir.attachment', attachment_data)
6. Field Mappings between Odoo 16 and 18
Odoo 16 Field | Odoo 18 Equivalent | Notes |
---|---|---|
name | partner_name (in hr.candidate) | Candidate name is now stored in the candidate model |
partner_name | partner_name | Present in both models |
email_from | email_from | Present in both models |
partner_phone | partner_phone | Present in both models |
job_id | job_id | Same relation to hr.job |
stage_id | stage_id | Same relation to hr.recruitment.stage |
description | applicant_notes | Field renamed in Odoo 18 |
- | candidate_id | New field in Odoo 18, required |
7. Major Structural Changes
- Two-Level Structure:
- Odoo 16: Single hr.applicant model for both candidate info and application
- Odoo 18: Separate hr.candidate model (person) and hr.applicant model (application)
- Benefits of New Structure:
- One candidate can have multiple applications
- Better separation of personal data and application data
- Improved candidate tracking and pipeline
- Import Implications:
- Must create candidate records first
- Link applicants to candidates
- Maintain both entities for complete data
8. Best Practices for Large Migrations
- Batch Processing: Export and import in manageable batches (50 records)
- Error Handling: Robust error handling to prevent entire process from failing
- Resume Uploads: Upload attachments to both candidate and applicant records
- Message History: Preserve communication history for both entities
- Incremental Testing: Test with small batches before full migration
This documentation should help others in the Odoo Community Association understand the significant changes to the recruitment module in Odoo 18 and provide a template for migrating their own data.
There are no comments for now.