Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0042267Openbravo ERP02. Master data managementpublic2019-11-13 11:312020-01-02 16:28
guillermogil 
inigo_lerga 
normalmajoralways
closedfixed 
5
 
3.0PR20Q1 
aferraz
Core
No
0042267: M_Product has a wrong constraint
m_product_value should be changed by a trigger that checks that the value is not duplicated on the same legal entity.

It will be needed to review also if some index is needed as the unique will be removed.
N/A
No tags attached.
Issue History
2019-11-13 11:31guillermogilNew Issue
2019-11-13 11:31guillermogilAssigned To => Triage Finance
2019-11-13 11:31guillermogilModules => Core
2019-11-13 11:31guillermogilResolution time => 1575586800
2019-11-13 11:31guillermogilTriggers an Emergency Pack => No
2019-11-13 11:33guillermogilDescription Updatedbug_revision_view_page.php?rev_id=19678#r19678
2019-11-13 12:38vmromanosNote Added: 0115573
2019-11-13 12:38vmromanosStatusnew => acknowledged
2019-11-13 12:45vmromanosNote Edited: 0115573bug_revision_view_page.php?bugnote_id=0115573#r19682
2019-11-21 10:57vmromanosNote Added: 0115743
2019-11-21 10:58vmromanosAssigned ToTriage Finance => inigo_lerga
2019-11-21 10:58vmromanosStatusacknowledged => scheduled
2019-11-21 10:58vmromanosTypedefect => feature request
2019-11-27 08:20inigo_lergaNote Added: 0115861
2019-11-28 15:13inigo_lergaNote Added: 0115945
2019-12-17 17:07hgbotCheckin
2019-12-17 17:07hgbotNote Added: 0116382
2019-12-19 12:59hgbotCheckin
2019-12-19 12:59hgbotNote Added: 0116429
2019-12-19 18:27hudsonbotCheckin
2019-12-19 18:27hudsonbotNote Added: 0116440
2019-12-27 12:43hgbotCheckin
2019-12-27 12:43hgbotNote Added: 0116556
2019-12-27 12:43hgbotStatusscheduled => resolved
2019-12-27 12:43hgbotResolutionopen => fixed
2019-12-27 12:43hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/09d12ac7b19abe656c145d7b1806f7ae2b80663e [^]
2019-12-27 12:45aferrazReview Assigned To => aferraz
2019-12-27 12:45aferrazNote Added: 0116557
2019-12-27 12:45aferrazStatusresolved => closed
2019-12-27 12:45aferrazFixed in Version => 3.0PR20Q1
2019-12-27 14:08hgbotCheckin
2019-12-27 14:08hgbotNote Added: 0116560
2019-12-27 14:33hgbotCheckin
2019-12-27 14:33hgbotNote Added: 0116562
2019-12-27 14:56hgbotCheckin
2019-12-27 14:56hgbotNote Added: 0116563
2020-01-02 16:28inigo_lergaNote Added: 0116610

Notes
(0115573)
vmromanos   
2019-11-13 12:38   
(edited on: 2019-11-13 12:45)
Important: this would create an important API change and could have performance implications as the associated index won't be available anymore.

Other master data, like Product Category, Business Partner, etc. should be reviewed as well to implement the same logic.


Do NOT work on this until Dmitry's approval.

(0115743)
vmromanos   
2019-11-21 10:57   
Finally we will implement the following:

1. In Core, to relax current unique constraint [Client, Value] by [Value, Organization], so the same product's search key can be shared between several organizations.
Note adding Client column doesn't add any value thanks to UUIDs.

Important: this will create an API change. Any code that is expecting a unique product's search key per client would start failing after relaxing the unique constraint. The risk of this API change is "medium" because it's very difficult to detect this scenario in the code, and the possible failure would happen in runtime only.

2. Review the unique constraint in other master data entities to follow the same approach.
Candidates: Business Partner, Business Partner Category, Product, Product Category and PriceList.

3. Create a new module, that can be optionally installed, to add an EventObserver to restrict the searchkey duplication within the legal entity tree.
(0115861)
inigo_lerga   
2019-11-27 08:20   
It is needed to add the Client into the unique constraint to avoid the following case:
An Openbravo installation that contains more than one client could not have, for example, one product each with the same search key, even though they would be separate clients inside Openbravo and there is no need for them to be related.

For this reason, the new constraints will be as follows: [Value, Organization, Client]
(0115945)
inigo_lerga   
2019-11-28 15:13   
Test Plan for Product:
As the F&B International Group Admin role:
    - Go to the Product Window.
    - Create a new record inserting "1" as SearchKey,
      "F&B España - Región Sur" as Organization and
      any name you prefer. Save the record.
    - Create another record inserting "1" as SearchKey,
      "F&B España - Región Norte" as Organization and
      any name you prefer. Save the record.
      #Apreciate that an error message is thrown as the
      two Organizations used have the same Legal Entity
      above them#
    - Change the SearchKey to a different value such as "2".
      #Apreciate that this time no error is shown and
      the record has been succesfully saved#
    - Modify the SearchKey of this same record to "1" again
      and save the record.
      #Apreciate that the same error as before is shown when
      modifying a record with the same SearchKey as another
      pre-existing one#

Test Plan for Product Category:
As the F&B International Group Admin role:
    - Go to the Product Category Window.
    - Create a new record inserting "1" as SearchKey,
      "F&B España - Región Sur" as Organization and
      any name you prefer. Save the record.
    - Create another record inserting "1" as SearchKey,
      "F&B España - Región Norte" as Organization and
      any name you prefer. Save the record.
      #Apreciate that an error message is thrown as the
      two Organizations used have the same Legal Entity
      above them#
    - Change the SearchKey to a different value such as "2".
      #Apreciate that this time no error is shown and
      the record has been succesfully saved#
    - Modify the SearchKey of this same record to "1" again
      and save the record.
      #Apreciate that the same error as before is shown when
      modifying a record with the same SearchKey as another
      pre-existing one#

Test Plan for Business Partner:
As the F&B International Group Admin role:
    - Go to the Business Partner Window.
    - Create a new record inserting "1" as SearchKey,
      "F&B España - Región Sur" as Organization and
      any commercial name and business partner category
      you prefer. Save the record.
    - Create another record inserting "1" as SearchKey,
      "F&B España - Región Norte" as Organization and
      any commercial name and business partner category
      you prefer. Save the record.
      #Apreciate that an error message is thrown as the
      two Organizations used have the same Legal Entity
      above them#
    - Change the SearchKey to a different value such as "2".
      #Apreciate that this time no error is shown and
      the record has been succesfully saved#
    - Modify the SearchKey of this same record to "1" again
      and save the record.
      #Apreciate that the same error as before is shown when
      modifying a record with the same SearchKey as another
      pre-existing one#

Test Plan for Business Partner Category:
As the F&B International Group Admin role:
    - Go to the Business Partner Category Window.
    - Create a new record inserting "1" as SearchKey,
      "F&B España - Región Sur" as Organization and
      any name you prefer. Save the record.
    - Create another record inserting "1" as SearchKey,
      "F&B España - Región Norte" as Organization and
      any name you prefer. Save the record.
      #Apreciate that an error message is thrown as the
      two Organizations used have the same Legal Entity
      above them#
    - Change the SearchKey to a different value such as "2".
      #Apreciate that this time no error is shown and
      the record has been succesfully saved#
    - Modify the SearchKey of this same record to "1" again
      and save the record.
      #Apreciate that the same error as before is shown when
      modifying a record with the same SearchKey as another
      pre-existing one#

Test Plan for Price List:
As the F&B International Group Admin role:
    - Go to the Price List Window.
    - Create a new record inserting "1" as Name,
      "F&B España - Región Sur" as Organization and
      any currency you prefer. Save the record.
    - Create another record inserting "1" as Name,
      "F&B España - Región Norte" as Organization and
      any currency you prefer. Save the record.
      #Apreciate that an error message is thrown as the
      two Organizations used have the same Legal Entity
      above them#
    - Change the Name to a different value such as "2".
      #Apreciate that this time no error is shown and
      the record has been succesfully saved#
    - Modify the Name of this same record to "1" again
      and save the record.
      #Apreciate that the same error as before is shown when
      modifying a record with the same Name as another
      pre-existing one#
(0116382)
hgbot   
2019-12-17 17:07   
Repository: erp/mods/org.openbravo.masterdata.uniqueconstraintbylegalentity
Changeset: 27f0978b9edfb33f0beb507054ab41e06bb2b1e5
Author: Iñigo Lerga <inigo.lerga <at> openbravo.com>
Date: Tue Dec 17 17:03:49 2019 +0100
URL: http://code.openbravo.com/erp/mods/org.openbravo.masterdata.uniqueconstraintbylegalentity/rev/27f0978b9edfb33f0beb507054ab41e06bb2b1e5 [^]

Related to Issue 42267: Relax constraints and EventHandler added

Relax current unique constraints in Search Keys (or name
in PriceLists) for Business Partner, Business Partner
Category, Product, Product Category and PriceList.
Also an EventHandler is added to restrict search keys
(or name in PriceLists) inside the same Legal Entity or
branch in the hierarchy.
Automated Tests for the EventHandler are provided too.

---

---
(0116429)
hgbot   
2019-12-19 12:59   
Repository: erp/devel/pi
Changeset: 43fc4c5ce2502f094ab843198c486908c2623b97
Author: David Miguelez <david.miguelez <at> openbravo.com>
Date: Thu Dec 19 12:59:07 2019 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/43fc4c5ce2502f094ab843198c486908c2623b97 [^]

Related to Issue 42267: Relaxation of Unique constraint

Relax current unique constraint in Search Keys for Product

---
M src-db/database/model/tables/M_PRODUCT.xml
---
(0116440)
hudsonbot   
2019-12-19 18:27   
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/49eee5eb07a1 [^]
Maturity status: Test
(0116556)
hgbot   
2019-12-27 12:43   
Repository: erp/devel/pi
Changeset: 09d12ac7b19abe656c145d7b1806f7ae2b80663e
Author: Iñigo Lerga <inigo.lerga <at> openbravo.com>
Date: Tue Nov 26 16:41:01 2019 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/09d12ac7b19abe656c145d7b1806f7ae2b80663e [^]

Fixes BUG-42267: Relaxation of Unique constraints

Relax current unique constraints in Search Keys for
Business Partner, Business Partner Category,
Product Category and PriceList.

---
M src-db/database/model/tables/C_BPARTNER.xml
M src-db/database/model/tables/C_BP_GROUP.xml
M src-db/database/model/tables/M_PRICELIST.xml
M src-db/database/model/tables/M_PRODUCT_CATEGORY.xml
---
(0116557)
aferraz   
2019-12-27 12:45   
Code review OK
(0116560)
hgbot   
2019-12-27 14:08   
Repository: erp/mods/org.openbravo.masterdata.uniqueconstraintbylegalentity
Changeset: 9775fefd4409f8e835b8cdac168f3fd2025ff487
Author: Iñigo Lerga <inigo.lerga <at> openbravo.com>
Date: Fri Dec 27 14:03:23 2019 +0100
URL: http://code.openbravo.com/erp/mods/org.openbravo.masterdata.uniqueconstraintbylegalentity/rev/9775fefd4409f8e835b8cdac168f3fd2025ff487 [^]

Related to Issue 42267: Code Review improvements applied

---
M src-db/database/sourcedata/AD_MESSAGE.xml
M src-db/database/sourcedata/AD_MODULE.xml
M src-test/org/openbravo/masterdata/uniqueconstraintbylegalentity/test/UCEventObserverTest.java
M src-test/org/openbravo/masterdata/uniqueconstraintbylegalentity/test/UCEventObserverTestData.java
M src/org/openbravo/masterdata/uniqueconstraintbylegalentity/event/UC_EventObserver.java
---
(0116562)
hgbot   
2019-12-27 14:33   
Repository: erp/mods/org.openbravo.masterdata.uniqueconstraintbylegalentity
Changeset: 8427b801918109a940cd254cfda22dca9dc931e0
Author: Iñigo Lerga <inigo.lerga <at> openbravo.com>
Date: Fri Dec 27 14:33:02 2019 +0100
URL: http://code.openbravo.com/erp/mods/org.openbravo.masterdata.uniqueconstraintbylegalentity/rev/8427b801918109a940cd254cfda22dca9dc931e0 [^]

Related to Issue 42267: User Interface Application dependency erased.

---
M src-db/database/sourcedata/AD_MODULE_DEPENDENCY.xml
---
(0116563)
hgbot   
2019-12-27 14:56   
Repository: erp/mods/org.openbravo.masterdata.uniqueconstraintbylegalentity
Changeset: 3207713b59d7af81e57a673dcb5ba06ace30c698
Author: Iñigo Lerga <inigo.lerga <at> openbravo.com>
Date: Fri Dec 27 14:56:08 2019 +0100
URL: http://code.openbravo.com/erp/mods/org.openbravo.masterdata.uniqueconstraintbylegalentity/rev/3207713b59d7af81e57a673dcb5ba06ace30c698 [^]

Related to Issue 42267: Renamed files and TestSuite added

---
A src-test/org/openbravo/masterdata/uniqueconstraintbylegalentity/test/OBMUCLEEventObserverTest.java
A src-test/org/openbravo/masterdata/uniqueconstraintbylegalentity/test/OBMUCLEEventObserverTestData.java
A src-test/org/openbravo/masterdata/uniqueconstraintbylegalentity/test/OBMUCLEEventObserverTestSuite.java
A src/org/openbravo/masterdata/uniqueconstraintbylegalentity/event/OBMUCLEEventObserver.java
R src-test/org/openbravo/masterdata/uniqueconstraintbylegalentity/test/UCEventObserverTest.java
R src-test/org/openbravo/masterdata/uniqueconstraintbylegalentity/test/UCEventObserverTestData.java
R src/org/openbravo/masterdata/uniqueconstraintbylegalentity/event/UC_EventObserver.java
---
(0116610)
inigo_lerga   
2020-01-02 16:28   
Documentation can be found in:
http://wiki.openbravo.com/wiki/Modules:Unique_Constraint_By_Legal_Entity#Introduction [^]