purchaseIdHeadPanel1.getControlDocRifLookup().getLookupController().addLookupListener(new LookupListener() {
public void codeValidated(boolean validated) {}
public void codeChanged(ValueObject parentVO,Collection parentChangedAttributes) {
GridPurchaseDocVO vo = (GridPurchaseDocVO)purchaseIdHeadPanel1.getControlDocRifLookup().getLookupController().getLookupVO();
if (vo.getDocNumberDOC06()!=null) {
// pre-set header data...
PurchaseDocPK pk = new PurchaseDocPK(
vo.getCompanyCodeSys01DOC06(),
vo.getDocTypeDOC06(),
vo.getDocYearDOC06(),
vo.getDocNumberDOC06()
);
Response res = ClientUtils.getData("loadPurchaseDoc",pk);
if (!res.isError()) {
DetailPurchaseDocVO purchaseDocVO = (DetailPurchaseDocVO)((VOResponse)res).getVo();
DetailPurchaseDocVO oldPurchaseDocVO = (DetailPurchaseDocVO)headerFormPanel.getVOModel().getValueObject();
purchaseDocVO.setCompanyCodeSys01Doc06DOC06(vo.getCompanyCodeSys01DOC06());
purchaseDocVO.setDocTypeDoc06DOC06(vo.getDocTypeDOC06());
purchaseDocVO.setDocYearDoc06DOC06(vo.getDocYearDOC06());
purchaseDocVO.setDocNumberDoc06DOC06(vo.getDocNumberDOC06());
purchaseDocVO.setDocSequenceDoc06DOC06(vo.getDocSequenceDOC06());
purchaseDocVO.setDocTypeDOC06(ApplicationConsts.PURCHASE_INVOICE_FROM_DN_DOC_TYPE);
purchaseDocVO.setDocNumberDOC06(null);
purchaseDocVO.setDocSequenceDOC06(oldPurchaseDocVO.getDocSequenceDOC06());
purchaseDocVO.setDocStateDOC06(ApplicationConsts.OPENED);
purchaseDocVO.setDocDateDOC06(oldPurchaseDocVO.getDocDateDOC06());