'When a inv_inv_item record is created with a source number,
then the source number needs to be unique within the
organisation.'

@staticmethod
def inv_inv_item_onvalidate(form):

    item_source_no = form.vars.item_source_no
    if (not item_source_no):
        return
    if hasattr(form, 'record'):
        record = form.record
        if (record and record.item_source_no and (record.item_source_no == item_source_no)):
            return
    db = current.db
    s3db = current.s3db
    itable = s3db.inv_inv_item
    org_field = 'owner_org_id'
    query = ((itable[org_field] == form.vars[org_field]) & (itable.item_source_no == item_source_no))
    record = db(query).select(itable[org_field], limitby=(0, 1)).first()
    if record:
        org = current.response.s3.org_organisation_represent(record[org_field])
        form.errors.item_source_no = (current.T('The    Tracking    Number    %s    is    already    used    by    %s.') % (item_source_no, org))
