Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0012308Openbravo ERP06. Material requirement planning (MRP)public2010-02-16 19:162010-05-18 12:12
mensenjh 
harikrishnan 
highmajoralways
closedfixed 
20Community Appliance
2.50MP11 
2.50MP172.50MP15 
Core
No
0012308: Closed Purchase Orders in Purchasing Plan
1) Closed Purchase Orders are included in the Purchasing Plan with a negative qty after completing purchase invoice.

2) Even though closed orders are included in the plan, the new suggested purchase quantity does not make sense.
1. Create procurement/sales material suitable for procurement planning.
2. Create sales order for material.
3. Create purchase plan and create purchase order
4. Create purchase plan: there is pending purchase order
5. Receive purchase order
6. Create purchase plan: there is no pending purchase order
7. Create purchase invoice: do not complete
8. Create purchase plan: there is no pending purchase order
9. Complete previous invoice
10. Create purchase plan: there is 1 pending purchase order with negative qty for previous purchase !!!
No tags attached.
has duplicate defect 00112682.50MP17 closed adrianromero MRP: Purchasing plan is showing unexplainable negative quantities for Purchase Order lines that were already received 
? MRP_ClosedOrders.odt (89,957) 2010-02-16 19:16
https://issues.openbravo.com/file_download.php?file_id=2226&type=bug
Issue History
2010-02-16 19:16mensenjhNew Issue
2010-02-16 19:16mensenjhAssigned To => adrianromero
2010-02-16 19:16mensenjhFile Added: MRP_ClosedOrders.odt
2010-02-16 19:17mensenjhIssue Monitored: mensenjh
2010-02-17 13:39adrianromeroNote Added: 0024490
2010-02-17 13:39adrianromeroPriorityimmediate => normal
2010-02-17 13:39adrianromeroSeveritycritical => minor
2010-02-17 21:22pjuvaraPrioritynormal => high
2010-02-17 21:22pjuvaraSeverityminor => major
2010-02-18 09:47adrianromeroStatusnew => scheduled
2010-02-18 09:47adrianromerofix_in_branch => pi
2010-02-18 09:47adrianromeroTarget Version => 2.50MP14
2010-02-18 09:47adrianromerofix_in_branchpi =>
2010-03-02 04:25eintelauIssue Monitored: eintelau
2010-03-04 19:20adrianromeroNote Added: 0025066
2010-03-04 19:20adrianromeroStatusscheduled => feedback
2010-03-05 11:53mensenjhNote Added: 0025077
2010-03-08 16:05jpabloaeTarget Version2.50MP14 => 2.50MP15
2010-03-09 18:40adrianromeroNote Added: 0025190
2010-03-13 05:54harikrishnanAssigned Toadrianromero => harikrishnan
2010-03-13 05:56hgbotCheckin
2010-03-13 05:56hgbotNote Added: 0025437
2010-03-13 05:56hgbotStatusfeedback => resolved
2010-03-13 05:56hgbotResolutionopen => fixed
2010-03-13 05:56hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/00600b268925e20657afec9148d19cc414e8cd28 [^]
2010-03-13 06:57harikrishnanNote Added: 0025438
2010-03-13 18:42mensenjhNote Added: 0025440
2010-03-15 11:06gorkaionNote Added: 0025458
2010-03-16 08:41hudsonbotCheckin
2010-03-16 08:41hudsonbotNote Added: 0025520
2010-03-16 10:25rafarodaIssue Monitored: rafaroda
2010-03-16 13:02mensenjhNote Added: 0025537
2010-04-07 16:28pjuvaraIssue Monitored: pjuvara
2010-04-07 17:58adrianromeroNote Added: 0025955
2010-04-12 10:34mensenjhNote Added: 0026059
2010-04-16 18:49sureshbabuNote Added: 0026324
2010-04-16 18:49sureshbabuStatusresolved => closed
2010-04-16 18:49sureshbabuFixed in Version => 2.50MP15
2010-04-17 00:00anonymoussf_bug_id0 => 2988596
2010-04-26 18:49adrianromeroRelationship addedhas duplicate 0011268
2010-05-18 12:12gorka_gilTarget Version2.50MP15 => 2.50MP17

Notes
(0024490)
adrianromero   
2010-02-17 13:39   
Modified the severity and priority to follow the bug reporting guidelines:

http://wiki.openbravo.com/wiki/Bug_Reporting_Guidelines#How_to_Choose_the_Right_Severity [^]
(0025066)
adrianromero   
2010-03-04 19:20   
Hello

We are trying to reproduce this issue but we need a explanations in detail of the steps required to reproduce it.

Please, could you provide it.

(0025077)
mensenjh   
2010-03-05 11:53   
See trasnaction details below. I'm expecting knowledge on how to go through transactions and how to set up a material for planning.

1. Create procurement/sales material suitable for procurement planning.

Master Data Management || Product || Product
make sure set up for procurement and sales in header tab
Planning method in tab Org specific that includes MRP, Pending sales order, Pending Purchase Order

2. Create sales order for material.
Sales Management || Transactions || Sales Order || Header

3. Create purchase plan and create purchase order
Material Requirement (MRP) || Transactions || Purchasing Plan || Header (& Line)

4. Create purchase plan: there is pending purchase order
See step 3


5. Receive purchase order

Procurement Management || Transactions || Pending Goods Receipts || Pending Goods Receipts

6. Create purchase plan: there is no pending purchase order
See step 3

7. Create purchase invoice: do not complete

Procurement Management || Transactions || Purchase Invoice || Header

8. Create purchase plan: there is no pending purchase order
See step 3

9. Complete previous invoice
See step 7 > Press complete

10. Create purchase plan: there is 1 pending purchase order with negative qty for previous purchase !!! This order is ctually already received but is displayed anyway and planning results are incorrect.

See step 3
(0025190)
adrianromero   
2010-03-09 18:40   
There are instructions to setup MRP in the following document http://wiki.openbravo.com/wiki/HOW_TO_MRP [^]

The error is probably in the PL function MRP_RUN_INITIALIZE in the line starting by FOR Cur_OrderLine IN.

The calculation to review in this line is

(ol.QTYORDERED - COALESCE(ol.QTYDELIVERED, 0) - COALESCE(matchpo.qty,0)) AS qty
(0025437)
hgbot   
2010-03-13 05:56   
Repository: erp/devel/pi
Changeset: 00600b268925e20657afec9148d19cc414e8cd28
Author: Harikrishnan Raja <harikrishnan.raja <at> openbravo.com>
Date: Sat Mar 13 10:31:41 2010 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/00600b268925e20657afec9148d19cc414e8cd28 [^]

Fixes Issue 12308: Closed Purchase Orders in Purchasing Plan.

---
M src-db/database/model/functions/MRP_RUN_INITIALIZE.xml
---
(0025438)
harikrishnan   
2010-03-13 06:57   
Steps to test:

# Create a Planner (Material Requirement (MRP) || Setup || Planner || Planner ) with the following data:

   1. Name: Test Planner

# Create a new Planning Method (Material Requirement (MRP) || Setup || Planning Method || Planning Method) with the following data:

   1. Name: Test Planning Method
   2. Lines: Pending Sales Orders with Days to End = 30 and Weighting = 1
   3. Lines: Material Requirement with Days to End = 30 and Weighting = 1
   4. Lines: Pending Purchase Orders with Days to End = 30 and Weighting = 1
#Create a new product(Master Data Management || Product || Product )
    Product:
        *Name : Test Product
        *Dont select the production check box,Select only the sales and purchase.
    Purchasing (Master Data Management || Product || Product >> Purchasing )
        Business Partner = Edison
        Min. Quantity Order = 4
        Purchasing Lead Time = 5
    Org Specific (Master Data Management || Product || Product >> Org Specific )
        Organization = Main;
        Planning Method = Test Planning Method
        Planner = Test Planner
        Safety Stock = 12
    Price (Master Data Management || Product || Product >> Price ).
        1.Price List Version : Purchase 2006;List Price:100;Standard Price :75;Price Limit:70
        2.Price List Version : Sales 2006;List Price:110;Standard Price :90;Price Limit:80
#Create a new standard sales order.
    Header (Sales Management || Transactions || Sales Order || Header )
        Business Partner : McGiver Supplies
        Transaction Document :Standard Order
        Order Date : take any date further (eg:30/03/2010)
    Lines (Sales Management || Transactions || Sales Order || Header >> Lines )
        Product : Test Product
    Complete the order
#Create a new purchasing plan.
    Header (Material Requirement (MRP) || Transactions || Purchasing Plan || Header )
        Time Horizon:60
        Safety Lead Time : 1
        Product : Test Product
        Select blank to this fields :Product Category ,Business Partner Category
    Click the button "Process Purchase Plan".
The lines are generated,with pending sales order and since their is no stock it ll suggest to create a purchase order.
#Create a new purchase order
    Header (Procurement Management || Transactions || Purchase Order || Header )
        Business partner : McGiver Supplies
    Lines (Procurement Management || Transactions || Purchase Order || Header >> Lines )
        Product : Test Product
        Ordered Quantity : 10
REPEATED PHASE : Now go to Purchasing plan and delete all the lines.Then again run the purchasing plan.
#Now you can notice the pending purchase order.
#Now create a goods receipt for the above purchase order.
#REPEATED PHASE
#Now you can notice the pending purchase order will be removed.
#Create a purchase invoice for the above receipt.
#REPEATED PHASE
#Now the negative quantity wont appear.
(0025440)
mensenjh   
2010-03-13 18:42   
I added the corrected code manually and did ant compile.complete. I did the test but do not see the fix. What is missing in the note from harikrishnan is the step to complete the invoice. Now it seems it is only created. When I compelte the invoice I still see the pending order in the purchasing plan. Assuming I took the right steps to incorporate the fix manually, it is not yet fixed.
(0025458)
gorkaion   
2010-03-15 11:06   
where did you correct the code. If you have changed the xml file you have to run 'ant update.database' to apply the fix in the database. If you have changed something in core you should do before an 'ant export.database'.
(0025520)
hudsonbot   
2010-03-16 08:41   
A changeset related to this issue has been promoted to main after passing a series of tests and an OBX has been generated:

Changeset: http://code.openbravo.com/erp/devel/main/rev/00600b268925 [^]
Merge Changeset: http://code.openbravo.com/erp/devel/main/rev/3e52c5b52d67 [^]
Tests: http://builds.openbravo.com/view/devel-int/ [^]
OBX: http://builds.openbravo.com/erp/core/obx/OpenbravoERP-2.50CI.16713.obx [^]
(0025537)
mensenjh   
2010-03-16 13:02   
I changed the xml file and now did ant update.database with force enabled. Now when I run procurement plan I get the error: cache lookup failed for function 34650 (see attchment). Did I corrupt my database or is this related to the fix?
(0025955)
adrianromero   
2010-04-07 17:58   
Hello.

Could you please test the same path to reproduce this error in our nigthly builds enviroment?

http://live.builds.openbravo.com/erp_devel_pi-full-oracle [^]
http://live.builds.openbravo.com/erp_devel_pi-full-pgsql [^]

This way we can differenciate whether the issue you get is an issue related to the fix or related to your environment.

Thanks.
(0026059)
mensenjh   
2010-04-12 10:34   
Checked on the nightly (pgsql) build with product beer. Everything A-OK. Thanks.
(0026324)
sureshbabu   
2010-04-16 18:49   
Tested working fine