Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

Odoo 11 Cash Rounding via External API.

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
apiodoo11
1 Svar
3462 Visninger
Avatar
Terence Ng

I am trying to add the cash rounding line via API and wonder whether it is possible. I have created the invoice and define the cash rounding method but it will not add the cash rounding line as invoice_line is added later. I wonder whether there is a method to trigger the cash rounding like compute_tax. Below is the code I use, for testing purpose i have include adding invoice_line as part of the code.

@app.route("/create_invoice")

def create_invoice():

    date_invoice = request.args.get("date_invoice")

    invoice_id = models.execute_kw(db, uid, password, 'account.invoice', 'create', [{

    'date_invoice':date_invoice,

    'type': 'out_invoice',

    'partner_id': 92,

    'account_id': 38,

    'cash_rounding_id': 1,

    }])

    product_id = request.args.get("product_id")

    name = request.args.get("name")

    quantity = request.args.get("quantity")

    price_unit = request.args.get("price_unit")

    account_id = request.args.get("account_id")

    invoice_line_id = models.execute_kw(db, uid, password, 'account.invoice.line', 'create', [{

    'invoice_id': invoice_id,

    'product_id': product_id,

    'name': name,

    'quantity': quantity,

    'price_unit': price_unit,

    'account_id': account_id,

    'invoice_line_tax_ids':  [ (4,6) ],

    }])

    invoice_tax_id = models.execute_kw(db, uid, password, 'account.invoice', 'compute_taxes', [(invoice_id)])

    return jsonify(invoice_id)

0
Avatar
Kassér
Avatar
Terence Ng
Forfatter Bedste svar

I did manually in the end.

    rounding_line_id = models.execute_kw(db, uid, password,'account.invoice.line', 'search',[[['invoice_id', '=', invoice_id], ['is_rounding_line', '=', True]]])
if rounding_line_id:
models.execute_kw(db, uid, password, 'account.invoice.line', 'unlink', [rounding_line_id]) models.execute_kw(db, uid, password, 'account.invoice', 'compute_taxes', [(invoice_id)])
total = models.execute_kw(db, uid, password,'account.invoice', 'search_read', [[['id', '=', invoice_id]]], {'fields': ['amount_total']})
total_value = total[0].get('amount_total')
normalized_value = total_value/0.05
sign = math.copysign(1.0, normalized_value)
epsilon_magnitude = math.log(abs(normalized_value), 2)
epsilon = 2**(epsilon_magnitude-53)
normalized_value += sign*epsilon
rounded_value = math.floor(abs(normalized_value)) * sign * 0.05
rounding_difference = rounded_value - total_value
if rounding_difference:
models.execute_kw(db, uid, password, 'account.invoice.line', 'create', [{
'invoice_id': invoice_id,
'name': 'Rounding',
'quantity': 1,
'price_unit': rounding_difference,
'account_id': 126,
'is_rounding_line': True,
'sequence': 9999
}])
return jsonify(invoice_line_id)
1
Avatar
Kassér
Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
create GET API for backend team from odoo
api controller odoo11
Avatar
Avatar
1
nov. 23
5001
Scheduled Actions
api scheduled odoo11
Avatar
Avatar
1
mar. 23
6542
How to access external API given by someone else from Odoo 11?
external api odoo11
Avatar
Avatar
Avatar
2
dec. 19
16937
How to retrieve invoices using the web API in Odoo 11?
api invoices odoo11
Avatar
Avatar
Avatar
Avatar
Avatar
7
okt. 19
11438
ODOO 11 AND 12 : What are the differnces between API odoo 11 and odoo 12 ? Løst
api odoo11 odoo12
Avatar
Avatar
1
jul. 19
4134
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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