Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

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

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
xmlrpcerppeekInvoice_lineodoo8
1 Rispondi
11226 Visualizzazioni
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
Abbandona
Avatar
Yenthe Van Ginneken (Mainframe Monkey)
Autore Risposta migliore

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
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
How to create database on remote server with xmlrpc or erppeek ? Risolto
xmlrpc erppeek odoo
Avatar
Avatar
1
ago 21
4447
Changing xmlrpc_port from 8069 to 8070 causes report issues? Risolto
xmlrpc port odoo8
Avatar
1
mar 15
8339
How to import data with External ID's through XMLRPC Risolto
v8 csv xmlrpc odoo8
Avatar
2
mag 22
13221
xmlrpc Error when attempting to connect to my local instance Risolto
xmlrpc
Avatar
Avatar
Avatar
3
lug 25
4186
Cannot marshal None unless allow_none is enabled
xmlrpc
Avatar
1
ott 24
3039
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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