Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profit organisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

How to write multiple orderlines with XML-RPC to remote database?

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
xmlrpcerppeekInvoice_lineodoo8
1 Beantwoorden
11208 Weergaven
Avatar
Yenthe Van Ginneken (Mainframe Monkey)

Hi guys,

I'm building a module that copies a whole invoice from one database to another the moment the user clicks on a button. I have a working concept, as long as there is one line (one product) on the invoice. 
The code:

# Get all ids from all taxes in the current database tax_ids = [] for tax_id in self.invoice_line.invoice_line_tax_id: result = tax_proxy.search([('name', '=', tax_id.name)]) # This means the tax doesn't exist in the target db if not result: # Create tax in target database. new_tax_id = tax_proxy.create({ 'name': tax_id.name, 'amount': tax_id.amount, 'price_include': tax_id.price_include, 'include_base_amount': tax_id.include_base_amount, 'child_depend': tax_id.child_depend }) tax_ids.append(new_tax_id.id) else: tax_ids.append(tax_id.id) # Create the invoice! invoice_proxy.create({ 'partner_id': partner_id, # This should be Mavi-Rent (res.contact company record) 'account_id': account[0], 'date_invoice': self.date_invoice, 'fiscal_position': self.fiscal_position, 'payment_term': self.payment_term, 'comment': self.comment, 'type': 'in_invoice', 'invoice_line': [(0, 0, { 'name': self.invoice_line.name, 'product_id': self.invoice_line.product_id.id, 'account_id': self.invoice_line.account_id.id, 'invoice_line_tax_id': [(6, 0, tax_ids)], 'quantity': self.invoice_line.quantity, 'price_unit': self.invoice_line.price_unit })] })

This however leaves me with two problems that I am unsure on how to solve:
1) The taxes are all added to a list before I do invoice_proxy.create, to create the invoice. This means that all taxes from all products will be applied. The reason that I did this before invoice_proxy.create was exactly for the same issue as problem #2.
2) This code will work if there is an invoice with one product line, but not with multiple (otherwise you'll get a singleton error).

So what I'm wondering is how should I exactly create multiple invoice_lines (with the correct taxes filled in in the many2many invoice_line_tax_id) in this .create function?

Regards,
Yenthe

1
Avatar
Annuleer
Avatar
Yenthe Van Ginneken (Mainframe Monkey)
Auteur Beste antwoord

Hi guys,

I ended up doing invoice_proxy.create first without the orderlines, just the invoice template.
After I created the invoice I loop over every line in invoice_line and do invoice_proxy.write to write one product at a time on the invoice. The code to create the invoice:

# Create the invoice! new_invoice = invoice_proxy.create({ 'partner_id': partner_id, # This should be Mavi-Rent (res.contact company record) 'account_id': account[0], 'date_invoice': self.date_invoice, 'date_due': self.date_due, 'reference': self.reference, 'origin': self.origin, 'fiscal_position': self.fiscal_position, 'payment_term': self.payment_term, 'comment': self.comment, 'type': 'in_invoice'

})

Writing a invoice_line away at a time in a for loop:

for invoice_line in self.invoice_line: # Write a line on the before created invoice new_invoice.write({ 'invoice_line': [(0, 0, { 'name': invoice_line.name, 'product_id': product_id, 'account_id': invoice_line.account_id.id, 'invoice_line_tax_id': [(6, 0, tax_ids)], 'quantity': invoice_line.quantity, 'price_unit': invoice_line.price_unit })]

})


When doing these operations there are a few things to watch out for though. Some examples:

  • Products may exist on your current database, but not on the database you write to

  • Taxes may exist on your current database, but not on the database you write to

  • Customers may exist on your customer database, but not on the database you write to

  • Any record that does not exist on your target database should be created through XML-RPC in the target database. Be sure to take the ID from the record of the remote database, not the current database. You will otherwise try to reference products from your local database in the target database that do not exist there (or, even worse, link to another product)

I hope this helps somebody in the future.

Yenthe

2
Avatar
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
How to create database on remote server with xmlrpc or erppeek ? Opgelost
xmlrpc erppeek odoo
Avatar
Avatar
1
aug. 21
4436
Changing xmlrpc_port from 8069 to 8070 causes report issues? Opgelost
xmlrpc port odoo8
Avatar
1
mrt. 15
8322
How to import data with External ID's through XMLRPC Opgelost
v8 csv xmlrpc odoo8
Avatar
2
mei 22
13203
xmlrpc Error when attempting to connect to my local instance Opgelost
xmlrpc
Avatar
Avatar
Avatar
3
jul. 25
4170
Cannot marshal None unless allow_none is enabled
xmlrpc
Avatar
1
okt. 24
3026
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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