client/skr/models/SalesOrder.coffee in stockor-0.3.0 vs client/skr/models/SalesOrder.coffee in stockor-0.4.0
- old
+ new
@@ -53,21 +53,25 @@
invoices: { collection: "Invoice", inverse: 'sales_order' }
lines: { collection: "SoLine", inverse: 'sales_order', fk: 'sales_order_id', }
pick_tickets: { collection: "PickTicket", inverse: 'sales_order' }
events:
- 'change:customer': 'onCustomerChange'
'lines add remove change:total': 'onTotalChange'
+ 'change:customer': 'onCustomerChange'
onTotalChange: ->
@trigger('change', @, {})
@unCacheDerived('total')
@unset('order_total')
onCustomerChange: ->
- return unless @isNew()
+ return if @customer.isProxy or not @isNew()
+
associations = ['billing_address', 'shipping_address']
for attr in ['terms_id']
@set(attr, @customer[attr])
+
@customer.withAssociations(associations).then =>
for name in associations
- @associations.replace(@, name, @customer[name])
+ @[name].set(
+ _.omit( @customer[name].serialize(), 'id' )
+ )