DataObjects/Location.php
authorAlan Knowles <alan@roojs.com>
Wed, 25 Feb 2015 06:20:51 +0000 (14:20 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 25 Feb 2015 06:20:51 +0000 (14:20 +0800)
DataObjects/Location.php

index a102b52..fd4a40d 100644 (file)
@@ -287,7 +287,28 @@ class Pman_Xtuple_DataObjects_Location extends DB_DataObject
             'location_netable' => 1,
         );
     }
-    
+    function initDatabase($roo)
+    {
+       
+         if ($this->count()) {
+            echo "location exists - SKIP\n";
+            return;
+        }
+        $cust = DB_DataObject::Factory('custinfo');
+        $cc = $cust->count() ;
+        if ($cc != 1) {
+            echo "location create - needs 1 custinfo - got $cc\n";
+            return;
+        }
+        $cust->find(true);
+        
+        $this->setFrom(array(
+            'location_name' => 'Warehouse',
+            'location_descrip' => 'Warehouse',
+            'location_cust_id' => $cust->pid()
+        ));
+        $this->insert();
+    }
     
     function beforeInsert($q,$roo)
     {