Importing custom models

Hello,

Axelor is one of the best open source products I have found for ERP/CRM function. Thank you for putting out such a good product. Can you please help me with the following?

I have created a rather complex custom model as follows. It combines a set of existing models and creates a new model.

Foreman - com.axelor.auth.db.User (Many to one)
Item - com.axelor.apps.production.db.MachineTool (Many to one)
Date - Date
ToolStatus - A custom selection called ‹ ToolStatus › with string values « Missing », « Broken » etc. (Many to one)
Quantity - Integer
Unit - com.axelor.apps.base.db.Unit (Many to one)

I’m able to create entries using the UI, but have a lot of data that needs to be imported. Can you please help with that? I tried using the CSV config and sample csv below with the ‹ Importer › menu but it fails giving errors:

<?xml version="1.0"?>
<input file="foremantools_import.csv" type="com.axelor.meta.db.MetaJsonRecord"
    search = "self.attrs.Foreman.name = :name" update="false" >    	
	<bind to="attrs" column="attrs"></bind>
	<bind to="name" column="name"></bind>
</input>

CSV File:
« name »,« attrs »
« Lucy ROBERT »,"{« Date »: « 2021-01-02 », « Item »: {« id »: 2, « name »: « METAL CUTTING BLADES », « $version »: 0}, « Foreman »: {« id »: 14, « $version »: 2, « fullName »: « Lucy ROBERT »}, « Quantity »: 7}"

Exception:
javax.validation.ConstraintViolationException: Validation failed for classes [com.axelor.meta.db.MetaJsonRecord] during persist time for groups [javax.validation.groups.Default, ]
List of constraint violations:[
ConstraintViolationImpl{interpolatedMessage=‹ may not be null ›, propertyPath=jsonModel, rootBeanClass=class com.axelor.meta.db.MetaJsonRecord, messageTemplate=’{javax.validation.constraints.NotNull.message}’}
]

Exported object example: (I created it on UI and exported it using ‹ Advanced Export ›)
Imported from,Updated by,Updated on,Created on,Version,Attrs,Archived,Import ID,Created by,Json model,Name,Id
,1/29/2021 7:34 AM,0,"{"« Date »": « « 2021-01-01" », « « Item » »: { »« id »": 1, « « name » »: « « REPLACEMENT VOLT METER LEADS » », «  »$version"": 1}, « « Foreman » »: {"« id »": 27, «  »$version"": 2, « « fullName » »: « « Cyril MARCHAL » »}, « « Quantity » »: 1}",Admin,ForemanTools,2
,1/29/2021 9:48 AM,0,"{"« Date »": « « 2021-01-02" », « « Item » »: { »« id »": 2, « « name » »: « « METAL CUTTING BLADES » », «  »$version"": 0}, « « Foreman » »: {"« id »": 14, «  »$version"": 2, « « fullName » »: « « Lucy ROBERT » »}, « « Quantity » »: 7}",Admin,ForemanTools,3

Hello @RRM

Glad to know it. Thank you so much.

Did you include jsonModel column in your data file ?

This exception indicate that we must have to provide the value for jsonModel field as it’s having not null constraint. The value for this column will be the name of your customModel.

Thank you.
Regards.