         shipping_address: { model: "Address" }
         sales_order:      { model: "SalesOrder",  readOnly:true }
         customer:         { model: "Customer",    readOnly:true }
-        location:         { model: "Location",    readOnly:true }
+        location:         { model: "Location",    readOnly:true, default: ->
+            Skr.Models.Location.fetchById(@location_id) if @location_id
+        }
         terms:            { model: "PaymentTerm", readOnly:true }
         pick_ticket:      { model: "PickTicket",  readOnly:true }
         lines:            { collection: "InvLine", inverse: 'invoice'  }


    derived:
        total: deps: ['invoice_total'], fn: ->
            @order_total or @lines.reduce( (t, l) ->
                t.plus(l.total)
            , _.bigDecimal(0))


        id:                 {type:"integer", required:true}
        visible_id:         {type:"integer", required:true}
        terms_id:           {type:"integer", required:true}
        customer_id:        {type:"integer", required:true, default: ->
            Skr.Models.Location.default()?.id
        }
        location_id:        {type:"integer", required:true}
        sales_order_id:     "integer"
        pick_ticket_id:     "integer"
