Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Discuss
    • Artificial Intelligence
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Manajemen Properti
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Konsultasi
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

Register payment using XMLRPC

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
accountpaymentaccount.invoicexmlrpcaccount.voucher
5 Replies
14672 Tampilan
Avatar
Vlad Janicek

Hi there,

I have been trying to register an invoice payment through OpenERP. I have been able to manually create and approve the invoice, the voucher and its line

I'm currently creating the voucher using this information:

def create_voucher(name, amount, journal_id, account_id,
                   period_id, partner_id, move_id):
    model = 'account.voucher'
    r = {
        'name': name,
        'amount': amount,
        'journal_id': journal_id,
        'account_id': account_id,
        'period_id': period_id,
        'partner_id': partner_id,
        'type': 'receipt',
        # Colocar move_id
        'move_id': move_id
    }
# executing XMLRPC stuff

And im creating voucher lines with this info

def create_voucher_line(name, amount, voucher_id, partner_id, account_id):
    model = 'account.voucher.line'
    r = {
        'name': name,
        'payment_option': 'without_writeoff',
        'amount': amount,
        'voucher_id': voucher_id,
        'partner_id': partner_id,
        'account_id': account_id,
        #'move_id': move_id
        #'amount': 0,
        #'type': 'cr'
    }
# executing XMLRPC stuff

I can successfully see the voucher record and it's lines but this is where I may be wrong. How do I register that voucher into an invoice payment?? I have tried to use proforma voucher with no success

db_conn.exec_workflow('mydb', 1, 'admin', 'account.voucher',  'proforma_voucher', voucher_id)

If I'm successfully creating a voucher and it's lines, what would be the final step to register that as a payment??

Thanks a lot for your help

jhv

2
Avatar
Buang
Aron Lorincz

I've added an (I think) simple-to-follow answer here: https://www.odoo.com/forum/help-1/question/how-to-apply-payment-to-invoice-via-xml-rpc-37795#answer_93799

Avatar
Carlos Castillo
Jawaban Terbai

Hi,

I had the same issue and in my case I needed to remove the field "move_id" from account.voucher and adding the field "move_line_id" to account.voucher.line, have you tried that?

move_line_id should match the ID of the account.move.line whose "move_id" field matches the "move_id" field of the invoice you created

I also set 'type'='cr' for account.voucher.line

After that, executing workflow('account.voucher', 'proforma_voucher', voucher_id) worked ok,

Hope this helps!

3
Avatar
Buang
Vlad Janicek
Penulis

Had few days without checking this and yes!! i found out how to do it and is exactly what you said!!

Avatar
Luc Vanwaelscappel
Jawaban Terbai

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)
1
Avatar
Buang
Peter Alabaster

Thanks for this - helped me to write test cases for registering payment on invoices. For some reason i was getting the 'double_check > 1' case, and it turned out it was a stock account getting into the mix with a debit above 0. I'm not sure if this is a config issue or just that the above code doesn't take into account the stock accounts (V8). Either way, cheers !

Avatar
Ashif Abdulrahman
Jawaban Terbai

no need to inherit account.voucher. after creating the account.voucher record, you just add this in your XMLRPC script.

self.sock.execute(self.dbname, self.uid, self.pwd, 'account.voucher', 
                             'button_proforma_voucher', voucher_id, {})

voucher_id should be the ID of the created voucher.

1
Avatar
Buang
Vlad Janicek
Penulis

I did, as I mentioned in my post, but it didnt chante its status. Am i missing something with the voucher or its line? Should I add another record? or should I add more lines per voucher?

Jack Richard

@Vlad Janicek what is the issue with it? have you got any errors?

Vlad Janicek
Penulis

I may be inserting wrong records in voucher lines... I get no errors when I execute the workflow. Ashif suggested execute but execute is for browsing. I used exec_workflow. I only get False and no changes are made

Vlad Janicek
Penulis

any ideas? im about to give up

Vlad Janicek
Penulis

I tried that too. I get this returned: {'type': 'ir.actions.act_window_close'}

That is the button that is pressed in the register payment wizard view. Wont this avoid all the functions in that view?

I tried that when I realized that I have to execute all the onmove functions in order to have all the account_voucher_lines records.

Thanks a lot, I really appreciate your help dude! I'll keep trying to figure it out

Vlad Janicek
Penulis

I even found out that 'confirm_paid' would make an invoice as 'paid' but wont tie it to a voucher. wf_service.trg_validate(uid, 'account.invoice', invoice_id, 'confirm_paid', cr). The invoice will be paid but it wont register it's payment. Doesn't work for us either

Avatar
Ferdinand Gassauer
Jawaban Terbai

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

  1. create and open invoice
  2. create and post payment move
  3. 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)

0
Avatar
Buang
Avatar
Vlad Janicek
Penulis Jawaban Terbai

Thank you very much for for answer and help.

I tried that already and it didn't work. It may be that I'm missing to add the exact move_line_id or any other record to account_voucher_line or that I'm missing something else.

Just in case, I followed everything you said with no payment being registered.

This is how I inherited account_voucher:

class account_voucher(osv.osv):
    _inherit = 'account.voucher'

    def action_proforma_voucher(self, cr, uid, voucher_id, context=None):
        wf_service = netsvc.LocalService("workflow")
        wf_service.trg_validate(uid, 'account.voucher', voucher_id,
                                'proforma_voucher', cr)
        wf_service.trg_write(uid, 'account.voucher', voucher_id, cr)
        return True

BTW I printed both outputs

wf_service.trg_validate(uid, ...
wf_service.trg_write(uid, 'acc...

and they print False and None respectively

This is what I used to execute the XMLRPC call

def set_payment(voucher_id):
    db_conn = xmlrpclib.ServerProxy(dc.url + '/xmlrpc/object')
    return db_conn.execute('mydb', myuid, 'mypass', 'account.voucher',
                           'action_proforma_voucher', voucher_id, {})

I still don't understand this process. What is exactly needed by the 'proforma_voucher' WF process? I have checked all the onchange functions in the register payment view and they create many account_voucher_lines whereas I'm just creating one.

Thanks a lot for your help pal

0
Avatar
Buang
Ashif Abdulrahman

There is an another way, i have updated my previous answer. check it out....

Vlad Janicek
Penulis

@Ashif: thanks! I updated my last comment. It didnt work either.

Vlad Janicek
Penulis

Still trying... doing each onchange by hand and it doesn't work

Ashif Abdulrahman

hi, please check this too...

Vlad Janicek
Penulis

Updated, still not working

Vlad Janicek
Penulis

Any ideas?

Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
How to update delay charges?
account payment account.invoice payment_term
Avatar
0
Mar 15
4964
Any module for delay charges?
module account payment account.invoice total
Avatar
0
Mar 15
4886
can't validate invoice in multi-company (Document type: Account, Operation: read) Diselesaikan
account account.invoice
Avatar
Avatar
Avatar
Avatar
Avatar
5
Des 23
22992
Openerp 7 Indian Accounting
account account.invoice
Avatar
0
Mar 15
4825
Export accounting entry of payment with linked invoice sequence number
invoice account payment
Avatar
Avatar
1
Mei 25
2573
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Karir
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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