[ofbiz-framework] branch ofbiz-12246 created (now 2afba3e)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch ofbiz-12246 created (now 2afba3e)

danwatford
This is an automated email from the ASF dual-hosted git repository.

danwatford pushed a change to branch ofbiz-12246
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git.


      at 2afba3e  Fixed: Default From Date for Product Config Item Content truncated to seconds rather than milliseconds.

This branch includes the following new commits:

     new 2afba3e  Fixed: Default From Date for Product Config Item Content truncated to seconds rather than milliseconds.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.

Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] 01/01: Fixed: Default From Date for Product Config Item Content truncated to seconds rather than milliseconds.

danwatford
This is an automated email from the ASF dual-hosted git repository.

danwatford pushed a commit to branch ofbiz-12246
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 2afba3ed154b91b43415c0243a3dca1790795a91
Author: Daniel Watford <[hidden email]>
AuthorDate: Fri May 28 09:41:24 2021 +0100

    Fixed: Default From Date for Product Config Item Content truncated to seconds
    rather than milliseconds.
   
    (OFBIZ-12246)
   
    There was a mismatch in timestamp resolution. Updates to Product Config
    Item Contents rely on second resolution timestamps for finding records
    to update. By default, millisecond resolution timestamps were created
    for config item contents' From Date which caused records to not be found
    during update operations.
   
    Also made From Date a display-only field when editing a config item
    content since it is a primary key and cannot be modified.
---
 .../product/config/ProductConfigItemContentServices.groovy         | 7 +++++--
 applications/product/widget/catalog/ConfigForms.xml                | 5 +++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/applications/product/groovyScripts/product/config/ProductConfigItemContentServices.groovy b/applications/product/groovyScripts/product/config/ProductConfigItemContentServices.groovy
index be7f42d..0f446b7 100644
--- a/applications/product/groovyScripts/product/config/ProductConfigItemContentServices.groovy
+++ b/applications/product/groovyScripts/product/config/ProductConfigItemContentServices.groovy
@@ -30,7 +30,7 @@ def createProductConfigItemContent() {
     Map result = success()
     GenericValue newEntity = makeValue("ProdConfItemContent", parameters)
     if (!newEntity.fromDate) {
-        newEntity.fromDate = UtilDateTime.nowTimestamp()
+        newEntity.fromDate = UtilDateTime.getTimestamp(System.currentTimeSeconds() * 1000)
     }
     newEntity.create()
 
@@ -47,7 +47,10 @@ def createProductConfigItemContent() {
  * Update Content For ProductConfigItem
  */
 def updateProductConfigItemContent() {
-    GenericValue lookedUpValue = from("ProdConfItemContent").where(parameters).queryOne()
+    GenericValue pkParameters = makeValue("ProdConfItemContent")
+    pkParameters.setPKFields(parameters)
+
+    GenericValue lookedUpValue = from("ProdConfItemContent").where(pkParameters).queryOne()
     lookedUpValue.setNonPKFields(parameters)
     lookedUpValue.store()
 
diff --git a/applications/product/widget/catalog/ConfigForms.xml b/applications/product/widget/catalog/ConfigForms.xml
index 9c618c5..291b1c8 100644
--- a/applications/product/widget/catalog/ConfigForms.xml
+++ b/applications/product/widget/catalog/ConfigForms.xml
@@ -177,8 +177,9 @@ under the License.
         header-row-style="header-row" default-table-style="basic-table">
         <alt-target use-when="contentId==null" target="createSimpleTextContentForProductConfigItem"/>
         <auto-fields-entity entity-name="ProdConfItemContent" map-name="productContentData"/>
-        <field name="fromDate" title="${uiLabelMap.CommonFromDate}" ></field>
-        <field name="thruDate" title="${uiLabelMap.CommonThruDate}"></field>
+        <field use-when="contentId == null" name="fromDate" title="${uiLabelMap.CommonFromDate}"><date-time/></field>
+        <field use-when="contentId != null" name="fromDate" title="${uiLabelMap.CommonFromDate}"><display/></field>
+        <field name="thruDate" title="${uiLabelMap.CommonThruDate}"><date-time/></field>
         <field name="description" title="${uiLabelMap.ProductProductDescription}" map-name="content"><text size="40"/></field>
         <field name="localeString" title="${uiLabelMap.ProductLocaleString}" map-name="content"><text size="40"/></field>
         <field use-when="contentId == null" name="contentId"><ignored/></field>