<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: jessen  
    $Date: 2011-9-13 上午10:24:20  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select *
              from (select fv.company_id, fv.company_code, fv.company_short_name
                      from fnd_companies_vl fv
                     where fv.company_type = 1
                       and (fv.end_date_active is null or
                           sysdate between fv.start_date_active and fv.end_date_active)) v
            #WHERE_CLAUSE#
            order by v.company_code
]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="company_id" datatype="java.lang.Long"/>
        <bm:field name="company_code" datatype="java.lang.String" displayWidth="200" forDisplay="true" forQuery="true" prompt="FND_COMPANIES.COMPANY_CODE"/>
        <bm:field name="company_short_name" datatype="java.lang.String" displayWidth="200" forDisplay="true" forQuery="true" prompt="FND_COMPANIES.COMPANY_SHORT_NAME_ID"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="company_code" queryOperator="like"/>
        <bm:query-field field="company_short_name" queryOperator="like"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="company_id" expression="(v.company_id = ${@company_id} or exists (select 1 from fnd_companies_vl c where v.company_id = c.company_id and c.parent_company_id=${@company_id}))"/>
    </bm:data-filters>
</bm:model>
