Fixes issue 40539: Sets warehouse organization in physical inventories
authorNono Carballo <nonofce@gmail.com>
Wed, 17 Apr 2019 11:42:09 +0200
changeset 35690 e4ecb0f34be7
parent 35689 5e010ec9da31
child 35691 0436f5f5c68c
Fixes issue 40539: Sets warehouse organization in physical inventories

When creating Physical Inventories (init/close) at processing Physical Inventory
Amount Update, organization is set to the warehouse organization, instead of
the document organization.
src/org/openbravo/costing/InventoryAmountUpdateProcess.java
--- a/src/org/openbravo/costing/InventoryAmountUpdateProcess.java	Wed Apr 17 11:25:20 2019 +0000
+++ b/src/org/openbravo/costing/InventoryAmountUpdateProcess.java	Wed Apr 17 11:42:09 2019 +0200
@@ -347,6 +347,7 @@
     inv.setOrganization(
         (Organization) OBDal.getInstance().getProxy(Organization.ENTITY_NAME, orgId));
     inv.setWarehouse((Warehouse) OBDal.getInstance().getProxy(Warehouse.ENTITY_NAME, warehouseId));
+
     inv.setCaInventoryamtline(invLine);
     List<InvAmtUpdLnInventories> invList = invLine.getInventoryAmountUpdateLineInventoriesList();
     invList.add(inv);
@@ -354,22 +355,21 @@
 
     InventoryCount closeInv = OBProvider.getInstance().get(InventoryCount.class);
     closeInv.setClient((Client) OBDal.getInstance().getProxy(Client.ENTITY_NAME, clientId));
-    closeInv.setOrganization(
-        (Organization) OBDal.getInstance().getProxy(Organization.ENTITY_NAME, orgId));
     closeInv.setName(OBMessageUtils.messageBD("InvAmtUpdCloseInventory"));
     closeInv
         .setWarehouse((Warehouse) OBDal.getInstance().getProxy(Warehouse.ENTITY_NAME, warehouseId));
+    closeInv.setOrganization(closeInv.getWarehouse().getOrganization());
+
     closeInv.setMovementDate(localDate);
     closeInv.setInventoryType("C");
     inv.setCloseInventory(closeInv);
 
     InventoryCount initInv = OBProvider.getInstance().get(InventoryCount.class);
     initInv.setClient((Client) OBDal.getInstance().getProxy(Client.ENTITY_NAME, clientId));
-    initInv.setOrganization(
-        (Organization) OBDal.getInstance().getProxy(Organization.ENTITY_NAME, orgId));
     initInv.setName(OBMessageUtils.messageBD("InvAmtUpdInitInventory"));
     initInv
         .setWarehouse((Warehouse) OBDal.getInstance().getProxy(Warehouse.ENTITY_NAME, warehouseId));
+    initInv.setOrganization(initInv.getWarehouse().getOrganization());
     initInv.setMovementDate(localDate);
     initInv.setInventoryType("O");
     inv.setInitInventory(initInv);