<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<object-views xmlns="http://axelor.com/xml/ns/object-views"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://axelor.com/xml/ns/object-views http://axelor.com/xml/ns/object-views/object-views_5.2.xsd">


    <grid name="partner-price-list-grid" title="Price lists"
          model="com.axelor.apps.base.db.PartnerPriceList">
        <field name="label"/>
        <field name="typeSelect"/>
        <field name="isExclusive"/>
    </grid>

    <form name="sale-partner-price-list-form" title="Price lists"
          model="com.axelor.apps.base.db.PartnerPriceList"
          onNew="action-record-partner-price-list-record-sale-type"
          width="large">
        <panel name="mainPanel">
            <field name="label"/>
            <field name="typeSelect" readonly="true" colSpan="4"/>
            <field name="isExclusive"/>
            <field name="priceListSet"
                   grid-view="price-list-grid"
                   form-view="sale-price-list-form"
                   onChange="action-method-partner-price-list-check-dates"
                   domain="self.typeSelect = 1"
                   colSpan="12"/>
        </panel>
        <panel-dashlet name="partnersDashletPanel" title="Partners" action="action-partner-price-list-view-dashlet-partners" colSpan="12"/>
    </form>

    <form name="purchase-partner-price-list-form" title="Price lists"
          model="com.axelor.apps.base.db.PartnerPriceList"
          onNew="action-record-partner-price-list-record-purchase-type"
          width="large">
        <panel name="mainPanel">
            <field name="label"/>
            <field name="typeSelect" readonly="true" colSpan="4"/>
            <field name="isExclusive"/>
            <field name="priceListSet"
                   grid-view="price-list-grid"
                   form-view="purchase-price-list-form"
                   onChange="action-method-partner-price-list-check-dates"
                   domain="self.typeSelect = 2"
                   colSpan="12"/>
        </panel>
        <panel-dashlet name="partnersDashletPanel" title="Partners" action="action-partner-price-list-view-dashlet-partners" colSpan="12"/>
    </form>

    <action-record name="action-record-partner-price-list-record-sale-type"
                   model="com.axelor.apps.base.db.PartnerPriceList">
        <field name="typeSelect" expr="1"/>
    </action-record>

    <action-record name="action-record-partner-price-list-record-purchase-type"
                   model="com.axelor.apps.base.db.PartnerPriceList">
        <field name="typeSelect" expr="2"/>
    </action-record>

    <action-method name="action-method-partner-price-list-check-dates">
        <call class="com.axelor.apps.base.web.PartnerPriceListController"
              method="checkDates"/>
    </action-method>

   <action-view name="action-partner-price-list-view-dashlet-partners" title="Partners" model="com.axelor.apps.base.db.Partner">
		<view type="grid" name="partner-customer-grid" if="typeSelect == 1"/>
		<view type="form" name="partner-customer-form" if="typeSelect == 1"/>
		<view type="grid" name="partner-supplier-grid" if="typeSelect == 2"/>
		<view type="form" name="partner-supplier-form" if="typeSelect == 2"/>
		<domain>(self.purchasePartnerPriceList = :partnerPriceListId AND self.purchasePartnerPriceList.typeSelect = :typeSelect) OR (self.salePartnerPriceList = :partnerPriceListId AND self.salePartnerPriceList.typeSelect = :typeSelect)</domain>
		<context name="partnerPriceListId" expr="eval: id" />
		<context name="typeSelect" expr="eval: typeSelect"/>
   </action-view>

</object-views>
