Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0038861Openbravo ERP02. Master data managementpublic2018-06-29 08:492018-08-08 13:06
ngarcia 
markmm82 
urgentmajoralways
closedfixed 
5
 
3.0PR18Q4 
dmiguelez
Core
No
0038861: Empty error message shown in Create Variants if the Product Characteristic has Subset but not values
Empty error message shown in Create Variants if the Product Characteristic has Subset but not values
As group admin role:
   Create a new Product Characteristic
   Set it as Variant
   Add a Subset to it
   Create a new Product
   Set it as Generic
   Set the previously created Characteristic
   Launch Create Variants Process and check an empty error message is shown
   The log shows

      ERROR org.openbravo.materialmgmt.VariantAutomaticGenerationProcess - Exception processing variant generation
java.util.NoSuchElementException
    at java.util.ArrayList$Itr.next(ArrayList.java:840)
    at org.openbravo.materialmgmt.VariantAutomaticGenerationProcess$ProductCharacteristicAux.getNextValue(VariantAutomaticGenerationProcess.java:342)
    at org.openbravo.materialmgmt.VariantAutomaticGenerationProcess.execute(VariantAutomaticGenerationProcess.java:124)
No tags attached.
Issue History
2018-06-29 08:49ngarciaNew Issue
2018-06-29 08:49ngarciaAssigned To => Triage Finance
2018-06-29 08:49ngarciaModules => Core
2018-06-29 08:49ngarciaResolution time => 1532037600
2018-06-29 08:49ngarciaTriggers an Emergency Pack => No
2018-06-29 08:49ngarciaIssue Monitored: networkb
2018-07-16 16:35markmm82Assigned ToTriage Finance => markmm82
2018-07-16 16:35markmm82Statusnew => scheduled
2018-07-20 01:24markmm82Note Added: 0105815
2018-07-24 15:49hgbotCheckin
2018-07-24 15:49hgbotNote Added: 0105917
2018-07-24 15:49hgbotStatusscheduled => resolved
2018-07-24 15:49hgbotResolutionopen => fixed
2018-07-24 15:49hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/1dbba4eb40f8d6e0efac921637eeffb27a0e963c [^]
2018-07-24 15:49dmiguelezReview Assigned To => dmiguelez
2018-07-24 15:49dmiguelezNote Added: 0105918
2018-07-24 15:49dmiguelezStatusresolved => closed
2018-07-24 15:49dmiguelezFixed in Version => 3.0PR18Q4
2018-08-08 13:06hudsonbotCheckin
2018-08-08 13:06hudsonbotNote Added: 0106224

Notes
(0105815)
markmm82   
2018-07-20 01:24   
Test Plan:
As group admin role:
   Create a new Product Characteristic. Set it as Variant
     Name = PC
     Variant = Yes
   Create a new Product. Set it as Generic
     Search Key = Name = P
     Is Generic = Y
   Launch Create Variants Process and check an error message is shown:
     Error:
     Variants can not be created because the Generic Product does not have any Characteristic defined as Variant.
   It is correct due we have not defined any characteristic yet to the product.
   Go to Characteristics tab and add the previously created Characteristic
     Characteristic = PC
     Variant = Yes
   Launch Create Variants Process and check the following message is shown:
     Process completed successfully
     0 variants created.
   It is correct because the product characteristic has any value defined.

   Go to the previously created Product Characteristic and add a Subset to it, DON'T DEFINE ANY VALUE TO IT.
   Move to the Product window and Launch Create Variants Process for the previously created product (P) and check the following message is shown:
     Process completed successfully
     0 variants created.
   It is correct because although the product characteristic has a subset defined it hasn't any value defined.

   Go to the previously created Product Characteristic but this time we going to add values to the existing Subset.
   First add two new values in the Value tab:
      1st record => Name = Code = V1
      2nd record => Name = Code = V2
   Add two new subset values from previosly created values V1 and V2

   Launch Create Variants Process and check the message is shown:
     Process completed successfully
     2 variants created
   Notice there are two new entries in Characteristic Configuration tab, each one for each characteristic value V1 and V2
(0105917)
hgbot   
2018-07-24 15:49   
Repository: erp/devel/pi
Changeset: 1dbba4eb40f8d6e0efac921637eeffb27a0e963c
Author: Mark <markmm82 <at> gmail.com>
Date: Wed Jul 18 17:56:03 2018 -0400
URL: http://code.openbravo.com/erp/devel/pi/rev/1dbba4eb40f8d6e0efac921637eeffb27a0e963c [^]

Fixes issue 38861: Fixed Create Variants if ProductCharacteristic hasn't values

An empty error message was shown in Create Variants if the Product Characteristic
hadd Subset but not values because it was trying to iterate hover an empty collection
in an incorrect way.

This solution includes:
- Save in a local variable the list with the Product Characteristics to be processed
  to avoid calling .list() method twice because it will repeat the same query and it is
  not needed.
- Avoid using a OBCriteria to get the list of ProductCharacteristicConf objects defined
  for the ProductCharacteristic is processing. This list is accessed directly from the
  object by calling the prCh.getProductCharacteristicConfList() method.
- If the processing ProductCharacteristic hasn't any configuration then it is not executed
  the section of code in charge of create the auxiliary information to be used to create
  the variants. In this way the exception throwed in the issue is not happening.
- Avoid to try to generate variants if there aren't any product characteristic configuration.
  The hasNext flag is initiallized with true if exists at least one variant to be created, and false
  in other case.
- Modified the do {} while block to use a while block and avoid create the first variant if any exists.

---
M src/org/openbravo/materialmgmt/VariantAutomaticGenerationProcess.java
---
(0105918)
dmiguelez   
2018-07-24 15:49   
Code Review + Testing Ok
(0106224)
hudsonbot   
2018-08-08 13:06   
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/bfd7a414183a [^]
Maturity status: Test