Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

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

Naroči se

Get notified when there's activity on this post

This question has been flagged
xmlrpcerppeekInvoice_lineodoo8
1 Odgovori
11210 Prikazi
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
Opusti
Avatar
Yenthe Van Ginneken (Mainframe Monkey)
Avtor Best Answer

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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
How to create database on remote server with xmlrpc or erppeek ? Solved
xmlrpc erppeek odoo
Avatar
Avatar
1
avg. 21
4436
Changing xmlrpc_port from 8069 to 8070 causes report issues? Solved
xmlrpc port odoo8
Avatar
1
mar. 15
8324
How to import data with External ID's through XMLRPC Solved
v8 csv xmlrpc odoo8
Avatar
2
maj 22
13203
xmlrpc Error when attempting to connect to my local instance Solved
xmlrpc
Avatar
Avatar
Avatar
3
jul. 25
4171
Cannot marshal None unless allow_none is enabled
xmlrpc
Avatar
1
okt. 24
3030
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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