Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

How to apply payment to Invoice via XML-RPC?

Odebírat

Get notified when there's activity on this post

This question has been flagged
workflowinvoicesvoucher
10 Odpovědi
23780 Zobrazení
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
Zrušit
Avatar
Aron Lorincz
Nejlepší odpověď

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
Zrušit
Avatar
Carlos Castillo
Autor Nejlepší odpověď

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
Zrušit
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
Nejlepší odpověď

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
Zrušit
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
Nejlepší odpověď

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
Zrušit
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
Nejlepší odpověď

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
Zrušit
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Changing the workflow for the Sales module. We don't use Sales Orders
workflow invoices sales.order quotes
Avatar
Avatar
1
pro 21
3707
Como crear un canal para PQR
workflow
Avatar
Avatar
2
říj 25
591
Odoo + amazon connector Vyřešeno
workflow
Avatar
Avatar
Avatar
2
zář 25
949
How to set up recurring automatic payments in Odoo
workflow
Avatar
Avatar
1
zář 25
1230
Looking for Full Workflow Video: Purchase ➝ Sales ➝ Inventory ➝ Accounting ➝ Manufacturing in Odoo
workflow
Avatar
Avatar
1
srp 25
1224
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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