When importing CSV files, the org.adempiere.impexp.GridTabCSVImporter.preprocessRow() submits the CSV row content to the field.isMandatory() function.
When this code is executed, field have the data of the field on current selected record in the UI, this way, all records isMandatory() will be submited to the logic against the current record and depending on the content of the record being inserted, it will return true for an empty field that should be returned false.
This checking can be safely removed from preprocessing, since when the importer fill the data later, it will be checked again with the correct context.
Thanks , I changed a little your approach in order to still check field without checking context - I think this can be useful as column IsMandatory could be overwritten in field and field customization.
can't update a tab have mandatory field
export data have mandatory field
+ change some value
+ empty mandatory field (so don't want import csv touch this field)
import at merger or update mode.
get error FillMandatory