Fixes issue 26820: Additional properties should not be used as primary keys.
authorAugusto Mauch <augusto.mauch@openbravo.com>
Tue, 10 Jun 2014 15:19:07 +0200
changeset 23470 5e171f9e8353
parent 23457 a5801fd5781a
child 23471 7dd486c17ed6
Fixes issue 26820: Additional properties should not be used as primary keys.

When setting the primary keys of a datasource, its additional properties should not be taken into account. Only those that belong to the main entity should be considered.

For instance, consider the following case. The SalesInvoiceLine entity has a product property, which uses a selector reference. The field used as the Display Field of the selector will be added to the additional properties of SalesInvoiceLine. If the product.id property were used as Display Field, then it would be added to the additional properties, but should not be considered a primary key for SalesInvoiceLine even though that property is a primary key in its referenced entity.
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/templates/datasource.ftl
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/templates/datasource.ftl	Tue Jun 10 10:46:21 2014 +0200
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/templates/datasource.ftl	Tue Jun 10 15:19:07 2014 +0200
@@ -70,7 +70,7 @@
     <#if property.additional>
     , additional: ${property.additional?string}
     </#if>
-<#if property.id>
+<#if property.id && !property.additional>
     ,primaryKey: true
 </#if>
 <#--