Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0058217Openbravo ERP07. Sales managementpublic2025-03-12 15:102025-03-27 11:55
sofidossant 
Triage Omni WMS 
normalminoralways
closedduplicate 
5
pi 
 
OBPS
Core
123870
No
0058217: Error with selector warehouse in Sales Quotation
When I create a sales quotation and add a bp, I get the warehouse incorrectly (not for order by priority).
If I have two warehouses defined as follows in an organization X, for example in ID
          m_warehouse_id | priority
----------------------------------+----------
 8522B31040604AB98F2B44D1E00CB10E | 1
 E5A38EC28320451DA813D1A7AF2A54C2 | 0

When I created a sales quotation with a org X and one bp, the SE_Order_BPartner callout is triggered, which uses:
      String strMwarehouse = strIsSOTrx.equals("N")
          ? SEOrderBPartnerData.mWarehouse(this, strBPartner)
          : SEOrderBPartnerData.mWarehouseOnhand(this, strOrgId);


This in Sales Quotation use:

        select m_warehouse_id, priority from ad_org_warehouse
        where ad_org_id = 'X'
        and (select isactive from m_warehouse where m_warehouse_id=ad_org_warehouse.m_warehouse_id)='Y'
        group by m_warehouse_id, priority
        having min(priority) = priority

For my org X should bring me first the 0 warehouse and then the priority 1 warehouse.
But the result is:

          m_warehouse_id | priority
----------------------------------+----------
 8522B31040604AB98F2B44D1E00CB10E | 1
 E5A38EC28320451DA813D1A7AF2A54C2 | 0

if I change the having to

 select m_warehouse_id, priority from ad_org_warehouse
        where ad_org_id = 'X'
        and (select isactive from m_warehouse where m_warehouse_id=ad_org_warehouse.m_warehouse_id)='Y'
        group by priority, m_warehouse_id
        having min(priority) = priority

         m_warehouse_id | priority
----------------------------------+----------
 E5A38EC28320451DA813D1A7AF2A54C2 | 0
 8522B31040604AB98F2B44D1E00CB10E | 1





This error is
PostgreSQL does not guarantee a specific order in the results unless ORDER BY is used.
Changing the order of the fields in GROUP BY should not affect the content of the results, but it may change the order in which they are processed and returned.

We need to add the order by priority, to help to the query
No tags attached.
Issue History
2025-03-12 15:10sofidossantNew Issue
2025-03-12 15:10sofidossantAssigned To => Triage Omni OMS
2025-03-12 15:10sofidossantOBNetwork customer => OBPS
2025-03-12 15:10sofidossantModules => Core
2025-03-12 15:10sofidossantSupport ticket => 123870
2025-03-12 15:10sofidossantTriggers an Emergency Pack => No
2025-03-12 18:42aferrazAssigned ToTriage Omni OMS => Triage Omni WMS
2025-03-27 11:55hgbotNote Added: 0177330
2025-03-27 11:55hgbotStatusnew => closed
2025-03-27 11:55hgbotResolutionopen => duplicate

Notes
(0177330)
hgbot   
2025-03-27 11:55   
Issue exported to Jira: https://openbravo.atlassian.net/browse/RM-24062 [^]