Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

How to register payments automatically trough python code?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
v8pythonautomatedpayments
1 Odpowiedz
11118 Widoki
Awatar
Sergej

Task: Given a csv file with payments, the customer payments have to be registred in odoo. 

I am not using RPC calls, everything happens in an Import Wizard that I have created. The Wizard reads the file and searches for the invoices.

First attempt: After importing the file I have the invoice code and the paid amount for every invoice. I've read the post https://www.odoo.com/forum/help-1/question/how-to-apply-payment-to-invoice-via-xml-rpc-37795. My implementation looked like this:

            invoice = self.env['account.invoice'].search([('number','=',invoice_name)])

partner_id = self.env['res.partner']._find_accounting_partner(invoice.partner_id).id
account_voucher = invoice.env['account.voucher'].create({
'amount':amount,
'account_id':invoice.account_id.id,
'partner_id':partner_id,
'type':invoice.type in ('out_invoice','out_refund') and 'receipt' or 'payment',
'journal_id':invoice.journal_id.id
})
for line in invoice.move_id.line_id:
if line.debit > 0.0:
account_voucher.env['account.voucher.line'].create({
'name':invoice.number,
'voucher_id':account_voucher.id,
'move_line_id':line.id,
'amount_unreconciled':abs(line.debit),
'amount_original':abs(line.debit),
'amount':abs(line.debit),
'account_id':invoice.account_id.id,
'partner_id':partner_id,
'type': 'cr',
})
account_voucher.signal_workflow('proforma_voucher')

Problem: Although payments are registred, the behaviour is different from the standard payment behaviour. The credit field in the customer accounting tab is not affected which means that the whole process isn't complete. Additionally, I don't need to have so much information for the standard payment operation. If the button Register Payment is pressed in an invoice only the amount and the journal_id are needed. Everything else gets computed by the system.

Is there a way to simulate the standard behaviour. My thought was to get the context from the invoice_pay_customer function, open a new voucher model with this context, set the amount, set the journal_id and to press the button Register Payment. My code:

invoice = self.env['account.invoice'].search([('number','=',invoice_name)])
test = invoice.invoice_pay_customer()
context_dict = {}
context_dict.update(invoice._context)
context_dict.update(test['context'])
account_voucher = invoice.env['account.voucher'].with_context(context_dict).new({'amount':amount,'journal_id':self.env['account.journal'].search([('code','=','BNK2')]).id})
account_voucher.button_proforma_voucher()

If I use create instead of new then I would need a lot of mandatory fields, which normally should be computed by the system. If I use new then it's not the same as creating a new view. Nothing happens if the button is pressed. The code runs without errors. The context is not available in the new object. (Debug prints in account.voucher only have the standard tz, id, .... context)

Is there a way to improve this thought or should it be done in a different way?


I appreciate any help and feedback!


3
Awatar
Odrzuć
Awatar
Vysakh B Thottarath
Najlepsza odpowiedź

Got the answer ?

0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
creating automatic scheduled job to archive tasks
python automated scheduler
Awatar
Awatar
Awatar
2
lut 23
4974
Studio Automated Actions Python Code
python automated studio
Awatar
Awatar
1
sty 21
12346
Automated action : return another action Rozwiązane
action python automated
Awatar
Awatar
3
lip 20
10849
Python expression in Automated Actions Rozwiązane
action python automated
Awatar
Awatar
1
kwi 20
14934
Manage field type file
crm python automated
Awatar
Awatar
3
sty 20
3981
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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