Re: svn commit: r603569 - /ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r603569 - /ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml

Jacopo Cappellato
David,

I'm sorry but it is still not working: I think that the problem is that
when you receive two (or more) shipment items, the service
"receiveInventoryProduct" is called two times by the "service-multi"
event handler; after the first call, the inventoryItemId returned by the
service is put in the context (parameters) and so the second service
call will evaluate the following condition as false:

<if-empty field-name="parameters.inventoryItemId">

and so the updateInventoryItem service is called.

I really don't know how to fix this, but a solution would be that of
changing the name of the IN parameter for the inventoryItemId...

Jacopo



[hidden email] wrote:

> Author: jonesde
> Date: Wed Dec 12 03:26:21 2007
> New Revision: 603569
>
> URL: http://svn.apache.org/viewvc?rev=603569&view=rev
> Log:
> Reverted changes done by Jacopo in rev 603506 which was a temporary fix for the problem described there; the real problem appears to be that code, in poss;the real problem seems to be that a variable was retained somewhere in a loop where it should not have been, and to fix that I made 2 changes: in the receiveInventoryProduct simple-method I changed it to use the parameters.inventoryItemId variable for input only, and it isn't set and used inside the loop, instead the new currentInventoryItemId variable is used; also in the quickReceiveReturn simple-method I add a clear-field of receiveCtx to make sure that stale data does not remain between iterations over return items; I don't have a good test case for this, so please take a look at it Jacopo, and it might be good to find a automated test case for this in the near future as this is fairly complicated and error prone code
>
> Modified:
>     ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml
>
> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml?rev=603569&r1=603568&r2=603569&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml (original)
> +++ ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml Wed Dec 12 03:26:21 2007
> @@ -113,20 +113,21 @@
>              
>              <!-- if there is an inventoryItemId, update it (this will happen when receiving serialized inventory already in the system, like for returns); if not create one -->
>              <clear-field field-name="serviceInMap"/>
> -<!--
> +            <clear-field field-name="currentInventoryItemId"/>
> +            
>              <if-empty field-name="parameters.inventoryItemId">
> --->
>                  <set-service-fields service-name="createInventoryItem" map-name="parameters" to-map-name="serviceInMap"/>
>                  <call-service service-name="createInventoryItem" in-map-name="serviceInMap">
> -                    <result-to-field result-name="inventoryItemId" field-name="parameters.inventoryItemId"/>
> +                    <result-to-field result-name="inventoryItemId" field-name="currentInventoryItemId"/>
>                  </call-service>
> -<!--
> +                
>                  <else>
>                      <set-service-fields service-name="updateInventoryItem" map-name="parameters" to-map-name="serviceInMap"/>
>                      <call-service service-name="updateInventoryItem" in-map-name="serviceInMap"/>
> +                    <set field="currentInventoryItemId" from-field="parameters.inventoryItemId"/>
>                  </else>
>              </if-empty>
> --->            
> +
>              <!-- do this only for non-serialized inventory -->
>              <if-compare value="SERIALIZED_INV_ITEM" operator="not-equals" field-name="parameters.inventoryItemTypeId">
>                  <clear-field field-name="serviceInMap"/>
> @@ -162,7 +163,7 @@
>                          </condition>
>                          <then>
>                              <clear-field field-name="serviceInMap"/>
> -                            <set field="serviceInMap.inventoryItemId" from-field="parameters.inventoryItemId"/>
> +                            <set field="serviceInMap.inventoryItemId" from-field="currentInventoryItemId"/>
>                              <set field="serviceInMap.statusId" value="INV_AVAILABLE"/> <!-- XXX set to returned instead -->
>                              <call-service service-name="updateInventoryItem" in-map-name="serviceInMap"/>
>                          </then>
> @@ -174,10 +175,10 @@
>              <set-service-fields service-name="balanceInventoryItems" map-name="parameters" to-map-name="serviceInMap"/>
>              <call-service service-name="balanceInventoryItems" in-map-name="serviceInMap"/>
>  
> -            <set field="successMessageList[]" value="Received ${parameters.quantityAccepted} of ${parameters.productId} in inventory item ${parameters.inventoryItemId}"/>
> +            <set field="successMessageList[]" value="Received ${parameters.quantityAccepted} of ${parameters.productId} in inventory item ${currentInventoryItemId}"/>
>          </loop>
>          <!-- return the last inventory item received -->
> -        <field-to-result field-name="parameters.inventoryItemId" result-name="inventoryItemId"/>
> +        <field-to-result field-name="currentInventoryItemId" result-name="inventoryItemId"/>
>      </simple-method>
>  
>      <simple-method method-name="quickReceiveReturn" short-description="Quick Receive Entire Return">
> @@ -230,7 +231,9 @@
>                          <result-to-field result-name="shipmentItemSeqId"/>
>                      </call-service>
>                  </iterate>
> -                <iterate entry-name="returnItem" list-name="returnItems">                    
> +                <iterate entry-name="returnItem" list-name="returnItems">
> +                    <clear-field field-name="receiveCtx"/>
> +                                        
>                      <if-empty field-name="expectedItemStatus" map-name="returnItem">
>                          <set value="INV_RETURNED" field="returnItem.expectedItemStatus" type="String"/>
>                      </if-empty>
>

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r603569 - /ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml

David E Jones

Thanks for your persistence Jacopo. In rev 603849 I changed the input  
parameter to be currentInventoryItemId so the IN and OUT are named  
differently. That was the easier to change as the OUT param is used a  
lot, but the IN one I could only find used in the OAGIS component.

So... hopefully it is working properly now!

-David


On Dec 12, 2007, at 7:31 AM, Jacopo Cappellato wrote:

> David,
>
> I'm sorry but it is still not working: I think that the problem is  
> that when you receive two (or more) shipment items, the service  
> "receiveInventoryProduct" is called two times by the "service-multi"  
> event handler; after the first call, the inventoryItemId returned by  
> the service is put in the context (parameters) and so the second  
> service call will evaluate the following condition as false:
>
> <if-empty field-name="parameters.inventoryItemId">
>
> and so the updateInventoryItem service is called.
>
> I really don't know how to fix this, but a solution would be that of  
> changing the name of the IN parameter for the inventoryItemId...
>
> Jacopo
>
>
>
> [hidden email] wrote:
>> Author: jonesde
>> Date: Wed Dec 12 03:26:21 2007
>> New Revision: 603569
>> URL: http://svn.apache.org/viewvc?rev=603569&view=rev
>> Log:
>> Reverted changes done by Jacopo in rev 603506 which was a temporary  
>> fix for the problem described there; the real problem appears to be  
>> that code, in poss;the real problem seems to be that a variable was  
>> retained somewhere in a loop where it should not have been, and to  
>> fix that I made 2 changes: in the receiveInventoryProduct simple-
>> method I changed it to use the parameters.inventoryItemId variable  
>> for input only, and it isn't set and used inside the loop, instead  
>> the new currentInventoryItemId variable is used; also in the  
>> quickReceiveReturn simple-method I add a clear-field of receiveCtx  
>> to make sure that stale data does not remain between iterations  
>> over return items; I don't have a good test case for this, so  
>> please take a look at it Jacopo, and it might be good to find a  
>> automated test case for this in the near future as this is fairly  
>> complicated and error prone code
>> Modified:
>>    ofbiz/trunk/applications/product/script/org/ofbiz/shipment/
>> receipt/ShipmentReceiptServices.xml
>> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/
>> shipment/receipt/ShipmentReceiptServices.xml
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/shipment/receipt/ShipmentReceiptServices.xml?rev=603569&r1=603568&r2=603569&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- ofbiz/trunk/applications/product/script/org/ofbiz/shipment/
>> receipt/ShipmentReceiptServices.xml (original)
>> +++ ofbiz/trunk/applications/product/script/org/ofbiz/shipment/
>> receipt/ShipmentReceiptServices.xml Wed Dec 12 03:26:21 2007
>> @@ -113,20 +113,21 @@
>>                          <!-- if there is an inventoryItemId,  
>> update it (this will happen when receiving serialized inventory  
>> already in the system, like for returns); if not create one -->
>>             <clear-field field-name="serviceInMap"/>
>> -<!--
>> +            <clear-field field-name="currentInventoryItemId"/>
>> +                         <if-empty field-
>> name="parameters.inventoryItemId">
>> --->
>>                 <set-service-fields service-
>> name="createInventoryItem" map-name="parameters" to-map-
>> name="serviceInMap"/>
>>                 <call-service service-name="createInventoryItem" in-
>> map-name="serviceInMap">
>> -                    <result-to-field result-name="inventoryItemId"  
>> field-name="parameters.inventoryItemId"/>
>> +                    <result-to-field result-name="inventoryItemId"  
>> field-name="currentInventoryItemId"/>
>>                 </call-service>
>> -<!--
>> +                                 <else>
>>                     <set-service-fields service-
>> name="updateInventoryItem" map-name="parameters" to-map-
>> name="serviceInMap"/>
>>                     <call-service service-
>> name="updateInventoryItem" in-map-name="serviceInMap"/>
>> +                    <set field="currentInventoryItemId" from-
>> field="parameters.inventoryItemId"/>
>>                 </else>
>>             </if-empty>
>> --->            +
>>             <!-- do this only for non-serialized inventory -->
>>             <if-compare value="SERIALIZED_INV_ITEM" operator="not-
>> equals" field-name="parameters.inventoryItemTypeId">
>>                 <clear-field field-name="serviceInMap"/>
>> @@ -162,7 +163,7 @@
>>                         </condition>
>>                         <then>
>>                             <clear-field field-name="serviceInMap"/>
>> -                            <set  
>> field="serviceInMap.inventoryItemId" from-
>> field="parameters.inventoryItemId"/>
>> +                            <set  
>> field="serviceInMap.inventoryItemId" from-
>> field="currentInventoryItemId"/>
>>                             <set field="serviceInMap.statusId"  
>> value="INV_AVAILABLE"/> <!-- XXX set to returned instead -->
>>                             <call-service service-
>> name="updateInventoryItem" in-map-name="serviceInMap"/>
>>                         </then>
>> @@ -174,10 +175,10 @@
>>             <set-service-fields service-
>> name="balanceInventoryItems" map-name="parameters" to-map-
>> name="serviceInMap"/>
>>             <call-service service-name="balanceInventoryItems" in-
>> map-name="serviceInMap"/>
>> -            <set field="successMessageList[]" value="Received $
>> {parameters.quantityAccepted} of ${parameters.productId} in  
>> inventory item ${parameters.inventoryItemId}"/>
>> +            <set field="successMessageList[]" value="Received $
>> {parameters.quantityAccepted} of ${parameters.productId} in  
>> inventory item ${currentInventoryItemId}"/>
>>         </loop>
>>         <!-- return the last inventory item received -->
>> -        <field-to-result field-name="parameters.inventoryItemId"  
>> result-name="inventoryItemId"/>
>> +        <field-to-result field-name="currentInventoryItemId"  
>> result-name="inventoryItemId"/>
>>     </simple-method>
>>      <simple-method method-name="quickReceiveReturn" short-
>> description="Quick Receive Entire Return">
>> @@ -230,7 +231,9 @@
>>                         <result-to-field result-
>> name="shipmentItemSeqId"/>
>>                     </call-service>
>>                 </iterate>
>> -                <iterate entry-name="returnItem" list-
>> name="returnItems">                    +                <iterate  
>> entry-name="returnItem" list-name="returnItems">
>> +                    <clear-field field-name="receiveCtx"/>
>> +                                                             <if-
>> empty field-name="expectedItemStatus" map-name="returnItem">
>>                         <set value="INV_RETURNED"  
>> field="returnItem.expectedItemStatus" type="String"/>
>>                     </if-empty>
>


smime.p7s (3K) Download Attachment