<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:e="leaf.service.exception" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="fc" baseTable="fnd_op_unit_hierarchy">
    <bm:fields>
        <bm:field name="operation_unit_id" databaseType="BIGINT" datatype="java.lang.Long"/>
        <bm:field name="parent_operation_unit_id" databaseType="BIGINT" datatype="java.lang.Long"/>
    </bm:fields>
    <bm:primary-key>
        <bm:pk-field name="operation_unit_id"/>
        <bm:pk-field name="parent_operation_unit_id"/>
    </bm:primary-key>
    <bm:relations>
        <bm:relation name="fou" joinType="INNER" refModel="fnd.fnd_operation_units">
            <bm:reference foreignField="operation_unit_id" localField="operation_unit_id"/>
        </bm:relation>
    </bm:relations>
    <bm:features>
        <f:standard-who/>
        <f:multi-language-storage/>
    </bm:features>
    <bm:ref-fields>
        <bm:ref-field name="operation_unit_code" prompt="FND_OPERATION_UNITS.OPERATION_UNIT_CODE" relationName="fou" sourceField="operation_unit_code"/>
        <bm:ref-field name="description_id" multiLanguage="true" multiLanguageDescField="description" relationName="fou" sourceField="description_id"/>
    </bm:ref-fields>
    <bm:data-filters>
        <bm:data-filter name="company_id" expression="exists (select 1 from fnd_operation_units u where u.operation_unit_id= parent_operation_unit_id  and u.company_id= ${/session/@company_id})"/>
        <!--  <bm:data-filter name="summary_flag" expression="exists (select 1 from fnd_operation_units u where u.operation_unit_id= fc.parent_operation_unit_id

and u.summary_flag='N')"/>-->
    </bm:data-filters>
    <bm:query-fields>
        <bm:query-field name="parent_op_unit_id" queryExpression="parent_operation_unit_id = ${@parent_op_unit_id}"/>
    </bm:query-fields>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="FND_OPERATION_UNITS.OPERATION_UNIT_DISTINCT"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
