0011932: show address and customer data for manual invoices
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 13 Jun 2016 10:39:08 +0000 (12:39 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 13 Jun 2016 14:32:36 +0000 (16:32 +0200)
* fixes company name and address data display

https://forge.tine20.org/view.php?id=11932

Change-Id: I89301971a531d8adf7020651744fccab03a588e7
Reviewed-on: http://gerrit.tine20.com/customers/3227
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Sales/js/InvoiceEditDialog.js

index 78c05ea..8c46407 100644 (file)
@@ -182,6 +182,14 @@ Tine.Sales.InvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
             }
             if (billingAddress) {
                 var companyName = this.record.get('customer') ? this.record.get('customer').name : null;
+                if (! companyName && this.record.get('customer_id') && this.record.get('customer_id').name) {
+                    companyName = this.record.get('customer_id').name;
+                }
+                if (! companyName && billingAddress.get('customer')) {
+                    companyName = billingAddress.get('customer') && billingAddress.get('customer').name
+                        ? billingAddress.get('customer').name
+                        : null;
+                }
                 this.form.findField('fixed_address').setValue(Tine.Sales.renderAddress(billingAddress, companyName));
             }
         }
@@ -246,7 +254,13 @@ Tine.Sales.InvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
                 this.addressPicker.enable();
                 
                 if (record.get('billing_address_id')) {
-                    this.addressPicker.setValue(record.get('billing_address_id'));
+                    var billingAddress = record.get('billing_address_id');
+                    if (! billingAddress.data) {
+                        billingAddress = new Tine.Sales.Model.Address(billingAddress);
+                    }
+                    billingAddress.set('customer', foundCustomer);
+                    this.addressPicker.setValue(billingAddress);
+                    this.onAddressLoad(this.addressPicker, billingAddress);
                 }
             } else {
                 this.addressPicker.reset();