saleIdHeadPanel1.getControlDocRifLookup().getLookupController().addLookupListener(new LookupListener() {
public void codeValidated(boolean validated) {}
public void codeChanged(ValueObject parentVO,Collection parentChangedAttributes) {
GridSaleDocVO vo = (GridSaleDocVO)saleIdHeadPanel1.getControlDocRifLookup().getLookupController().getLookupVO();
if (vo.getDocNumberDOC01()!=null) {
// pre-set header data...
Response res = ClientUtils.getData("loadSaleDoc",new SaleDocPK(
vo.getCompanyCodeSys01DOC01(),
vo.getDocTypeDOC01(),
vo.getDocYearDOC01(),
vo.getDocNumberDOC01()
));
if (!res.isError()) {
DetailSaleDocVO saleDocVO = (DetailSaleDocVO)((VOResponse)res).getVo();
DetailSaleDocVO oldSaleDocVO = (DetailSaleDocVO)headerFormPanel.getVOModel().getValueObject();
saleDocVO.setCompanyCodeSys01Doc01DOC01(vo.getCompanyCodeSys01DOC01());
saleDocVO.setDocTypeDoc01DOC01(vo.getDocTypeDOC01());
saleDocVO.setDocYearDoc01DOC01(vo.getDocYearDOC01());
saleDocVO.setDocNumberDoc01DOC01(vo.getDocNumberDOC01());
saleDocVO.setDocSequenceDoc01DOC01(vo.getDocSequenceDOC01());
saleDocVO.setDocTypeDOC01(ApplicationConsts.SALE_INVOICE_FROM_SD_DOC_TYPE);
saleDocVO.setDocNumberDOC01(null);
saleDocVO.setDocSequenceDOC01(null);
saleDocVO.setDocStateDOC01(ApplicationConsts.OPENED);
saleDocVO.setDocDateDOC01(oldSaleDocVO.getDocDateDOC01());