Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0031241Openbravo ERPA. Platformpublic2015-10-23 14:552022-02-01 08:09
lorenzofidalgo 
Triage Platform Base 
normalminoralways
acknowledgedopen 
5
main 
 
Google Chrome
Core
No
0031241: [15Q4] Inconsistent changes if user creates a discount with Sell at Cost Discretionary Discount module & later it's uninstalled
Creating a discount with "Sell at Cost Discretionary Discount" module and, after that, trying to uninstall module creates inconsistences in database.

Errors shown:
-------------------
Error: Not all the foreign keys were correctly activated. Please review which ones were not, and fix the missing references, or recover the backup of your sources.
Error: The following error occurred while executing this line: /opt/OpenbravoERP/src-db/database/build.xml:81: Java returned: 1
Error: Not all the foreign keys were correctly activated. Please review which ones were not, and fix the missing references, or recover the backup of your sources.
-------------------
Log File:
--------------
"set.code.rev:

code.rev:

init:

core.lib:

init:

compile:

build.jar:

build:

copy.core.lib:

database.lib:

compile:

jar:

buildvalidation:
[sql] Executing commands
[sql] 2 of 2 SQL statements executed successfully

buildvalidation:
[java] 0 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.AccountingTabs
[java] 1624 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.CheckUpdateConnectionPoolMerge
[java] 1644 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.DatabaseDecimalNumberCheck
[java] 1650 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.DatabaseVersionCheck
[java] 1710 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.DuplicateDocExchangeRate
[java] 1802 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.DuplicatedJavaPackage
[java] 1837 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.DuplicatedOrgWarehouse
[java] 1914 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.DuplicatedPriceListVersion
[java] 1943 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.GLJournalAccountingCheck
[java] 1948 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.PaymentGLItemCheck
[java] 1990 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.PreferenceConflict
[java] 2013 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.RemoveCostingRuleProcessExecutions
[java] 2026 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.buildvalidation.User1Ready
[java] 2032 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.advpaymentmngt.buildvalidation.TransactionsWithMissingData
[java] 2037 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.advpaymentmngt.buildvalidation.UniquePaymentForTransaction
[java] 2057 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.advpaymentmngt.buildvalidation.UnpostRefundPayments
[java] 2065 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.advpaymentmngt.buildvalidation.WrongPaymentScheduleDetailsCheck
[java] 2148 [main] INFO org.openbravo.buildvalidation.BuildValidationHandler - Executing build validation: org.openbravo.retail.posterminal.buildvalidation.DuplicatedPosTerminalPaymentType

update.database:
[sql] Executing commands
[sql] 2 of 2 SQL statements executed successfully

update.database.java:
[java] Executing database update process without checking changes in local files.
[java] 0 INFO - Database connection: jdbc:postgresql://localhost:5432/openbravo. [^] User: tad
[java] 1812 INFO - Executing full update.database
[java] 1846 INFO - Reading tables...
[java] 19117 INFO - Reading views...
[java] 19562 INFO - Reading sequences...
[java] 19571 INFO - Reading triggers...
[java] 19632 INFO - Reading functions...
[java] 20867 INFO - Sorting foreign keys, indexes and checks...
[java] 21436 INFO - Starting function and trigger standardization.
[java] 62661 INFO - Checking datatypes from the model loaded from the database
[java] 62663 INFO - Original model loaded from database.
[java] 62734 INFO - Reading model files...
[java] 82063 INFO - Checking datatypes from the model loaded from XML files
[java] 82121 INFO - Loading data from XML files
[java] 92123 INFO - Loading and applying configuration scripts
[java] 92139 INFO - Applying structure part of configuration script: org.openbravo.v3
[java] 92140 INFO - Loading configuration script: /opt/OpenbravoERP/modules/org.openbravo.v3/src-db/database/configScript.xml
[java] 92213 INFO - Applying structure part of configuration script: org.openbravo.retail.pack
[java] 92214 INFO - Loading configuration script: /opt/OpenbravoERP/modules/org.openbravo.retail.pack/src-db/database/configScript.xml
[java] 92233 INFO - Applying structure part of configuration script: mySystem.CustomizationTemplate
[java] 92234 INFO - Loading configuration script: /opt/OpenbravoERP/modules/mySystem.CustomizationTemplate/src-db/database/configScript.xml
[java] Checking if database structure was modified locally.
[java] Checking if data has changed in the application dictionary.
[java] 94049 INFO - Executing default prescript
[java] 94241 INFO - Executed 117 SQL command(s) successfully
[java] 94256 INFO - Updating database model...
[java] 95350 INFO - Executed 58 SQL command(s) successfully
[java] 95381 INFO - Executed 6 forced SQL command(s) with 1 error(s)
[java] 95389 INFO - Executed 1 forced SQL command(s) successfully
[java] 95391 INFO - Model update complete.
[java] 95643 INFO - Disabling foreign keys
[java] 96288 INFO - Executed 400 SQL command(s) successfully
[java] 96299 INFO - Disabling triggers
[java] 96443 INFO - Executed 321 SQL command(s) successfully
[java] 96909 INFO - Executed 834 SQL command(s) successfully
[java] 96976 INFO - Executing moduleScript: org.openbravo.modulescript.HBFix
[java] 97051 INFO - Executing moduleScript: org.openbravo.modulescript.InitializeCostingMigrationPreference
[java] 97208 INFO - Executing moduleScript: org.openbravo.advpaymentmngt.modulescript.InitializeAPRMReadyPreference
[java] 97288 INFO - Executing moduleScript: org.openbravo.module.remittance.modulescript.CreateAccountingConfiguration
[java] 97320 INFO - Executing moduleScript: org.openbravo.module.remittance.modulescript.InvoiceWrongPaymentComplete
[java] 97339 INFO - Executing moduleScript: org.openbravo.module.remittance.modulescript.PopulateBankInstructions
[java] 97351 INFO - Executing moduleScript: org.openbravo.module.remittance.modulescript.UpdateIsPaymentPaidRem
[java] 97365 INFO - Executing moduleScript: org.openbravo.module.remittance.modulescript.UpdateProcessRemittance
[java] 97369 INFO - Executing moduleScript: org.openbravo.retail.posterminal.modulescript.FixDataIssue24147
[java] 97400 INFO - Executing moduleScript: org.openbravo.retail.posterminal.modulescript.FixDataIssue24409
[java] 97402 INFO - Executing moduleScript: org.openbravo.retail.posterminal.modulescript.FixDataIssue25555
[java] 97416 INFO - Executing moduleScript: org.openbravo.retail.posterminal.modulescript.FixDataIssue25963
[java] 97418 INFO - Executing moduleScript: org.openbravo.retail.posterminal.modulescript.FixDataIssue26444
[java] 97451 INFO - Executing moduleScript: org.openbravo.retail.posterminal.modulescript.FixDataIssue27695
[java] 97454 INFO - Executing moduleScript: org.openbravo.retail.posterminal.modulescript.FixDataIssue28722
[java] 97457 INFO - Executing moduleScript: org.openbravo.retail.posterminal.modulescript.FixErrorTableData
[java] 97460 INFO - Executing moduleScript: org.openbravo.retail.posterminal.modulescript.FixWrongPaymentScheduled
[java] 97480 INFO - Executing moduleScript: org.openbravo.retail.posterminal.modulescript.InsertDiscountPreference
[java] 97494 INFO - Executing moduleScript: org.openbravo.retail.posterminal.modulescript.InsertNewFlowDiscountPreference
[java] 97501 INFO - Executing moduleScript: org.openbravo.retail.posterminal.modulescript.ModuleScriptPosterminal
[java] 97518 INFO - Loading and applying configuration scripts
[java] 97525 INFO - Applying data part of configuration script: org.openbravo.v3
[java] 97526 INFO - Loading configuration script: /opt/OpenbravoERP/modules/org.openbravo.v3/src-db/database/configScript.xml
[java] 98963 INFO - Applying data part of configuration script: org.openbravo.retail.pack
[java] 98964 INFO - Loading configuration script: /opt/OpenbravoERP/modules/org.openbravo.retail.pack/src-db/database/configScript.xml
[java] 99082 INFO - Applying data part of configuration script: mySystem.CustomizationTemplate
[java] 99084 INFO - Loading configuration script: /opt/OpenbravoERP/modules/mySystem.CustomizationTemplate/src-db/database/configScript.xml
[java] 99089 INFO - Comparing databases to find differences
[java] 106708 INFO - Updating Application Dictionary data...
[java] 106737 INFO - Removing invalid rows.
[java] 106971 INFO - Executed 88 SQL command(s) successfully
[java] 106981 INFO - Recreating Primary Keys
[java] 107195 INFO - Executing oncreatedefault statements for mandatory columns
[java] 107480 INFO - Executed 73 SQL command(s) successfully
[java] 107482 INFO - Recreating not null constraints
[java] 108171 INFO - Executed 905 SQL command(s) successfully
[java] 108176 INFO - Executing update final script (dropping temporary tables)
[java] 108659 INFO - Executed 57 SQL command(s) successfully
[java] 108695 INFO - Executed 4 forced SQL command(s) successfully
[java] 108696 INFO - Enabling Foreign Keys and Triggers
[java] 109636 INFO - Batch statement failed. Rolling back and retrying all the statements in a non-batched connection.
[java] 110724 WARN - SQL Command failed with: ERROR: insert or update on table "m_offer" violates foreign key constraint "m_offer_offertype"
[java] Detail: Key (m_offer_type_id)=(4776954A80E747C5BAA565AD464759BF) is not present in table "m_offer_type".
[java] 110727 WARN - -- END
[java] ALTER TABLE M_OFFER
[java] ADD CONSTRAINT M_OFFER_OFFERTYPE FOREIGN KEY (M_OFFER_TYPE_ID) REFERENCES M_OFFER_TYPE (M_OFFER_TYPE_ID)
[java] 111257 INFO - Executed 400 SQL command(s) with 1 error(s)
[java] 111402 INFO - Executed 321 SQL command(s) successfully
[java] 111406 INFO - Executing default postscript
[java] 111437 INFO - Executed 13 SQL command(s) successfully
[java] 113044 ERROR - Not all the foreign keys were correctly activated. Please review which ones were not, and fix the missing references, or recover the backup of your sources.
[java] java.lang.Exception: There were serious problems while updating the database. Please review and fix them before continuing with the application rebuild
[java] at org.openbravo.ddlutils.task.AlterDatabaseDataAll.doExecute(AlterDatabaseDataAll.java:243)
[java] at org.openbravo.ddlutils.task.BaseDatabaseTask.execute(BaseDatabaseTask.java:86)
[java] at org.openbravo.ddlutils.task.AlterDatabaseJava.main(AlterDatabaseJava.java:44)
[java] Exception in thread "main" java.lang.Exception: There were serious problems while updating the database. Please review and fix them before continuing with the application rebuild
[java] at org.openbravo.ddlutils.task.AlterDatabaseDataAll.doExecute(AlterDatabaseDataAll.java:262)
[java] at org.openbravo.ddlutils.task.BaseDatabaseTask.execute(BaseDatabaseTask.java:86)
[java] at org.openbravo.ddlutils.task.AlterDatabaseJava.main(AlterDatabaseJava.java:44)
[java] Caused by: java.lang.Exception: There were serious problems while updating the database. Please review and fix them before continuing with the application rebuild
[java] at org.openbravo.ddlutils.task.AlterDatabaseDataAll.doExecute(AlterDatabaseDataAll.java:243)
[java] ... 2 more"
--------------
0-Install "Sell at Cost Discretionary Discount" module and rebuild the context.
1-Login to the ERP as Openbravo and go to "Discounts and Promotions" window.
2-Create a new Discount.
3-Set the discount type as "Sell at cost price".
4-Set "Sell at cost price" as name.
5-Save this record.
6-Using system administrator role, go to "Module Management" window, remove "Sell at Cost Discretionary Discount" module and execute rebuilding.
7-Defect: Rebuild will fail. (Check attached image).
No tags attached.
png BuildingError.png (110,598) 2015-10-23 14:55
https://issues.openbravo.com/file_download.php?file_id=8632&type=bug
png
Issue History
2015-10-23 14:55lorenzofidalgoNew Issue
2015-10-23 14:55lorenzofidalgoAssigned To => platform
2015-10-23 14:55lorenzofidalgoFile Added: BuildingError.png
2015-10-23 14:55lorenzofidalgoWeb browser => Google Chrome
2015-10-23 14:55lorenzofidalgoModules => Core
2015-10-23 14:55lorenzofidalgoTriggers an Emergency Pack => No
2015-10-26 10:07alostaleWeb browserGoogle Chrome => Google Chrome
2015-10-26 10:07alostaleNote Added: 0081297
2015-10-26 10:07alostaleSeveritymajor => minor
2015-10-26 10:07alostaleStatusnew => acknowledged
2015-10-26 10:07alostaleTypedefect => design defect
2022-02-01 08:09alostaleAssigned Toplatform => Triage Platform Base

Notes
(0081297)
alostale   
2015-10-26 10:07   
Demoted to design defect.

In this case it is correct to fail when uninstalling the module, as there are discount rules implementing the discount type defined within the module. As these rules can be in use the cannot be removed (they could be used in orders and/or invoiced) so the module shouldn't be uninstalled in this situation.