<?xml version="1.0" encoding="UTF-8"?>
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">

  <module name="purchase" package="com.axelor.apps.purchase.db" />

  <entity name="PurchaseOrderLineFile" lang="java">
    <many-to-one name="coaFile" ref="com.axelor.meta.db.MetaFile" title="coa file" />
    <string
      name="noteCOA" large="true" multiline="true" title="Comment on coa" />
    <string name="file_type"
      selection="purchase.importation.folder.file.type" title="File type" />
    <datetime
      name="coa_validation_date" title="Coa validation date" />
    <many-to-one
      name="coa_validator_user" ref="com.axelor.auth.db.User" />
  	
    <integer name="statusSelect"
      title="Status" selection="purchase.order.line.file.status.select" default="1" readonly="true" />
  	<integer
      name="rdStatusSelect" title="Status" selection="purchase.order.line.rd.file.status.select"
      default="1" readonly="true" />
  	<integer name="qaStatusSelect" title="Status"
      selection="purchase.order.line.qa.file.status.select" default="1" readonly="true" />
  	<integer
      name="qcStatusSelect" title="Status" selection="purchase.order.line.qc.file.status.select"
      default="1" readonly="true" />
  	<integer name="productionStatusSelect" title="Status"
      selection="purchase.order.line.production.file.status.select" default="1" readonly="true" />
  	<integer
      name="dtStatusSelect" title="Status" selection="purchase.order.line.file.dt.status.select"
      default="1" readonly="true" />

    <many-to-one name="purchaseOrderLine"
      ref="com.axelor.apps.purchase.db.PurchaseOrderLine" title="Purchase order" />

    <datetime
      name="rd_validation_date" title="RD validation date" />
    <many-to-one name="rd_user"
      ref="com.axelor.auth.db.User" />

    <datetime name="qa_validation_date" title="QA validation date" />
    <many-to-one
      name="qa_validator_user" ref="com.axelor.auth.db.User" />

    <datetime name="qc_validation_date"
      title="QC validation date" />
    <many-to-one name="qc_validator_user"
      ref="com.axelor.auth.db.User" />

    <datetime name="production_validation_date"
      title="Production validation date" />
    <many-to-one name="production_validator_user"
      ref="com.axelor.auth.db.User" />

    <datetime name="dt_validation_date" title="Dt validation date" />
    <many-to-one
      name="dt_validator_user" ref="com.axelor.auth.db.User" />
    
    <datetime name="refusal_date"
      title="DSC refusal date" />
    <many-to-one name="refusal_user" ref="com.axelor.auth.db.User" />
    <string
      name="refusal_reason" title="Reasons of Refusal" large="true" />


    <datetime
      name="rd_refusal_date" title="RD refusal date" />
    <many-to-one name="rd_refusal_user"
      ref="com.axelor.auth.db.User" />
    <string name="rd_refusal_reason" title="Reasons of Refusal"
      large="true" />


    <datetime name="qa_refusal_date" title="QA refusal date" />
    <many-to-one
      name="qa_validator_refusal_user" ref="com.axelor.auth.db.User" />
    <string
      name="qa_refusal_reason" title="Reasons of Refusal" large="true" />


    <datetime
      name="qc_refusal_date" title="QC refusal date" />
    <many-to-one name="qc_validator_refusal_user"
      ref="com.axelor.auth.db.User" />
    <string name="qc_refusal_reason" title="Reasons of Refusal"
      large="true" />


    <datetime name="production_refusal_date" title="Production refusal date" />
    <many-to-one
      name="production_validator_refusal_user" ref="com.axelor.auth.db.User" />
    <string
      name="production_refusal_reason" title="Reasons of Refusal" large="true" />

    <datetime
      name="dt_refusal_date" title="Dr refusal date" />
    <many-to-one
      name="dt_validator_refusal_user" ref="com.axelor.auth.db.User" />
    <string
      name="dt_refusal_reason" title="Reasons of Refusal" large="true" />


    <!-- General Status -->
    <datetime
      name="statusReviewDate" title="Status Review Date" />
    <many-to-one name="statusReviewedBy"
      ref="com.axelor.auth.db.User" title="Status Reviewed By" />

    <!-- RD -->
    <datetime name="rdStatusReviewDate"
      title="RD Status Review Date" />
    <many-to-one name="rdStatusReviewedBy"
      ref="com.axelor.auth.db.User" title="RD Status Reviewed By" />

    <!-- QA -->
    <datetime
      name="qaStatusReviewDate" title="QA Status Review Date" />
    <many-to-one
      name="qaStatusReviewedBy" ref="com.axelor.auth.db.User" title="QA Status Reviewed By" />

    <!-- QC -->
    <datetime
      name="qcStatusReviewDate" title="QC Status Review Date" />
    <many-to-one
      name="qcStatusReviewedBy" ref="com.axelor.auth.db.User" title="QC Status Reviewed By" />

    <!-- Production -->
    <datetime
      name="productionStatusReviewDate" title="Production Status Review Date" />
    <many-to-one
      name="productionStatusReviewedBy" ref="com.axelor.auth.db.User"
      title="Production Status Reviewed By" />

    <!-- DT -->
    <datetime name="dtStatusReviewDate"
      title="DT Status Review Date" />
    <many-to-one name="dtStatusReviewedBy"
      ref="com.axelor.auth.db.User" title="DT Status Reviewed By" />

  	<boolean name="routinePurchase"
      title="Routine purchase" default="false" />

    <extra-code>
      <![CDATA[ 
        // General Status Constants
        public static final String STATUS_SELECT = "STATUS_SELECT";

        // RD Status Select Constant
        public static final String RD_STATUS_SELECT = "RD_STATUS_SELECT";

        // QA Status Select Constant
        public static final String QA_STATUS_SELECT = "QA_STATUS_SELECT";

        // QC Status Select Constant
        public static final String QC_STATUS_SELECT = "QC_STATUS_SELECT";

        // Production Status Select Constant
        public static final String PRODUCTION_STATUS_SELECT = "PRODUCTION_STATUS_SELECT";

        // DT Status Select Constant
        public static final String DT_STATUS_SELECT = "DT_STATUS_SELECT";
      ]]>
    </extra-code>


  <track>
      <!-- Status Fields -->
      <field name="statusSelect" />
      <field name="rdStatusSelect" />
      <field name="qaStatusSelect" />
      <field name="qcStatusSelect" />
      <field name="productionStatusSelect" />
      <field name="dtStatusSelect" />

      <!-- Refusal Date Fields -->
      <field name="refusal_date" />
      <field name="rd_refusal_date" />
      <field name="qa_refusal_date" />
      <field name="qc_refusal_date" />
      <field name="production_refusal_date" />
      <field name="dt_refusal_date" />

      <!-- Validation Date Fields -->
      <field name="coa_validation_date" />
      <field name="rd_validation_date" />
      <field name="qa_validation_date" />
      <field name="qc_validation_date" />
      <field name="production_validation_date" />
      <field name="dt_validation_date" />

      <!-- Review Date Fields -->
      <field name="statusReviewDate" />
      <field name="rdStatusReviewDate" />
      <field name="qaStatusReviewDate" />
      <field name="qcStatusReviewDate" />
      <field name="productionStatusReviewDate" />
      <field name="dtStatusReviewDate" />
    </track>


  </entity>

</domain-models>