<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: niujiaqing1265 $
    $Date: 2010/12/09 05:48:38 $
    $Revision: 1.2 $
    $Purpose: 部门分配 中lov对应的bm
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="unit" extend="exp.exp_org_unit" extendMode="reference">
    <bm:fields>
        <bm:field name="unit_id"/>
        <bm:field name="unit_code" forDisplay="true" forQuery="true" prompt="EXP_ORG_UNIT.UNIT_CODE"/>
        <bm:field name="description_id"/>
        <bm:field name="company_id"/>
        <bm:field name="org_unit_description" forDisplay="true" forQuery="true" prompt="EXP_ORG_UNIT.ORG_UNIT_DESCRIPTION"/>
        <!-- <bm:field name="company_short_name" forDisplay="true" forQuery="true" prompt="COMPANY_SHORT_NAME"/> -->
    </bm:fields>
    <bm:primary-key>
        <bm:pk-field name="unit_id"/>
    </bm:primary-key>
    <bm:relations>
        <bm:relation name="cpy" joinType="INNER" refModel="fnd.fnd_companies">
            <bm:reference foreignField="company_id" localField="company_id"/>
        </bm:relation>
    </bm:relations>
    <bm:query-fields>
        <bm:query-field field="unit_code" queryOperator="like"/>
        <bm:query-field field="org_unit_description" queryExpression="exists (select 1 from fnd_descriptions fd where unit.description_id=fd.description_id and fd.description_text like ${@org_unit_description} and fd.language = ${/session/@lang})"/>
        <bm:query-field name="company_code" queryExpression="cpy.company_code like ${@company_code}"/>
        <bm:query-field name="company_short_name" queryExpression="cpy.company_short_name  like ${@company_short_name}"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="query" expression="(select t.set_of_books_id from fnd_companies t where t.company_id = cpy.company_id) =          (select t.set_of_books_id from fnd_companies t where t.company_id = ${/session/@company_id})              and unit.enabled_flag = &apos;Y&apos;"/>
    </bm:data-filters>
    <bm:features>
        <f:standard-who/>
        <f:multi-language-display/>
    </bm:features>
    <bm:ref-fields>
        <bm:ref-field name="company_code" forDisplay="true" forQuery="true" prompt="COMPANY_CODE" relationName="cpy" sourceField="company_code"/>
        <bm:ref-field name="company_short_name" forDisplay="true" forQuery="true" prompt="COMPANY_SHORT_NAME" relationName="cpy" sourceField="company_short_name"/>
    </bm:ref-fields>
</bm:model>
