'Import item de-duplication'

@staticmethod
def project_project_deduplicate(item):

    data = item.data
    code = data.get('code')
    if code:
        table = item.table
        query = (table.code.lower() == code.lower())
    else:
        name = data.get('name')
        if name:
            table = item.table
            query = (table.name.lower() == name.lower())
        else:
            return
    duplicate = current.db(query).select(table.id, limitby=(0, 1)).first()
    if duplicate:
        item.id = duplicate.id
        item.method = item.METHOD.UPDATE
