'Finds possible duplicates workitems for a record in this campaign, based on a uniqueness
field.
:param record: browse_record to find duplicates workitems for.
:param campaign_rec: browse_record of campaign'

def _find_duplicate_workitems(self, record):

    self.ensure_one()
    duplicate_workitem_domain = [('res_id', '=', record.id), ('campaign_id', '=', self.id)]
    unique_field = self.unique_field_id
    if unique_field:
        unique_value = getattr(record, unique_field.name, None)
        if unique_value:
            if (unique_field.ttype == 'many2one'):
                unique_value = unique_value.id
            similar_res_ids = self.env[self.object_id.model].search([(unique_field.name, '=', unique_value)])
            if similar_res_ids:
                duplicate_workitem_domain = [('res_id', 'in', similar_res_ids.ids), ('campaign_id', '=', self.id)]
    return self.env['marketing.campaign.workitem'].search(duplicate_workitem_domain)
