diff --git a/tine20/Sales/js/AddressSearchCombo.js b/tine20/Sales/js/AddressSearchCombo.js index a6bf232ed4..fe16041e04 100644 --- a/tine20/Sales/js/AddressSearchCombo.js +++ b/tine20/Sales/js/AddressSearchCombo.js @@ -74,7 +74,8 @@ Tine.Sales.AddressSearchCombo = Ext.extend(Tine.Tinebase.widgets.form.RecordPick const customer = customerField?.selectedRecord; const customer_id = customer?.json?.original_id || customer?.id; - const category = editDialog.getForm().findField('document_category').selectedRecord; + const category = editDialog.getForm().findField('document_category')?.selectedRecord; + const isLegacy = !!editDialog.getForm().findField('contract'); const division = category?.data?.division_id; this.setDisabled(!customer_id); @@ -89,7 +90,7 @@ Tine.Sales.AddressSearchCombo = Ext.extend(Tine.Tinebase.widgets.form.RecordPick // is this case used somewhere??? typeRecord = customer.data?.postal; } else { - const debitors = _.filter(customer.data.debitors, (deb) => { return _.get(deb, 'division_id.id', deb) === division?.id}); + const debitors = _.filter(customer.data.debitors, (deb) => { return isLegacy || _.get(deb, 'division_id.id', deb) === division?.id}); const typeRecords = _.flatten(_.each(_.map(debitors, type), (addrs, idx) => { // have postal addr in each debitor addrs = addrs.concat(customer?.data?.postal ? customer.data.postal : []); diff --git a/tine20/Sales/js/InvoiceEditDialog.js b/tine20/Sales/js/InvoiceEditDialog.js index de7db3282a..935a48f821 100644 --- a/tine20/Sales/js/InvoiceEditDialog.js +++ b/tine20/Sales/js/InvoiceEditDialog.js @@ -281,7 +281,7 @@ Tine.Sales.InvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { * @param {Tine.Sales.Model.Contract} * record */ - onAfterContractLoad: function(record, customer) { + onAfterContractLoad: async function(record, customer) { var record = record ? record : this.record; var relations = record.get('relations'), foundCostCenter = false; var foundCustomer = customer ? customer : null; @@ -306,6 +306,7 @@ Tine.Sales.InvoiceEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, { } if (foundCustomer) { + foundCustomer = await Tine.Sales.getCustomer(foundCustomer.id); this.customerPicker.setValue(foundCustomer); this.customerPicker.combo.fireEvent('select');