Hi,
I want to import HR contracts types/sub-contracts types using csv files
The model for contracts types is:
<entity name="EmploymentContractType" lang="java">
<string name="name" title="EmploymentContractType.name" required="true"/>
<one-to-many name="employmentContractSubTypeList"
ref="com.axelor.apps.hr.db.EmploymentContractSubType" title="Contract sub type"/>
<string name="description" title="EmploymentContractType.description"/>
<boolean name="isNoLongerUsed" title="No longer used" default="false"/>
</entity>
and the sub-contracts types model is:
<entity name="EmploymentContractSubType" lang="java">
<string name="code" title="Code" namecolumn="true"/>
<string name="description" title="EmploymentContractSubType.description" large="true"/>
</entity>
I created two csv files, contractstype.csv, and subcontractstype.csv with the following contents respectively:
description,isNoLongerUsed,name,subtypes
Fixed-term contract,false,FTC,1|35
Permanent contract,false,PC,34|36|37
Apprenticeship contract,false,AC,
Professionalization contract,false,PRC,
Intermittent employment contract,false,IEC,
Part-time employment contract,false,PEC,
Seasonal employment contract,false,SEC,
Temporary employment contract,false,TEC,
============================================
importId,code,description
35,FTC Advisor,Advisor Fixed-term contract
1,FTC Freelance,Freelance Fixed-term contract
36,PC Profit-sharing bonus,Permanent contract with profit-sharing bonus
37,PC Without profit-sharing bonus,Permanent contract without profit-sharing bonus
34,PC Commission,Permanent contract with commission
The import configuration file contains the following:
<input file="subcontractstype.csv" separator=","
type="com.axelor.apps.hr.db.EmploymentContractSubType"/>
<input file="contractstype.csv" separator=","
type="com.axelor.apps.hr.db.EmploymentContractType">
<bind column="subtypes" to="employmentContractSubTypeList"
search="self.importId in :subtypes" if="!subtypes.empty" eval="subtypes.split('\\|') as List"
update="true">
</bind>
</input>
The problem is that the association table links only the first records (for example Fixed-term contract is linked only to FTC Advisor and not to FTC Freelance)
What I’m doing wrong ??