Openbravo Issue Tracking System - POS2
View Issue Details
0057668POS2POSpublic2025-01-16 15:222025-02-19 06:18
sofia_rodriguez 
Bimla_vm 
highminoralways
closedfixed 
5
 
 
No
0057668: Product integration fails while trying to assign a char value of a duplicated characteristic
In the back end, there are no restrictions to create a duplicated characteristic (two registers with the same name)

The main problem happens when we try to integrate a product and we want to assign a characteristic value that belongs to the duplicated characteristic

The integration is not prepared to support this case and fails in the query that gets the characteristic by name

Steps to reproduce:

1. Go to the BO
2. Open the window Product characteristics
3. Create a duplicated characteristic with some values
4. Using the Product API, integrate a product assigning a Product Characteristic created in the previous step (https://livebuilds.openbravo.com/context/retail_pos2_modules_pgsql/api#/Product/Import_Product [^])
In ImportProductJavaPropertyMappingHandler.java:

It is desired to have a setMaxResults in here

From
  private Characteristic getCharacteristicByName(String charName) {
    OBCriteria<Characteristic> criteria = OBDal.getInstance().createCriteria(Characteristic.class);
    criteria.add(Restrictions.eq("name", charName));
    return (Characteristic) criteria.uniqueResult();
  }

To
  private Characteristic getCharacteristicByName(String charName) {
    OBCriteria<Characteristic> criteria = OBDal.getInstance().createCriteria(Characteristic.class);
    criteria.add(Restrictions.eq("name", charName));
    criteria.setMaxResults(1);
    return (Characteristic) criteria.uniqueResult();
  }
No tags attached.
png image-20250116-112724.png (89,120) 2025-01-16 15:22
https://issues.openbravo.com/file_download.php?file_id=20740&type=bug
png
Issue History
2025-01-16 15:22sofia_rodriguezNew Issue
2025-01-16 15:22sofia_rodriguezAssigned To => Retail
2025-01-16 15:22sofia_rodriguezFile Added: image-20250116-112724.png
2025-01-16 15:22sofia_rodriguezTriggers an Emergency Pack => No
2025-01-17 05:20jorgewederagoAssigned ToRetail => fofarril
2025-01-17 05:20jorgewederagoStatusnew => acknowledged
2025-01-17 06:03guillermogilNote Added: 0174251
2025-01-17 06:03guillermogilTypedefect => feature request
2025-01-17 06:03guillermogilAssigned Tofofarril => Retail
2025-01-17 06:03guillermogilStatusacknowledged => scheduled
2025-01-17 06:04guillermogilStatusscheduled => resolved
2025-01-17 06:04guillermogilResolutionopen => fixed
2025-01-17 06:04guillermogilStatusresolved => new
2025-01-17 06:04guillermogilResolutionfixed => open
2025-02-04 18:00kchoperenaNote Added: 0175112
2025-02-06 10:36guillermogilNote Added: 0175209
2025-02-06 10:36guillermogilSeveritymajor => minor
2025-02-06 10:36guillermogilTypefeature request => defect
2025-02-06 10:36guillermogilProposed Solution updated
2025-02-06 10:37guillermogilAssigned ToRetail => jorgewederago
2025-02-06 10:58kchoperenaSummaryThe back office allows to register characteristics with the same name => Product integration fails while trying to assign a char value of a duplicated characteristic
2025-02-06 10:58kchoperenaDescription Updatedbug_revision_view_page.php?rev_id=29205#r29205
2025-02-06 10:58kchoperenaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=29207#r29207
2025-02-06 10:58kchoperenaProposed Solution updated
2025-02-13 14:56guillermogilStatusnew => acknowledged
2025-02-18 08:27Bimla_vmAssigned Tojorgewederago => Bimla_vm
2025-02-18 08:27Bimla_vmStatusacknowledged => scheduled
2025-02-19 06:13hgbotNote Added: 0175836
2025-02-19 06:18hgbotResolutionopen => fixed
2025-02-19 06:18hgbotStatusscheduled => closed
2025-02-19 06:18hgbotNote Added: 0175838
2025-02-19 06:18hgbotNote Added: 0175839

Notes
(0174251)
guillermogil   
2025-01-17 06:03   
Changed to FR, this is how characteristics have been defined in the product.
In case the behavior is wanted to be changed please raise it to PrM so they can review the request
(0175112)
kchoperena   
2025-02-04 18:00   
Not agree with this as we notice it in the Product Integration when we try to assign a characteristic-value . It is searching by Name the characteristic but as there is more than one defined with the same name the integration fails


We can consider a design defect and I understand that as the change is big enough to manage it as a task in JIRA makes sense to plan it but as part of the roadmap
(0175209)
guillermogil   
2025-02-06 10:36   
It is desired to have a setMaxResults in here

From
  private Characteristic getCharacteristicByName(String charName) {
    OBCriteria<Characteristic> criteria = OBDal.getInstance().createCriteria(Characteristic.class);
    criteria.add(Restrictions.eq("name", charName));
    return (Characteristic) criteria.uniqueResult();
  }

To
  private Characteristic getCharacteristicByName(String charName) {
    OBCriteria<Characteristic> criteria = OBDal.getInstance().createCriteria(Characteristic.class);
    criteria.add(Restrictions.eq("name", charName));
    criteria.setMaxResults(1);
    return (Characteristic) criteria.uniqueResult();
  }
(0175836)
hgbot   
2025-02-19 06:13   
Merge Request created: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.api/-/merge_requests/432 [^]
(0175838)
hgbot   
2025-02-19 06:18   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.api [^]
Changeset: d6732ffb31699cf7204e5c7a27a62328c045237e
Author: Bimla V Mayavan <b.mayavan@external.orisha.com>
Date: 18-02-2025 18:35:54
URL: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.api/-/commit/d6732ffb31699cf7204e5c7a27a62328c045237e [^]

Fixed ISSUE-57668: Added setMaxResults in criteria to avoid duplicated characteristic

---
M src/org/openbravo/api/mappings/product/ImportProductJavaPropertyMappingHandler.java
---
(0175839)
hgbot   
2025-02-19 06:18   
Merge request merged: https://gitlab.com/orisha-group/bu-commerce/openbravo/product/pmods/org.openbravo.api/-/merge_requests/432 [^]