<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="fnd_coding_rules" needAccessControl="false">
    <bm:fields>
        <bm:field name="document_category" databaseType="VARCHAR" datatype="java.lang.String"/>
        <bm:field name="coding_rule_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="coding_rule_code" databaseType="VARCHAR" datatype="java.lang.String" forDisplay="true" forQuery="true" prompt="编码规则代码"/>
        <bm:field name="description" databaseType="VARCHAR" datatype="java.lang.String" expression="(select description_text from fnd_descriptions f where description_id = (select description_id from fnd_coding_rules r where r.coding_rule_id = t1.coding_rule_id) AND f.Language = userenv(&apos;LANG&apos;))" forDisplay="true" forQuery="true" prompt="编码规则描述"/>
    </bm:fields>
    <bm:operations>
    <bm:operation name="query">
        <bm:query-sql><![CDATA[
    			SELECT *
  FROM (SELECT t1.document_category,
               t1.coding_rule_id,
               t1.coding_rule_code,
               (SELECT description_text
                  FROM fnd_descriptions f
                 WHERE description_id = (SELECT description_id
                                           FROM fnd_coding_rules r
                                          WHERE r.coding_rule_id = t1.coding_rule_id)
                   AND f.language = userenv('LANG')) AS description
          FROM fnd_coding_rules t1)
				  #WHERE_CLAUSE#
    		]]></bm:query-sql>
    </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="coding_rule_code" queryOperator="like"/>
        <bm:query-field field="description" queryOperator="like"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="document_category" enforceOperations="query" expression="document_category = ${@document_category}"/>
    </bm:data-filters>
</bm:model>
