Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036690Openbravo ERP05. Production managementpublic2017-08-22 12:582017-09-21 16:49
ngarcia 
markmm82 
urgentmajoralways
closedfixed 
5
 
3.0PR17Q4 
aferraz
Core
No
0036690: Insufficient stock in Create Standards Process of Work Effort - Production Run tab if stock is in different priority warehouses
Insufficient stock in Create Standards Process of Work Effort - Production Run tab if stock is in different priority warehouses

The problem is that in M_GET_STOCK_PARAM function v_qtyaux is decreased on each loop and v_finalqty has the total value in the following piece of code:

      v_qtyaux := v_qtyaux - v_finalqty;
      IF (v_qtyaux <= 0) THEN
        DELETE FROM m_stock_proposed
        WHERE ad_pinstance_id = p_uuid
          AND (priority > cur_warehouse.priority
              OR isfinal = 'N');
        EXIT;
      END IF;
As group admin role:
   Create two new warehouses for F&B España Region Norte
   Add a locator to them
   Assign them as on hand warehouse to F&B España Region Norte organization (add also Region Norte WH in case it is not defined) and change their priority to 10, 20 and 30 respectively.
   Check all its locators have a inventory status that does not accept overissue (for example Undefined). Change it if not

   Create a new product: consumed
   Set it as production
   Add 13 units of it in the warehouse with 10 priority
   Add 8 units of it in the warehouse with 20 priority
   Add more than 9 units of it in the warehouse with 30 priority

   Create a new product: produced
   Set it as production
   Create a record in Manufacturing tab for España Norte org and any locator

   Create an Activity
   Create a Process Plan, Version and Operation
   Set Create Standards to 'N'
   Add 30 units of the previously created product to be consumed (P-)
   Add 1 unit of the previously created product to be produced (P+)

   Create a Work Requirement for that Process Plan and process it (Quantity: 1)
   Create Work Effort
   Go to Work Effort - Production Run tab, set Completed Quantity to 1 and Create Standards
   You will get the following error:
      Insufficient stock:: <productName>
No tags attached.
related to defect 0036681 closed markmm82 Insufficient stock in Create Standards Process of Work Effort - Production Run tab if decimal quantities are consumed 
Issue History
2017-08-22 12:58ngarciaNew Issue
2017-08-22 12:58ngarciaAssigned To => Triage Finance
2017-08-22 12:58ngarciaModules => Core
2017-08-22 12:58ngarciaResolution time => 1505167200
2017-08-22 12:58ngarciaTriggers an Emergency Pack => No
2017-08-22 12:58ngarciaIssue generated from0036681
2017-08-22 12:58ngarciaIssue Monitored: networkb
2017-08-22 12:59ngarciaRelationship addedrelated to 0036681
2017-08-22 12:59ngarciaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=15667#r15667
2017-08-22 13:16aferrazAssigned ToTriage Finance => markmm82
2017-08-23 23:56markmm82Statusnew => scheduled
2017-08-24 20:57markmm82Assigned Tomarkmm82 => ngarcia
2017-08-24 20:57markmm82Statusscheduled => feedback
2017-08-25 09:08ngarciaStatusfeedback => scheduled
2017-08-25 09:08ngarciaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=15707#r15707
2017-08-25 09:30aferrazAssigned Tongarcia => markmm82
2017-08-25 11:44ngarciaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=15718#r15718
2017-08-25 12:02aferrazSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=15720#r15720
2017-08-29 19:17markmm82Note Added: 0098711
2017-08-29 19:20markmm82Note Edited: 0098711bug_revision_view_page.php?bugnote_id=0098711#r15755
2017-08-29 19:51markmm82Note Edited: 0098711bug_revision_view_page.php?bugnote_id=0098711#r15756
2017-08-29 20:09markmm82Note Edited: 0098711bug_revision_view_page.php?bugnote_id=0098711#r15757
2017-08-30 17:15markmm82Note Added: 0098737
2017-08-30 17:25markmm82Note Edited: 0098737bug_revision_view_page.php?bugnote_id=0098737#r15763
2017-08-30 20:22markmm82Note Edited: 0098737bug_revision_view_page.php?bugnote_id=0098737#r15764
2017-08-30 20:23markmm82Note Added: 0098738
2017-08-30 21:24markmm82Note Added: 0098739
2017-09-04 09:12hgbotCheckin
2017-09-04 09:12hgbotNote Added: 0098785
2017-09-04 09:12hgbotStatusscheduled => resolved
2017-09-04 09:12hgbotResolutionopen => fixed
2017-09-04 09:12hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/708d0981673dc18d7ea644daf1819245c966fa26 [^]
2017-09-04 09:14aferrazReview Assigned To => aferraz
2017-09-04 09:14aferrazNote Added: 0098786
2017-09-04 09:14aferrazStatusresolved => closed
2017-09-04 09:14aferrazFixed in Version => 3.0PR17Q4
2017-09-21 16:49hudsonbotCheckin
2017-09-21 16:49hudsonbotNote Added: 0099352

Notes
(0098711)
markmm82   
2017-08-29 19:17   
(edited on: 2017-08-29 20:09)
Test Plan 1: Using different warehouses, locators and priorities. Product with Enough Stock.

As group admin role:
1. Go to Warehouse and Storage Bins and create a new one for F&B US East Coast.
     Search Key = Name = EC2
2. Add a locator to them.
     Search Key = Name = L2
3. Change Inventory Status to Undefined.

4. Go to Warehouse and Storage Bins and create a new one for F&B US East Coast.
     Search Key = Name = EC3
5. Add a locator to them.
     Search Key = Name = L3
6. Change Inventory Status to Undefined.

7. Assign both created warehouses as on hand warehouse to F&B US East Coast organization
     Ensure it is also added East Coast WH in case it is not defined.
8. Change their priority to 10, 20 and 30 respectively.

9. Create a new product: consumed
     Set it as production

10. Go to Goods receipt windows and create a new one:
     Business partner = Be Soft Drinker, Inc.
     Warehouse = US East Coast (priority = 10)
11. Add a new line:
     Product = Consumed
     Quantity = 13
     Storage Bin = EC-2-0-0
12. Complete the receipt.

13. Go to Goods receipt windows and create a new one:
     Business partner = Be Soft Drinker, Inc.
     Warehouse = EC2 (priority = 20)
14. Add a new line:
     Product = Consumed
     Quantity = 8
     Storage Bin = L2
15. Complete the receipt.

16. Go to Goods receipt windows and create a new one:
     Business partner = Be Soft Drinker, Inc.
     Warehouse = EC3 (priority = 30)
17. Add a new line:
     Product = Consumed
     Quantity = 10
     Storage Bin = L3
18. Complete the receipt.


19. Create a new product: produced
     Set it as production
     Create a record in Manufacturing tab for US East Coast org and any locator, for example EC-0-0-0

20. Create an Activity
21. Create a Process Plan, Version and Operation
     Set Create Standards to 'N'
22. Go to I/O Products tab and create two lines with following data:
     Line 10:
          Product = consumed
          Production Type = Product use (P-)
          Quantity = 30
     Line 20:
          Product = produced
          Production Type = Product Production (P+)
          Quantity = 1

23. Create a Work Requirement
     Organization = F&B US East Coast
     Process Plan = previously created
     Quantity = 1
24. Process it.

25. Create Work Effort and set Today as date.
 
26. Go to Work Effort - Production Run tab, set Completed Quantity to 1.
27. Execute Create Standards process.
     Notice you don't get any error and process ends successfully.

28. Go to Work Effort - Production Run tab - Product tab and notice there are 4 new lines:
     Line 10: Product = produced, Production Type = Product Production (P+), Qty = 1, Storage Bin = EC-0-0-0 (defined in Manufacturing tab of product)
     Line 20: Product = consumed, Production Type = Product use (P-), Qty = 13, Storage Bin = EC-2-0-0 (defined in step 11)
     Line 30: Product = consumed, Production Type = Product use (P-), Qty = 8, Storage Bin = L2 (defined in step 14)
     Line 40: Product = consumed, Production Type = Product use (P-), Qty = 9, Storage Bin = L3 (defined in step 17)



-------------------------------------------


Test Plan 2: Using different warehouses with different and same priorities. Product with Enough Stock.

As group admin role:
1. Go to Warehouse and Storage Bins and create a new one for F&B US West Coast.
     Search Key = Name = WC2
2. Add a locator to them.
     Search Key = Name = WL2
3. Change Inventory Status to Undefined.

4. Go to Warehouse and Storage Bins and create a new one for F&B US West Coast.
     Search Key = Name = WC3
5. Add a locator to them.
     Search Key = Name = WL3
6. Change Inventory Status to Undefined.

7. Assign both created warehouses as on hand warehouse to F&B US West Coast organization
     Ensure it is also added US West Coast WH in case it is not defined.
8. Change their priority to 10, 20 and 20 respectively.
     Notice WC2 and WC3 have the same priority = 20.

9. Create a new product: consumed
     Set it as production

10. Go to Goods receipt windows and create a new one:
     Business partner = Be Soft Drinker, Inc.
     Warehouse = US West Coast (priority = 10)
11. Add a new line:
     Product = Consumed
     Quantity = 13
     Storage Bin = WC-1-0-0
12. Complete the receipt.

13. Go to Goods receipt windows and create a new one:
     Business partner = Be Soft Drinker, Inc.
     Warehouse = WC2 (priority = 20)
14. Add a new line:
     Product = Consumed
     Quantity = 8
     Storage Bin = WL2
15. Complete the receipt.

16. Go to Goods receipt windows and create a new one:
     Business partner = Be Soft Drinker, Inc.
     Warehouse = WC3 (priority = 20)
17. Add a new line:
     Product = Consumed
     Quantity = 10
     Storage Bin = WL3
18. Complete the receipt.


19. Create a new product: produced
     Set it as production
     Create a record in Manufacturing tab for US West Coast org and any locator, for example WC-0-0-0

20. Create an Activity
21. Create a Process Plan, Version and Operation
     Set Create Standards to 'N'
22. Go to I/O Products tab and create two lines with following data:
     Line 10:
          Product = consumed
          Production Type = Product use (P-)
          Quantity = 30
     Line 20:
          Product = produced
          Production Type = Product Production (P+)
          Quantity = 1

23. Create a Work Requirement
     Organization = F&B US West Coast
     Process Plan = previously created
     Quantity = 1
24. Process it.

25. Create Work Effort and set Today as date.
 
26. Go to Work Effort - Production Run tab, set Completed Quantity to 1.
27. Execute Create Standards process.
     Notice you don't get any error and process ends successfully.

28. Go to Work Effort - Production Run tab - Product tab and notice there are 4 new lines:
     Line 10: Product = produced, Production Type = Product Production (P+), Qty = 1, Storage Bin = WC-0-0-0 (defined in Manufacturing tab of product)
     Line 20: Product = consumed, Production Type = Product use (P-), Qty = 13, Storage Bin = WC-1-0-0 (defined in step 11)
     Line 30: Product = consumed, Production Type = Product use (P-), Qty = 8, Storage Bin = WL2 (defined in step 14)
     Line 40: Product = consumed, Production Type = Product use (P-), Qty = 9, Storage Bin = WL3 (defined in step 17)



----------------------------------------------------------


Test Plan 3: Using different warehouses, locators and priorities. Product with Insufficient Stock.

As group admin role:
   Create two new warehouses for F&B España Region Norte
   Add a locator to them
   Assign them as on hand warehouse to F&B España Region Norte organization (add also Region Norte WH in case it is not defined) and change their priority to 10, 20 and 30 respectively.
   Check all its locators have a inventory status that does not accept overissue (for example Undefined). Change it if not

   Create a new product: consumed
   Set it as production
   Add 13 units of it in the warehouse with 10 priority
   Add 8 units of it in the warehouse with 20 priority
   Add less than 9 units of it in the warehouse with 30 priority

   Create a new product: produced
   Set it as production
   Create a record in Manufacturing tab for España Norte org and any locator

   Create an Activity
   Create a Process Plan, Version and Operation
   Set Create Standards to 'N'
   Add 30 units of the previously created product to be consumed (P-)
   Add 1 unit of the previously created product to be produced (P+)

   Create a Work Requirement for that Process Plan and process it (Quantity: 1)
   Create Work Effort
   Go to Work Effort - Production Run tab, set Completed Quantity to 1 and Create Standards
   You will get the following error:
      Insufficient stock: consumed

(0098737)
markmm82   
2017-08-30 17:15   
(edited on: 2017-08-30 20:22)
Test Plan 4: Related to issue 22231: Qty on hand warehouses and rules

1. Go to Organization window, select F&B US, Inc. and go to to Warehouse tab.
   Notice there are two on-hand warehouses:
     - US East Coast
     - US West Coast
2. Configure a new product as follows:
   Organization = F&B US, Inc.
   Name = Search Key = TestingProduct
3. Add purchase and sales price list to it.

4. Create a new Goods Receipt for F&B US, Inc. organization and US East coast Warehouse.
5. Add a line with created product:
   Product = TestingProduct
   Storage Bin = EC-0-0-0
   Movement Quantity = 45 Units
6. Add another line with created product:
   Product = TestingProduct
   Storage Bin = EC-1-0-0
   Movement Quantity = 30 Units
7. Complete the receipts.

8. Create a new Goods Receipt for F&B US, Inc. organization and US West coast Warehouse.
9. Add a line with created product:
   Product = TestingProduct
   Storage Bin = WC-0-0-0
   Movement Quantity = 12 Units
10. Add another line with created product:
   Product = TestingProduct
   Storage Bin = WC-1-0-0
   Movement Quantity = 65 Units
11. Complete the receipts.

12. Create a sales order with a line:
    Product = TestingProduct
    Ordered Quantity = 60
    Warehouse Rule = Unique Storage Bin.
13. Complete the sales order.

14. Go to the window "Create shipments from order". Select the above sales order.
15. Click process and good shipment will be created.
16. Go to Goods Shipment window and select it. Notice in the created line, that good shipment took the storage bin WC-1-0-0 of the US West coast Warehouse
    It is correct as it is the only one with available stock in an unique storage bin according the warehouse rule applied in sales order.


Test Plan 5: Related to issue 22231: Qty on hand warehouses and NO rules applied

1. Go to Organization window, select F&B US, Inc. and go to to Warehouse tab.
   Notice there are two on-hand warehouses:
     - US East Coast
     - US West Coast
2. Configure a new product as follows:
   Organization = F&B US, Inc.
   Name = Search Key = TestingProduct2
3. Add purchase and sales price list to it.

4. Create a new Goods Receipt for F&B US, Inc. organization and US East coast Warehouse.
5. Add a line with created product:
   Product = TestingProduct2
   Storage Bin = EC-0-0-0
   Movement Quantity = 45 Units
6. Add another line with created product:
   Product = TestingProduct2
   Storage Bin = EC-1-0-0
   Movement Quantity = 30 Units
7. Complete the receipts.

8. Create a new Goods Receipt for F&B US, Inc. organization and US West coast Warehouse.
9. Add a line with created product:
   Product = TestingProduct2
   Storage Bin = WC-0-0-0
   Movement Quantity = 12 Units
10. Add another line with created product:
   Product = TestingProduct2
   Storage Bin = WC-1-0-0
   Movement Quantity = 65 Units
11. Complete the receipts.

12. Create a sales order with a line for US East coast warehouse:
    Product = TestingProduct2
    Ordered Quantity = 60
    Warehouse Rule = EMPTY.
13. Complete the sales order.

14. Go to the window "Create shipments from order". Select the above sales order.
15. Click process and good shipment will be created.
16. Go to Goods Shipment window and select it. Notice in the created lines, that good shipment took the storage bins from East coast Warehouse:
    45 Units from EC-0-0-0
    15 Units from EC-1-0-0



Test Plan 6
Repeat 1-11 steps of Test Plan 5.
In 12 step when you create the sales order header, select US West coast warehouse instead of US East coast warehouse.
Repeat 13-16 steps
In 16 step, you will get a shipment with following lines:
    12 Units from WC-0-0-0
    48 Units from WC-1-0-0

(0098738)
markmm82   
2017-08-30 20:23   
Test Plan 7 Related to issue 36681: Insufficient stock in Create Standards Process of Work Effort - Production Run tab
if decimal quantities are consumed

As group admin role:
   Create a new warehouse for F&B España Region Norte
   Add a locator to it
   Increase its Relative Priority to 100
   Assign it as on hand warehouse to F&B España Region Norte organization

   Create a new product: consumed
   Set it as production
   Add 4 units of it in Region Norte warehouse
   Add more units of it in the new created warehouse

   Create a new product: produced
   Set it as production
   Assign a locator to it in the Manufacturing tab

   Create an Activity
   Create a Process Plan, Version and Operation
   Set Create Standards to 'N'
   Add 4.4 units of the previously created product to be consumed (P-)
   Add 1 unit of the previously created product to be produced (P+)

   Create a Work Requirement for that Process Plan and process it (Quantity: 1)
   Create Work Effort
   Go to Work Effort - Production Run tab, set Completed Quantity to 1
   Run Create Standards process.
   Notice it finishes successfully.
(0098739)
markmm82   
2017-08-30 21:24   
Test Plan 8 Related to issue 29539: Issues in Reservations related to Reallocate Stock functionality

0. Active Enable Stock reservations preference.

1. Create new Product

  Go to Product Window and create a new record
     Organization: F&B US
     SearchKey: Test Product
     Name: Test Product
     Tax Category: Exempt
     Sale: Checked
     Product Type: Item
     Stocked: Checked
     Attribute Set: Lot
  Go to Price Tab and create a new record
    Price List Version: General Sales
    Unit Price: 10
    List Price: 10


2. Add Stock

  Go to Physical Inventory Window and create a new record
    Organization: F&B US
    Warehouse: US East Coast
  Go to Lines Tab and create a new record
    Product. Click on the magnifing glass. Click on the funnel icon. Filter Search Key by Test Product. Pick the record that has no Attribute defined
    Attribute Set Value: Create new one. 0001
    Storage Bin: EC-0-0-0
    Quantity Count: 10
  Click on Process Inventory Count

  Create another record in Physical Inventory Window
    Organization: F&B US
    Warehouse: US East Coast
  Go to Lines Tab and create a new record
    Product. Click on the magnifing glass. Click on the funnel icon. Filter Search Key by Test Product. Pick the record that has no Attribute defined
    Attribute Set Value: Create new one. 0002
    Storage Bin: EC-0-0-0
    Quantity Count: 10
  Click on Process Inventory Count


3. Create Sales Orders with Reservations

  Go to Sales Order Window and create a new record
    Organization: F&B US
    Business Partner: Healthy Food SuperMarkets
    Warehouse: US East Coast
    Invoice Terms: Immediate
  Go to Lines Tab and create a new record
    Product: Test Product
    Ordered Quantity: 5
  Go to Basic Discounts Tab and delete the existing record
  Book the Order
  Select the Sales Order Line and click on Manage Reservations button
  Select the Line with Attribute Set Value L0001 and set Quantity to 5 and click on Done

  Create another record in Sales Order Window
    Organization: F&B US
    Business Partner: Healthy Food SuperMarkets
    Warehouse: US East Coast
    Invoice Terms: Immediate
  Go to Lines Tab and create a new record
    Product: Test Product
    Ordered Quantity: 10
  Go to Basic Discounts Tab and delete the existing record
  Book the Order
  Select the Line and click on Manage Reservations button
  Select the Line with Attribute Set Value L0002 and set Quantity to 10 and click on Done


4. Check the data before moving forward

  This query can help, just replace productid with the m_product_id desired

    select l.value, sd.m_storage_detail_id, a.lot, a.m_attributesetinstance_id, qtyonhand, reservedqty, allocatedqty
    from m_storage_detail sd
      join m_locator l using (m_locator_id)
      join m_attributesetinstance a using (m_attributesetinstance_id)
    where m_product_id = productid
      and l.em_obwhs_type IS NULL OR l.em_obwhs_type <> 'OUT'
      and lot is not null;

  It should return something like this

    Lot ------ qtyonhand ----- reservedqty ----- allocatedqty
    0001 ----- 10 ------------ 5 --------------- 0
    0002 ----- 10 ----------- 10 -------------- 0


5. Generate PickList

  Back in Sales Order Window, select the Sales Order that has 10 as the Ordered Quantity
  Click on the Generate PickList button and generate a PickList using Outbound Locator.
  Note: Be sure you has configured Warehouse Picking List dataset and an outbound locator.
  
  By launching the previous query it will return something like
    Lot ------ qtyonhand ----- reservedqty ----- allocatedqty
    0001 ----- 10 ------------ 10 -------------- 5
    0002 ----- 10 ------------ 5 --------------- 5

  As expected
(0098785)
hgbot   
2017-09-04 09:12   
Repository: erp/devel/pi
Changeset: 708d0981673dc18d7ea644daf1819245c966fa26
Author: Mark <markmm82 <at> gmail.com>
Date: Fri Sep 01 12:26:19 2017 -0400
URL: http://code.openbravo.com/erp/devel/pi/rev/708d0981673dc18d7ea644daf1819245c966fa26 [^]

Fixes issue 36690: Insufficient stock in Create Standards Process of Work Effort

When Create Standards Process of Work Effort - Production Run tab was executed
if stock is in different priority warehouses, an error message Insufficient stock
is shown even if there is stock of the product.

Problem was that in M_GET_STOCK_PARAM function v_qtyaux is decreased on each loop
and v_finalqty is taking into account stock in warehouses of the same priority than
currently analyzed, when v_qtyaux is updated always is subtracted the sum of
m_stock_proposed lines with priority less or equal than current and it is wrong.

Solution is always compare the requested quantity (v_quantity) with sum of quantities
from m_stock_proposed lines with priority less or equal than current iteration.

---
M src-db/database/model/functions/M_GET_STOCK_PARAM.xml
---
(0098786)
aferraz   
2017-09-04 09:14   
Code review + Testing OK
(0099352)
hudsonbot   
2017-09-21 16:49   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test