Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0028908Openbravo ERP02. Master data managementpublic2015-02-10 14:032015-05-11 21:53
caristu 
jorge-garcia 
highminoralways
closedfixed 
5
pi 
3.0PR15Q3pi 
umartirena
Core
No
0028908: Not possible to delete a variant if the generic product has an image
Not possible to delete a variant if it was created from a generic product that has an image. The following error appears in the log:

2015-02-10 14:01:11,461 [ajp-localhost%2F127.0.0.1-8809-7] ERROR org.hibernate.util.JDBCExceptionReporter - Batch entry 0 delete from AD_Image where AD_Image_ID='image_UUID' was aborted. Call getNextException to see the cause.
2015-02-10 14:01:11,461 [ajp-localhost%2F127.0.0.1-8809-7] ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: update or delete on table "ad_image" violates foreign key constraint "m_product_ad_image" on table "m_product"
  Detail: Key (ad_image_id)=(image_UUID) is still referenced from table "m_product".
1) Go to the [Product Characteristic] window. Create a new variant characteristic with one value at least
2) In the [Product] window create a new generic product and set an image for it
3) Assign the characteristic created in 1) to the generic product
4) Generate some variants, for example using the Manage Variants process
5) Try to delete one of the variants
No tags attached.
Issue History
2015-02-10 14:03caristuNew Issue
2015-02-10 14:03caristuAssigned To => Sandrahuguet
2015-02-10 14:03caristuModules => Core
2015-02-10 14:03caristuResolution time => 1430172000
2015-02-10 14:03caristuTriggers an Emergency Pack => No
2015-02-23 13:30jonalegriaesarteTarget Version3.0PR15Q2 => 3.0PR15Q3
2015-03-09 17:34jonalegriaesarteResolution time1430172000 =>
2015-04-01 16:53jorge-garciaStatusnew => scheduled
2015-04-01 16:53jorge-garciaAssigned ToSandrahuguet => jorge-garcia
2015-05-06 13:05jorge-garciaNote Added: 0077050
2015-05-07 16:46hgbotCheckin
2015-05-07 16:46hgbotNote Added: 0077098
2015-05-07 16:46hgbotStatusscheduled => resolved
2015-05-07 16:46hgbotResolutionopen => fixed
2015-05-07 16:46hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/50fe70db3a66713b3795e6f21a2481e37553d14e [^]
2015-05-07 16:46hgbotCheckin
2015-05-07 16:46hgbotNote Added: 0077099
2015-05-07 16:46umartirenaReview Assigned To => umartirena
2015-05-07 16:46umartirenaNote Added: 0077100
2015-05-07 16:46umartirenaStatusresolved => closed
2015-05-07 16:46umartirenaFixed in Version => pi
2015-05-08 11:16hgbotCheckin
2015-05-08 11:16hgbotNote Added: 0077225
2015-05-08 15:39hudsonbotCheckin
2015-05-08 15:39hudsonbotNote Added: 0077248
2015-05-08 15:39hudsonbotCheckin
2015-05-08 15:39hudsonbotNote Added: 0077249
2015-05-11 21:53hudsonbotCheckin
2015-05-11 21:53hudsonbotNote Added: 0077309

Notes
(0077050)
jorge-garcia   
2015-05-06 13:05   
Test Plan

1) Go to the [Product Characteristic] window.
  Create a new variant characteristic with one value at least
2) In the [Product] window create a new generic product and set an image for it
3) Search the image in the ad_image table in the database.
4) Assign the characteristic created in step 1) to the generic product.
5) Generate some variants, using the Manage Variants process.
6) Try to delete one of the variants.
7) Check that the generic product and the rest of the variants still have the associated image.
8) Keep deleting the variants and checking the image is still associated.
9) Finally, delete the generic product you created in step 2) and check the image is deleted in the database.
(0077098)
hgbot   
2015-05-07 16:46   
Repository: erp/devel/pi
Changeset: 50fe70db3a66713b3795e6f21a2481e37553d14e
Author: Jorge Garcia <jorge.garcia <at> openbravo.com>
Date: Tue May 05 11:44:51 2015 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/50fe70db3a66713b3795e6f21a2481e37553d14e [^]

Fixed issue 28908: Not possible to delete a variant if has an image

Not possible to delete a variant if the generic product has an image.

The problem was that the image is shared among the generic product and
its variants.

The solution is to check if other products has the same image_id when deleting
 a record. In case that this check is true, the image isn't deleted from the
database, otherwise, the image is deleted from the database.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/event/RemoveImagesEventHandler.java
---
(0077099)
hgbot   
2015-05-07 16:46   
Repository: erp/devel/pi
Changeset: 3689ff974394155d3194670a1d854a89fd22aa3e
Author: Unai Martirena <unai.martirena <at> openbravo.com>
Date: Thu May 07 16:45:23 2015 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/3689ff974394155d3194670a1d854a89fd22aa3e [^]

Related to bug 28908: Fix copyright and format

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/event/RemoveImagesEventHandler.java
---
(0077100)
umartirena   
2015-05-07 16:46   
Code Review + Testing OK
(0077225)
hgbot   
2015-05-08 11:16   
Repository: erp/devel/pi
Changeset: 387af567776f559ad30a170319726bbf403ee590
Author: Unai Martirena <unai.martirena <at> openbravo.com>
Date: Fri May 08 11:11:43 2015 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/387af567776f559ad30a170319726bbf403ee590 [^]

Related to bug 28908: Code Review

[1]: Only check if any other product is using the image, if current product has an image.
[2]: Make method 'checkImageUtilization' more understandable returning a boolean value instead of a Product object that is not used later on.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/event/RemoveImagesEventHandler.java
---
(0077248)
hudsonbot   
2015-05-08 15:39   
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/d5cb256a6a8a [^]
Maturity status: Test
(0077249)
hudsonbot   
2015-05-08 15:39   
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/d5cb256a6a8a [^]
Maturity status: Test
(0077309)
hudsonbot   
2015-05-11 21:53   
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/a55bc3c14e8c [^]
Maturity status: Test