콘텐츠로 건너뛰기
Odoo 메뉴
  • 로그인
  • 무료 체험하기
  • 앱
    재무 관리
    • 회계
    • 청구서 관리
    • 비용 관리
    • 스프레드시트 (BI)
    • 문서
    • 전자 서명
    판매
    • CRM
    • 판매
    • POS 스토어
    • POS 레스토랑
    • 구독
    • 렌탈
    웹사이트
    • 웹사이트 빌더
    • 이커머스
    • 블로그
    • 포럼
    • 실시간 채팅
    • 온라인 학습 관리
    공급망
    • 재고 관리
    • 제조 관리
    • 제품 수명주기 관리 (PLM)
    • 매입
    • 유지관리
    • 품질
    인적자원 관리
    • 직원
    • 채용
    • 휴가 관리
    • 인사 평가
    • 인재 추천
    • 차량 관리
    마케팅
    • 소셜 마케팅
    • 이메일 마케팅
    • SMS 마케팅
    • 행사
    • 마케팅 자동화
    • 설문 조사
    서비스
    • 프로젝트
    • 작업 기록
    • 현장 서비스
    • 헬프데스크
    • 일정 관리
    • 일정 예약
    생산성
    • 메일 및 채팅
    • 전자 결재
    • IoT
    • VoIP
    • 지식 센터
    • WhatsApp
    타사 앱 Odoo 스튜디오 Odoo 클라우드 플랫폼
  • 인더스트리
    리테일
    • 서점
    • 의류 매장
    • 가구점
    • 식료품점
    • 철물점
    • 장난감 가게
    식음료 & 숙박업
    • 바 & 펍
    • 레스토랑
    • 패스트푸드
    • 게스트 하우스
    • 음료 유통업체
    • 호텔
    부동산
    • 부동산 중개업체
    • 건축 회사
    • 건설
    • 부동산 관리
    • 가드닝
    • 부동산 소유자 협회
    컨설팅
    • 회계 법인
    • Odoo 파트너
    • 마케팅 대행사
    • 법률 사무소
    • 인재 영입
    • 감사 및 인증
    제조 관리
    • 텍스타일
    • 메탈
    • 가구
    • 푸드
    • 양조장
    • 기업용 선물
    건강 & 피트니스
    • 스포츠 클럽
    • 안경점
    • 피트니스 센터
    • 웰니스 전문가
    • 약국
    • 미용실
    사업
    • 핸디맨
    • IT 하드웨어 및 지원 서비스
    • 태양 에너지 시스템
    • 제화업체
    • 클리닝 서비스
    • HVAC 서비스
    기타
    • 비영리 단체
    • 환경 에이전시
    • 광고판 임대
    • 사진
    • 자전거 임대
    • 소프트웨어 리셀러
    전체 인더스트리 찾아보기
  • 커뮤니티
    학습
    • 튜토리얼
    • 문서
    • 인증
    • 훈련
    • 블로그
    • 팟캐스트
    교육 역량 강화
    • 교육 프로그램
    • Scale-Up! 경영관리 게임
    • Odoo에 방문해보세요
    소프트웨어 신청
    • 다운로드
    • 버전 살펴보기
    • 릴리즈 내역
    협업
    • Github
    • 포럼
    • 행사
    • 번역
    • 파트너 등록
    • 파트너 대상 서비스
    • 회계 법인 정보 등록
    서비스 신청
    • 파트너 검색
    • 회계사 검색
    • 전문 상담 예약
    • 구현 서비스
    • 고객 정보
    • 고객 지원
    • 업그레이드
    Github 유튜브 트위터 링크드인 인스타그램 페이스북 스포티파이
    +1 (650) 691-3277
    데모 예약하기
  • 요금제
  • 고객 지원

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • 회계
  • 재고 관리
  • PoS
  • 프로젝트
  • MRP
All apps
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
모든 게시물 사용자 배지
태그 (모두 보기)
odoo accounting v14 pos v15
게시판 정보
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
모든 게시물 사용자 배지
태그 (모두 보기)
odoo accounting v14 pos v15
게시판 정보
도움말

Sample code for Applying payment to Invoice via XML-RPC (PHP) ?

구독

이 게시물에 활동이 있으면 알림 받기

신고된 질문입니다
paymentapiaccount.invoice
2 답글
19825 화면
아바타
Antoni

I am using PHP to communicate with the XML-RPC API. I have been able to successfully create and validate an invoice but I am running into a problem applying a payment to an invoice.

Does anyone know how this can be done through the API? Or have a code sample I could reference?

Thanks

Here is the code I am using. It doesnt show the actual xml-rpc calls but it shows the fields. This is using a custom handler I wrote.

echo "LOGIN<BR /><BR />";
$conn = new openerp_client($user, $password, $dbname, $server_url);

//search for company in partner model to get id
echo "SEARCH<br /><br />";
$data = array(
    0 => array('field' => 'name', 'operator' => '=', 'value' => 'Antoni\'s Company 2', 'type' => 'string')
);
$conn->search('res.partner', $data);

$partner_id = $conn->response['last_record_id'][0];

//search for company in res.comapny model to get id
echo "SEARCH<br /><br />";
$data = array(
    0 => array('field' => 'name', 'operator' => '=', 'value' => 'Antoni\'s Company 2', 'type' => 'string')
);
$conn->search('res.company', $data);

$company_id = $conn->response['last_record_id'][0];

//create the invoice
echo "INVOICE<BR /><BR />";

$data = array(
    0 => array('field' => 'partner_id', 'value' => $partner_id, 'type' => 'int'),
    1 => array('field' => 'date_invoice', 'value' => date('Y-m-d'), 'type' => 'string'),
    2 => array('field' => 'date_due', 'value' => date('Y-m-d'), 'type' => 'string'),
    3 => array('field' => 'account_id', 'value' => 40, 'type' => 'int'),
    4 => array('field' => 'journal_id', 'value' => 11, 'type' => 'int'),
    6 => array('field' => 'company_id', 'value' => $company_id, 'type' => 'int'),
    7 => array('field' => 'period_id', 'value' => 4, 'type' => 'int')
);

$conn->put('account.invoice', 'create', $data);
$invoice_id = $conn->response['last_record_id'];

//create the invoice lines
echo "CREATE INVOICE LINES<BR /><BR />";
$data = array(
    0 => array('field' => 'invoice_id', 'value' => $invoice_id, 'type' => 'int'),
    1 => array('field' => 'product_id', 'value' => 49, 'type' => 'int'),
    2 => array('field' => 'name', 'value' => '[ADPT] USB Adapter', 'type' => 'string'),
    3 => array('field' => 'price_unit', 'value' => 18.0, 'type' => 'double'),
    4 => array('field' => 'quantity', 'value' => 2.0, 'type' => 'double'),
    5 => array('field' => 'account_id', 'value' => 51, 'type' => 'int')
);

$conn->put('account.invoice.line', 'create', $data);

//validate the invoice
echo "VALIDATE<BR /><BR />";
$conn->workflow('account.invoice', 'invoice_open', $invoice_id);

//get move_id from invoice
echo "SEARCH INVOICE<BR /><BR />";
$data = array(
    0 => array('field' =>'id', 'operator' => '=', 'value' => $invoice_id, 'type' => 'int')
);
$conn->search('account.invoice', $data);

echo "GET INVOICE<BR /><BR />";
$fields = array();
$conn->get('account.invoice', $fields);

echo $move_id = $conn->response['last_record_id'][0]['move_id']->me['array'][0]->me['int'];

//create voucher
echo "Create<br /><br />";

$data = array(
    0 => array('field' => 'partner_id', 'value' => 166, 'type' => 'int'),
    1 => array('field' => 'company_id', 'value' => 1, 'type' => 'int'),
    2 => array('field' => 'type', 'value' => 'receipt', 'type' => 'string'),
    3 => array('field' => 'account_id', 'value' => 57, 'type' => 'int'),
    4 => array('field' => 'period_id', 'value' => 5, 'type' => 'int'),
    5 => array('field' => 'journal_id', 'value' => 17, 'type' => 'int'),
    6 => array('field' => 'amount', 'value' => 12.0, 'type' => 'double'),
    7 => array('field' => 'move_id', 'value' => $move_id, 'type' => 'int'),
    8 => array('field' => 'currency_id', 'value' => 1, 'type' => 'int'),
    9 => array('field' => 'date', 'value' => date('Y-m-d'), 'type' => 'string')
);
$conn->put('account.voucher', 'create', $data);
$voucher_id = $conn->response['last_record_id'];

//get move_line_id
$data = array(
    0 => array('field' => 'move_id', 'operator' => '=', 'value' => $move_id, 'type' => 'int'),
    1 => array('field' => 'name', 'operator' => '=', 'value' => '/', 'type' => 'string')
);
$conn->search('account.move.line', $data);

$fields = array();
$conn->get('account.move.line', $fields);

$move_line_id = $conn->response['last_record_id'][0]['id']->me['int'];

$invoice_name = $conn->response['last_record_id'][0]['invoice']->me['array'][1]->me['string'];

//create voucher line
echo "Create Voucher Line<br /><br />";
$data = array(
    0 => array('field' => 'partner_id', 'value' => 166, 'type' => 'int'),
    1 => array('field' => 'company_id', 'value' => 1, 'type' => 'int'),
    2 => array('field' => 'voucher_id', 'value' => $voucher_id, 'type' => 'int'),
    3 => array('field' => 'amount', 'value' => 12.0, 'type' => 'double'),
    4 => array('field' => 'type', 'value' => 'cr', 'type' => 'string'),
    5 => array('field' => 'name', 'value' => $invoice_name, 'type' => 'string'),
    6 => array('field' => 'account_id', 'value' => 40, 'type' => 'int'),
    7 => array('field' => 'move_line_id', 'value' => $move_line_id, 'type' => 'int')
);

$conn->put('account.voucher.line','create',$data);

//Post voucher
echo "Post Voucher<BR /><BR />";
$conn->workflow('account.voucher', 'proforma_voucher', $voucher_id);
0
아바타
취소
아바타
Francesco OpenCode
베스트 답변

If you want, you can use my script hosted in github: https://github.com/OpenCode/openerp-php-connector

If you read index.php page you can find examples for alla the feature. You must use create to create an invoice and call_function to validate it.

1
아바타
취소
Antoni
작성자

Hi Francesco, Thanks for replying. I have already figured out how to create and invoice and validate one. I am looking to make payments to an invoice and reconcile and invoice. Would you happen to have any code samples on that? Thanks.

Francesco OpenCode

A solution is to study the openerp workflow for the invoice and call the some functions with PHP

Antoni
작성자

I tried that as well. I did the following: created an invoice, added lines to the invoice, validated the invoice. Then created a voucher with the move_id related to the invoice got the move_line_id related to the invoice/lines. But the payment does not show up in the invoice and the voucher cannot be posted. So I am still missing something. I update the question with the code I have already. It uses a class I wrote but will give you an idea of the fields I am using. Thanks for your help.

아바타
Nicholas Linn
베스트 답변

I haven't had a chance to try it but I dug this up earlier and bookmarked it:

http://forum.openerp.com/forum/topic32306.html

Hope it helps.

0
아바타
취소
Jason Judge

This link is now dead. I've put the essence of the link content into this gist: https://gist.github.com/judgej/38d5bcba3c8f5e3f6fa5

토론이 재미있으신가요? 직접 참여해보세요!

지금 바로 가입하여 독점 서비스를 이용해보고 특별한 커뮤니티와 소통하세요!

가입
관련 게시물 답글 화면 활동
Apply payment to invoice via API
payment api account.invoice
아바타
0
3월 15
4581
Odoo API invoice
invoice payment api
아바타
0
11월 24
2119
POS Payment method: Partner debit/credit
pos payment api
아바타
아바타
1
3월 17
12315
Register Payment Amount Changes
payment account.invoice register
아바타
1
3월 15
5796
Vendor bills payments using an bank API
payment api bank vendorbill
아바타
아바타
2
4월 25
1560
커뮤니티
  • 튜토리얼
  • 문서
  • 포럼
오픈 소스
  • 다운로드
  • Github
  • Runbot
  • 번역
서비스
  • Odoo.sh 호스팅
  • 고객 지원
  • 업그레이드
  • 맞춤 개발
  • 학습
  • 회계사 검색
  • 파트너 검색
  • 파트너 등록
회사 소개
  • 회사 소개
  • 브랜드 자산
  • 상담 문의
  • 인재 채용
  • 행사
  • 팟캐스트
  • 블로그
  • 고객 사례
  • 법적고지 • 개인정보
  • 보안
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo는 CRM, 이커머스, 회계, 재고, POS, 프로젝트 관리 등 기업의 모든 요구 사항을 충족하도록 설계된 오픈 소스 기반의 통합 비즈니스 앱 제품군입니다.

Odoo의 간편한 UI와 완벽하게 통합된 기능을 직접 확인해 보세요.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now