Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0030376Openbravo ERP02. Master data managementpublic2015-07-15 18:462015-08-20 23:16
VictorVillar 
AtulOpenbravo 
urgentmajoralways
closedfixed 
5
pi 
3.0PR15Q4 
vmromanos
Core
No
0030376: The Create Price List process is modifying the Current Vendor field when it should not
The Create Price List process is modifying the Current Vendor field when it should not
As System Admin,
  Go to Windows, tabs and fields:
    select the Product window - Purchasing Tab
    Organization field = Yes

Log out and Log in.
 
Go to Product window
   Add two registers for different organizations.
   Add 2 Business Partners in Purchasing tab with the same Price List defined. Current Vendor = Yes for both registers. 2 different organizations
   Add the same Price List to the product.

Go to Price List window,
  select the same Price List as before
  Click on 'Create Price List' button (Note that you should have define a base price list in the price list version)
  When finishes realise that the process has changed the flag 'current vendor'. Now it has 'N'.


The problem is in the m_pricelist_create function:

/**
    * Make sure that we have only one active product
    */
    v_ResultStr:='CorrectingDuplicates';
    RAISE NOTICE '%',v_ResultStr ;
    DECLARE
      -- All duplicate products
      Cur_Duplicates RECORD;
      -- All vendors of Product - expensive first
      DECLARE Cur_Vendors CURSOR (Product_ID VARCHAR) FOR
        SELECT M_Product_ID,
          C_BPartner_ID
        FROM M_Product_PO
        WHERE IsCurrentVendor='Y'
          AND IsActive='Y'
          AND M_Product_ID=Product_ID
        ORDER BY PriceList DESC;
        --
        Product_ID VARCHAR(32); --OBTG:VARCHAR2--
        BPartner_ID VARCHAR(32); --OBTG:VARCHAR2--
      BEGIN
        FOR Cur_Duplicates IN
          (SELECT DISTINCT M_Product_ID
          FROM M_Product_PO po
          WHERE IsCurrentVendor='Y'
            AND IsActive='Y'
            AND EXISTS
            (SELECT M_Product_ID
            FROM M_Product_PO x
            WHERE x.M_Product_ID=po.M_Product_ID
            GROUP BY M_Product_ID
            HAVING COUNT(*)>1
            )
          ORDER BY 1
          )
        LOOP
          OPEN Cur_Vendors(Cur_Duplicates.M_Product_ID) ;
          FETCH Cur_Vendors INTO Product_ID,
          BPartner_ID; -- Leave First
          LOOP
            FETCH Cur_Vendors INTO Product_ID,
            BPartner_ID; -- Get Record ID
            EXIT WHEN NOT FOUND ; --OBTG:Cur_Vendors--
            --
            RAISE NOTICE '%',' Record: ' || Product_ID || ' / ' || BPartner_ID ;
            UPDATE M_Product_PO
              SET IsCurrentVendor='N'
            WHERE M_Product_ID=Product_ID
              AND C_BPartner_ID=BPartner_ID;
          END LOOP;
          CLOSE Cur_Vendors;
        END LOOP;
It should not change anything.
No tags attached.
Issue History
2015-07-15 18:46VictorVillarNew Issue
2015-07-15 18:46VictorVillarAssigned To => Triage Finance
2015-07-15 18:46VictorVillarModules => Core
2015-07-15 18:46VictorVillarResolution time => 1438898400
2015-07-15 18:46VictorVillarTriggers an Emergency Pack => No
2015-07-15 18:46VictorVillarIssue Monitored: networkb
2015-07-16 09:01jpcalventeIssue Monitored: jpcalvente
2015-07-16 09:18AtulOpenbravoAssigned ToTriage Finance => AtulOpenbravo
2015-07-16 09:18AtulOpenbravoStatusnew => scheduled
2015-07-17 09:18AtulOpenbravoNote Added: 0078910
2015-07-17 09:18AtulOpenbravoNote Edited: 0078910bug_revision_view_page.php?bugnote_id=0078910#r9056
2015-07-17 10:04hgbotCheckin
2015-07-17 10:04hgbotNote Added: 0078913
2015-07-17 10:04hgbotStatusscheduled => resolved
2015-07-17 10:04hgbotResolutionopen => fixed
2015-07-17 10:04hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/116e50e703f6b420f6fc087aa72663d0ede7d1cb [^]
2015-07-17 10:04hgbotCheckin
2015-07-17 10:04hgbotNote Added: 0078914
2015-07-17 10:04hgbotCheckin
2015-07-17 10:04hgbotNote Added: 0078915
2015-07-17 10:06vmromanosReview Assigned To => vmromanos
2015-07-17 10:06vmromanosNote Added: 0078916
2015-07-17 10:06vmromanosStatusresolved => closed
2015-08-20 23:16hudsonbotCheckin
2015-08-20 23:16hudsonbotNote Added: 0079497
2015-08-20 23:16hudsonbotCheckin
2015-08-20 23:16hudsonbotNote Added: 0079498
2015-08-20 23:16hudsonbotCheckin
2015-08-20 23:16hudsonbotNote Added: 0079499

Notes
(0078910)
AtulOpenbravo   
2015-07-17 09:18   
Test Plan
- Login as System Admin,
    Go to Windows, tabs and fields:
    Select the Product window - Purchasing Tab
    Set Organization field Displayed = Yes

- Log out and Log in.
 
- Go to Product window
   Add a Product for eg:- F&B Inc US.
   Add two registers in Purchasing Tab for 2 different Organization, 2
     different Business Partners, set same List Price, Current Vendor = Yes.
   Add the Product Price to the product for some Price List.

- Go to Price List window,
   Select the same Price List in which Product Price was created for above
     product.
   Create a new Price List Version. Set Base Price List as above. Fill up name
     Valid till Date, etc. Save record.
   Click on 'Create Price List' button

- When create price list process finishes, check Current Vendor flag for both registers in the Purchasing Plan. They are not changed by the above process. They are set as Yes.

(0078913)
hgbot   
2015-07-17 10:04   
Repository: erp/devel/pi
Changeset: 116e50e703f6b420f6fc087aa72663d0ede7d1cb
Author: Atul Gaware <atul.gaware <at> openbravo.com>
Date: Thu Jul 16 17:21:16 2015 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/116e50e703f6b420f6fc087aa72663d0ede7d1cb [^]

Fixes Issue 30376:The Create Price List process is modifying the Current
Vendor field when it should not

In case of multiple m_product_po register's for same product and same
business partner keeping iscurrentvendor flag active only for one register
is no more needed due to unique constraint applied on m_product_po for
m_product_id and c_bpartner_id during r2.5x merge into trunk.

---
M src-db/database/model/functions/M_PRICELIST_CREATE.xml
---
(0078914)
hgbot   
2015-07-17 10:04   
Repository: erp/devel/pi
Changeset: 131b77a5d55b5eb27b93fa85bd606eb3ac157021
Author: Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
Date: Fri Jul 17 09:30:16 2015 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/131b77a5d55b5eb27b93fa85bd606eb3ac157021 [^]

Related to issue 30376: code review improvements
Removed piece of code where IsCurrentVendor is set to Y. This process shouldn't update this column

---
M src-db/database/model/functions/M_PRICELIST_CREATE.xml
---
(0078915)
hgbot   
2015-07-17 10:04   
Repository: erp/devel/pi
Changeset: 94988f01014d317b55cf3b44ce75261155419abd
Author: Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
Date: Fri Jul 17 09:43:31 2015 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/94988f01014d317b55cf3b44ce75261155419abd [^]

Related to issue 30376: M_PriceList_Create removed unreached code
At the beginning of the process an error is raised when v_Costbased = 'N' AND (v_PriceList_Version_Base_ID IS NULL OR v_PriceList_Version_Base_ID='').
In this changeset we delete the code afterwards that would be only executed when the previous condition is true

---
M src-db/database/model/functions/M_PRICELIST_CREATE.xml
---
(0078916)
vmromanos   
2015-07-17 10:06   
Code review + testing OK
(0079497)
hudsonbot   
2015-08-20 23:16   
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/8c91718397a5 [^]
Maturity status: Test
(0079498)
hudsonbot   
2015-08-20 23:16   
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/8c91718397a5 [^]
Maturity status: Test
(0079499)
hudsonbot   
2015-08-20 23:16   
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/8c91718397a5 [^]
Maturity status: Test