# HG changeset patch
# User Rafa Alonso <ral@openbravo.com>
# Date 1438683047 -7200
#      Tue Aug 04 12:10:47 2015 +0200
# Node ID 71af5c2bd0119390d1c5a6007f5f90a792ee1e16
# Parent  ecbbe2ac59b98a094810c98a735580932449909e
Related to issue 30472: Added log entries when the 'creationDate' is updated

diff -r ecbbe2ac59b9 -r 71af5c2bd011 web/org.openbravo.retail.posterminal/js/model/order.js
--- a/web/org.openbravo.retail.posterminal/js/model/order.js	Fri Jul 17 14:55:29 2015 +0200
+++ b/web/org.openbravo.retail.posterminal/js/model/order.js	Tue Aug 04 12:10:47 2015 +0200
@@ -244,6 +244,17 @@
     local: true,
     _id: 'modelorder',
     initialize: function (attributes) {
+      // check if the creationDate is set to an incorrect value and get the stacktrace information
+      this.on('change:creationDate', function () {
+        var newDate = this.get('creationDate');
+        var message = "'creationDate' changed to " + newDate + (!newDate ? "" : ". getTimezoneOffset: '" + !!newDate.getTimezoneOffset) + "'. Stack: " + OB.UTIL.getStackTrace('_.extend.set', false);
+        if (newDate && !newDate.getTimezoneOffset) {
+          OB.error(message);
+        } else {
+          OB.info(message);
+        }
+      }, this);
+
       var orderId;
       if (attributes && attributes.id && attributes.json) {
         // The attributes of the order are stored in attributes.json
