Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0030571Openbravo ERPA. Platformpublic2015-08-13 12:532015-09-04 11:16
AugustoMauch 
AugustoMauch 
normalminorhave not tried
closedfixed 
5
 
 
alostale
Core
No
0030571: It is not possible to remove a row if it contains a mandatory image
If a suer tries to remove a row from a table that has a mandatory image column, an error message will be shown and the row will not be removed.

The error shown is: "null value in column “imageColumn” violates not-null constraint"
- Execute an update query to assign an image to all products.
- Modify the ad_image_id of the m_product table and make it not null. Update it also in the application dictionary to make it mandatory.
- As F&B Admin, create a new product and assign it a new image. Save the record
- Select the record and try to remove it. An error message will be shown and the record will not be deleted.
No tags attached.
related to defect 0040046 closed caristu unnecessary objects are created every time any DAL object is created/updated/deleted 
Issue History
2015-08-13 12:53AugustoMauchNew Issue
2015-08-13 12:53AugustoMauchAssigned To => platform
2015-08-13 12:53AugustoMauchModules => Core
2015-08-13 12:53AugustoMauchTriggers an Emergency Pack => No
2015-08-13 13:33AugustoMauchIssue Monitored: alostale
2015-08-13 13:33AugustoMauchReview Assigned To => alostale
2015-08-13 13:36hgbotCheckin
2015-08-13 13:36hgbotNote Added: 0079349
2015-08-13 13:36hgbotStatusnew => resolved
2015-08-13 13:36hgbotResolutionopen => fixed
2015-08-13 13:36hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/e75e4dc96dca2230210983b2cf6a4953901d6f7c [^]
2015-08-14 09:09alostaleAssigned Toplatform => AugustoMauch
2015-08-14 09:12alostaleNote Added: 0079351
2015-08-14 09:12alostaleStatusresolved => new
2015-08-14 09:12alostaleResolutionfixed => open
2015-08-14 13:26hgbotCheckin
2015-08-14 13:26hgbotNote Added: 0079361
2015-08-14 13:26hgbotStatusnew => resolved
2015-08-14 13:26hgbotResolutionopen => fixed
2015-08-14 13:26hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/e75e4dc96dca2230210983b2cf6a4953901d6f7c [^] => http://code.openbravo.com/erp/devel/pi/rev/5a32bf149f40131d3f7bf643b2be3af0979bd3ae [^]
2015-08-20 23:16hudsonbotCheckin
2015-08-20 23:16hudsonbotNote Added: 0079550
2015-08-20 23:16hudsonbotCheckin
2015-08-20 23:16hudsonbotNote Added: 0079553
2015-09-03 10:48dmitry_mezentsevNote Added: 0080037
2015-09-04 11:16alostaleNote Added: 0080088
2015-09-04 11:16alostaleStatusresolved => closed
2019-01-30 13:22caristuRelationship addedrelated to 0040046

Notes
(0079349)
hgbot   
2015-08-13 13:36   
Repository: erp/devel/pi
Changeset: e75e4dc96dca2230210983b2cf6a4953901d6f7c
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Thu Aug 13 13:31:57 2015 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/e75e4dc96dca2230210983b2cf6a4953901d6f7c [^]

Fixes issue 30571: Rows with mandatory image columns can be removed

When a row contains columns that use the ad_image reference, those images are removed when the row is removed in the RemoveImagesEventHandler. This is an event handler that is executed before the row is removed, so removing the image results in a query like this:

update my_table set my_image_field = null

This is a problem is the image column is mandatory.

There were two ways to fix this:
- Give support to event handlers that are executed after the row is removed.
- Set a dummy image to the deleted row, to avoid breaking the not null constraint.

The first option is very complex, so the first one has been chosen.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/event/RemoveImagesEventHandler.java
---
(0079351)
alostale   
2015-08-14 09:12   
Reopening due to some performance issues:

* This new logic should be executed only for mandatory image columns, now it is executed for all
* getDummyImage should be executed only if needed, now it is executed always
* Dummy image should be identified by a special ID rather than by name, ad_image is not indexed by name, looking up dummy image by this column causes a sequential scan which can perform badly with big amount of image records
(0079361)
hgbot   
2015-08-14 13:26   
Repository: erp/devel/pi
Changeset: 5a32bf149f40131d3f7bf643b2be3af0979bd3ae
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Fri Aug 14 13:23:23 2015 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/5a32bf149f40131d3f7bf643b2be3af0979bd3ae [^]

Fixes issue 30571: Creates a dummy image only when needed, fetches it via its id

The initial fix was suboptimal as the dummy image was queried/created even if its property was not mandatory. Also, the image was initially fetch via its name, which is a non indexes column. Now it is fetched via its id.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/event/RemoveImagesEventHandler.java
---
(0079550)
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
(0079553)
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
(0080037)
dmitry_mezentsev   
2015-09-03 10:48   
Not closed for 20 days!!!
(0080088)
alostale   
2015-09-04 11:16   
code reviewed + tested

Reported performance problems are now fixed