Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

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

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

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

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
paymentapiaccount.invoice
2 Respuestas
19819 Vistas
Avatar
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
Avatar
Descartar
Avatar
Francesco OpenCode
Mejor respuesta

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
Avatar
Descartar
Antoni
Autor

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
Autor

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.

Avatar
Nicholas Linn
Mejor respuesta

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
Avatar
Descartar
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

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Apply payment to invoice via API
payment api account.invoice
Avatar
0
mar 15
4579
Odoo API invoice
invoice payment api
Avatar
0
nov 24
2116
POS Payment method: Partner debit/credit
pos payment api
Avatar
Avatar
1
mar 17
12314
Register Payment Amount Changes
payment account.invoice register
Avatar
1
mar 15
5796
Vendor bills payments using an bank API
payment api bank vendorbill
Avatar
Avatar
2
abr 25
1557
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة 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 es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

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