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

How to apply payment to Invoice via XML-RPC?

Suscribirse

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

Se marcó esta pregunta
workflowinvoicesvoucher
10 Respuestas
23770 Vistas
Avatar
Carlos Castillo

I'm trying to import invoices from our website into OpenERP via XML-RPC and PHP.

I managed to create an invoice an validate it. The problem comes when applying payment to the invoice: I'm not sure what's the proper way to "pay" that invoice.

The steps I've followed till now are:

  1. Create invoice
  2. Create invoice lines
  3. Open Invoice
  4. Create Voucher related to Invoice's move_id
  5. Create Voucher line

The entries are correctly created, however the payment stays in 'draft' state and never shows up at the invoice.

I've seen that the next step in the account.invoice workflow is "Paid", but I can't make it work. The requirement for this transition is "test_paid()" and the trigger model is account.move.line, but I don't know exactly how to trigger this action.

I've also tried with account.voucher workflow, but "proforma_voucher" action has no effect on the draft voucher

Any ideas about what can be wrong? Am I missing something?

Thanks

2
Avatar
Descartar
Avatar
Aron Lorincz
Mejor respuesta

To add a hopefully "it just works" solution:

if not invoice.state == "open":
return
payable_amount = ... # The amount you want to pay
voucher = self.env["account.voucher"].create({
"name": "",
"amount": payable_amount,
"journal_id": self.env["account.journal"].search([("type", "=", "bank")], limit=1).id,
"account_id": invoice.partner_id.property_account_receivable.id,
"period_id": self.env["account.voucher"]._get_period(),
"partner_id": invoice.partner_id.id,
"type": "receipt"
})
voucher_line = self.env["account.voucher.line"].create({
"name": "",
"payment_option": "without_writeoff",
"amount": payable_amount,
"voucher_id": voucher.id,
"partner_id": invoice.partner_id.id,
"account_id": invoice.partner_id.property_account_receivable.id,
"type": "cr",
"move_line_id": invoice.move_id.line_id[0].id,
})
voucher.signal_workflow("proforma_voucher")
2
Avatar
Descartar
Avatar
Carlos Castillo
Autor Mejor respuesta

Thank you Boniface, that's the solution.

I figured it out yesterday at the end, the problem i had was that the account used in voucher didn't match with the default account of the Journal.

So, at the end, the workflow i used works like this (just insert and pay one invoice, if you want to pay all the partner's open invoices can be done the way Boniface said):

  1. Create invoice
  2. Create invoice lines
  3. Open Invoice (account.invoice workflow, action: invoice_open)
  4. Opening invoice will create an account.move related with the invoice
  5. Create Voucher specifying amount of the payment (matching invoice's amount), journal, account and period
  6. Create Voucher line with "move_line_id" matching Invoice's account.move.line Id
  7. Post payment (via account.voucher workflow, action: proforma_voucher)

In my case, this worked perfectly.

Hope this will help

2
Avatar
Descartar
Vlad Janicek

I have tried for days this and had no success in registering the payment. i opened this threat http://help.openerp.com/question/44048/register-payment-using-xmlrpc/

Avatar
Ferdinand Gassauer
Mejor respuesta

I suggest to create a python function (module) which is called via XMLRPC  - XMLRPC is much to slow

create and open invoice
create and post payment move
reconcile
        for inv in invoice_ids: 
            invoice_id = inv.id
            wf_service.trg_validate(uid, 'account.invoice', invoice_id, 'invoice_open', cr)
            for inv_open in invoice_obj.browse(cr, uid, [invoice_id] , context):
                invoices.append(inv_open.number)
                # payment
                journal_id = journal_obj.search(cr, uid, [('code','=', order_vals['pay_method'])])[0]
                journal = journal_obj.browse(cr, uid, [journal_id], context)[0]
                move_val = {
                    'partner_id' : inv_open.partner_id.id,
                    'date'       : inv_open.date_invoice,
                    'period_id'  : inv_open.period_id.id,
                    'journal_id' : journal_id,
                    'ref' : order_vals['pay_ref']
                }
                move_id =  move_obj.create(cr, uid, move_val, context)
                line_val = {
                    'account_id' : inv_open.account_id.id,
                    'credit'     : inv_open.residual,
                    'move_id'    : move_id,
                    'name'       : order_vals['pay_ref']
                }  
                line_val.update(move_val)
                line_id = move_line_obj.create(cr, uid, line_val, context)
                reconcile_lines = [line_id]
                line_val = {
                    'account_id' : journal.default_debit_account_id.id,
                    'debit'      : inv_open.residual,
                    'move_id'    : move_id,
                    'name'       : order_vals['pay_ref']
                }  
                line_val.update(move_val)
                line_id = move_line_obj.create(cr, uid, line_val, context)
                move_obj.button_validate(cr, uid, [move_id], context=context)

                inv_move_line_id = move_line_obj.search(cr, uid, [('move_id','=',inv_open.move_id.id), ('account_id','=', inv_open.account_id.id) ])[0]
                reconcile_lines.append(inv_move_line_id)
                move_line_obj.reconcile(cr, uid, reconcile_lines)

                invoice_obj.invoice_print(cr, uid, [inv_open.id], 'account.invoice', context)

1
Avatar
Descartar
Bino

This worked for me, Thanks.. Just need to change 3 things i have changed below for invoice_id in invoice_ids: # invoice_id = inv.id wf_service.trg_validate(uid, 'account.invoice', invoice_id, 'invoice_open', cr) for inv_open in invoice_obj.browse(cr, uid, [invoice_id] , context): #invoices.append(inv_open.number) # payment journal_id = journal_obj.search(cr, uid, [('code','=', order_vals['pay_method'])])[0]

Avatar
Jaakko Komulainen
Mejor respuesta

You need to reconcile the invoice from the voucher view. If the voucher has same partner as open invoice, it should offer you to reconcile the payment amount from that partners open invoice(s). After fully reconciled, the invoice moves to paid state and a journal entry is generated.

Hope this helps.

0
Avatar
Descartar
Carlos Castillo
Autor

Thanks for the answer. The problem is that i need to do everything via XML-RPC, How could I reconcile the invoice that way?

Jaakko Komulainen

I haven't looked into automatic reconciliation myself, but I guess you could try to use the openerp's reconcile tool at accounting/periodic processing/reconciliation/automatic reconciliation via XML-RPC.

Boniface Irungu

I figured out how to solve this. I had a client request to integrate openerp with another php based payment platform. Please check this answer http://stackoverflow.com/questions/16238044/openerp-7-api-invoice-validation-and-payment/20471961#20471961

hope this helps you.

Avatar
Alkivi SAS
Mejor respuesta

Hi guys,

I've been facing the same issue here, and here is the code that is currently working for us. Any feedback are appreciated :) Transaction object is a custom one, but contains the journal_id related to the bank account and an amount.

    invoice = self.browse(cr, uid, ids[0], context=context)
    move = invoice.move_id

    # First part, create voucher
    account = transaction.journal_id.default_credit_account_id or transaction.journal_id.default_debit_account_id
    period_id = self.pool.get('account.voucher')._get_period(cr, uid)
    partner_id = self.pool.get('res.partner')._find_accounting_partner(invoice.partner_id).id,

    voucher_data = {
        'partner_id': partner_id,
        'amount': abs(transaction.amount),
        'journal_id': transaction.journal_id.id,
        'period_id': period_id,
        'account_id': account.id,
        'type': invoice.type in ('out_invoice','out_refund') and 'receipt' or 'payment',
        'reference' : invoice.name,
    }

    _logger.debug('voucher_data')
    _logger.debug(voucher_data)

    voucher_id = self.pool.get('account.voucher').create(cr, uid, voucher_data, context=context)
    _logger.debug('test')
    _logger.debug(voucher_id)

    # Equivalent to workflow proform
    self.pool.get('account.voucher').write(cr, uid, [voucher_id], {'state':'draft'}, context=context)

    # Need to create basic account.voucher.line according to the type of invoice need to check stuff ...
    double_check = 0
    for move_line in invoice.move_id.line_id:
        # According to invoice type
        if invoice.type in ('out_invoice','out_refund'):
            if move_line.debit > 0.0:
                line_data = {
                    'name': invoice.number,
                    'voucher_id' : voucher_id,
                    'move_line_id' : move_line.id,
                    'account_id' : invoice.account_id.id,
                    'partner_id' : partner_id,
                    'amount_unreconciled': abs(move_line.debit),
                    'amount_original': abs(move_line.debit),
                    'amount': abs(move_line.debit),
                    'type': 'cr',
                }
                _logger.debug('line_data')
                _logger.debug(line_data)

                line_id = self.pool.get('account.voucher.line').create(cr, uid, line_data, context=context)
                double_check += 1
        else:
            if move_line.credit > 0.0:
                line_data = {
                    'name': invoice.number,
                    'voucher_id' : voucher_id,
                    'move_line_id' : move_line.id,
                    'account_id' : invoice.account_id.id,
                    'partner_id' : partner_id,
                    'amount_unreconciled': abs(move_line.credit),
                    'amount_original': abs(move_line.credit),
                    'amount': abs(move_line.credit),
                    'type': 'dr',
                }
                _logger.debug('line_data')
                _logger.debug(line_data)

                line_id = self.pool.get('account.voucher.line').create(cr, uid, line_data, context=context)
                double_check += 1

    # Cautious check to see if we did ok
    if double_check == 0:
        _logger.warning(invoice)
        _logger.warning(voucher_id)
        raise osv.except_osv(_("Warning"), _("I did not create any voucher line"))
    elif double_check > 1:
        _logger.warning(invoice)
        _logger.warning(voucher_id)
        raise osv.except_osv(_("Warning"), _("I created multiple voucher line ??"))


    # Where the magic happen
    self.pool.get('account.voucher').button_proforma_voucher(cr, uid, [voucher_id], context=context)
0
Avatar
Descartar
¿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
Changing the workflow for the Sales module. We don't use Sales Orders
workflow invoices sales.order quotes
Avatar
Avatar
1
dic 21
3700
Como crear un canal para PQR
workflow
Avatar
Avatar
2
oct 25
588
Odoo + amazon connector Resuelto
workflow
Avatar
Avatar
Avatar
2
sept 25
942
How to set up recurring automatic payments in Odoo
workflow
Avatar
Avatar
1
sept 25
1224
Looking for Full Workflow Video: Purchase ➝ Sales ➝ Inventory ➝ Accounting ➝ Manufacturing in Odoo
workflow
Avatar
Avatar
1
ago 25
1223
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