         id:                 {type:"integer", required:true}
         visible_id:         {type:"integer", required:true}
         terms_id:           {type:"integer", required:true}
-        customer_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"


    constructor: ->
        super
        @lines.on('change:total', ->
            @trigger('change', @, {})
            @unCacheDerived('total')
            @unset('order_total')
        , this)

    setCustomer: (cust) ->
        this.set(customer: cust)
        @copyAssociationsFrom( @customer, 'billing_address', 'shipping_address')

    setFromSalesOrder: (so) ->
        @sales_order_id = so.id

        shipping_address: { model: "Address" }
        sales_order:      { model: "SalesOrder",  readOnly:true }
        customer:         { model: "Customer",    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'  }
