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 generate new draft invoice ( invoice_line ) from new generate module?

Iscriviti

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

La domanda è stata contrassegnata
Invoice_line
2 Risposte
9306 Visualizzazioni
Avatar
abdul aziz yaakup

Hi all,

I create a new module to calculate water consumption and I want to generate a new invoice from it. This module has similar models like "sale.order" and "sale.order.line". 

I can generate a draft invoice from my module but the problem is, it doesn't include the invoice_lines. This draft invoice only get the value for the customer (partner_id) , journal (journal_id) and account (account_id).  

Can anyone assist me on this?

Thank you.

 

0
Avatar
Abbandona
Avatar
Mariusz Mizgier
Risposta migliore

Go to sale/wizard/sale_make_invoice.py and sale/wizard/sale_line_invoice.py for reference - you have methods written right there. Look also at sale.py, especially at _prepare_order_line_invoice_line for further answers.

0
Avatar
Abbandona
Avatar
abdul aziz yaakup
Autore Risposta migliore

Hi Mariusz Mizgier, Thanks for your tips. I already create the same methods in order to make it happen but I got the following error.

 

2014-06-02 12:52:21,945 5460 ERROR ccsb2 openerp.sql_db: Programming error: can't adapt type 'browse_record', in query insert into "account_invoice" (id,"origin","comment","check_total","reference","payment_term","journal_id","currency_id","partner_id","fiscal_position","user_id","reference_type","company_id","state","type","internal_number","account_id","reconciled","section_id","date_invoice","name","sent",create_uid,create_date,write_uid,write_date) values (31,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,(now() at time zone 'UTC'),%s,(now() at time zone 'UTC')) 2014-06-02 12:52:21,946 5460 ERROR ccsb2 openerp.osv.osv: Uncaught exception Traceback (most recent call last): File "/opt/openerp/v7/server/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/opt/openerp/v7/server/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/opt/openerp/v7/addons/audittrail/audittrail.py", line 514, in execute_cr return fct_src(cr, uid, model, method, *args, **kw) File "/opt/openerp/v7/server/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/opt/openerp/v7/extra_addons/utility_meter/wizard/water_make_invoice_advance.py", line 176, in create_invoices res = utility_meter_obj.action_invoice_create(cr, uid, utility_meter_ids, context) File "/opt/openerp/v7/extra_addons/utility_meter/water_meter.py", line 982, in action_invoice_create res = self._make_invoice(cr, uid, val[0][0], reduce(lambda x, y: x + y, [l for o, l in val], []), context=context) File "/opt/openerp/v7/extra_addons/utility_meter/water_meter.py", line 902, in _make_invoice inv_id = inv_obj.create(cr, uid, inv, context=context) File "/opt/openerp/v7/addons/mail/mail_thread.py", line 241, in create thread_id = super(mail_thread, self).create(cr, uid, values, context=context) File "/opt/openerp/v7/server/openerp/osv/orm.py", line 4511, in create cr.execute('insert into "'+self._table+'" (id'+upd0+") values ("+str(id_new)+upd1+')', tuple(upd2)) File "/opt/openerp/v7/server/openerp/sql_db.py", line 161, in wrapper return f(self, *args, **kwargs) File "/opt/openerp/v7/server/openerp/sql_db.py", line 226, in execute res = self._obj.execute(query, params) ProgrammingError: can't adapt type 'browse_record' 2014-06-02 12:52:21,952 5460 ERROR ccsb2 openerp.netsvc: can't adapt type 'browse_record' Traceback (most recent call last): File "/opt/openerp/v7/server/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/opt/openerp/v7/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/opt/openerp/v7/server/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/opt/openerp/v7/server/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/opt/openerp/v7/server/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/opt/openerp/v7/addons/audittrail/audittrail.py", line 514, in execute_cr return fct_src(cr, uid, model, method, *args, **kw) File "/opt/openerp/v7/server/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/opt/openerp/v7/extra_addons/utility_meter/wizard/water_make_invoice_advance.py", line 176, in create_invoices res = utility_meter_obj.action_invoice_create(cr, uid, utility_meter_ids, context) File "/opt/openerp/v7/extra_addons/utility_meter/water_meter.py", line 982, in action_invoice_create res = self._make_invoice(cr, uid, val[0][0], reduce(lambda x, y: x + y, [l for o, l in val], []), context=context) File "/opt/openerp/v7/extra_addons/utility_meter/water_meter.py", line 902, in _make_invoice inv_id = inv_obj.create(cr, uid, inv, context=context) File "/opt/openerp/v7/addons/mail/mail_thread.py", line 241, in create thread_id = super(mail_thread, self).create(cr, uid, values, context=context) File "/opt/openerp/v7/server/openerp/osv/orm.py", line 4511, in create cr.execute('insert into "'+self._table+'" (id'+upd0+") values ("+str(id_new)+upd1+')', tuple(upd2)) File "/opt/openerp/v7/server/openerp/sql_db.py", line 161, in wrapper return f(self, *args, **kwargs) File "/opt/openerp/v7/server/openerp/sql_db.py", line 226, in execute res = self._obj.execute(query, params) ProgrammingError: can't adapt type 'browse_record'

 

I hope that you can help me on this because I was stuck at this error. Thanks.

0
Avatar
Abbandona
Mariusz Mizgier

Please copy your code here, so that I can say anything about it. I would be interested in the way you create a dictionary to pass the values for invoice creation.

abdul aziz yaakup
Autore

Here is my code. def _prepare_invoice(self, cr, uid, order, lines, context=None): if context is None: context = {} pa=1 pb=3 # pc=8 import pdb; pdb.set_trace(); invoice_vals = { 'name': order.client_order_ref or '', 'origin': order.name, 'type': 'out_invoice', 'reference':order.client_order_ref or order.name, 'account_id': order.partner_id.property_account_receivable.id, 'partner_id': order.partner_id.id, 'journal_id': order.journal_id, 'invoice_line': [(6, 0, lines)], 'currency_id': order.currency_id, 'comment': order.note, 'payment_term': order.payment_term and order.payment_term.id or False, 'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id, 'date_invoice': context.get('date_invoice', False), 'company_id': pa, 'user_id': order.user_id and order.user_id.id or False } import pdb; pdb.set_trace(); invoice_vals.update(self._inv_get(cr, uid, order, context=context)) return invoice_vals Here is for the _prepare_line.. def _prepare_invoice_line(self, cr, uid, line, account_id=False, context=None): res = {} if not line.invoiced: if not account_id: if line.product_id: account_id = line.product_id.property_account_income.id if not account_id: account_id = line.product_id.categ_id.property_account_income_categ.id if not account_id: raise osv.except_osv(_('Error!'), _('Please define income account for this product: "%s" (id:%d).') % \ (line.product_id.name, line.product_id.id,)) else: prop = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category', context=context) account_id = prop and prop.id or False uosqty = self._get_line_qty(cr, uid, line, context=context) uos_id = self._get_line_uom(cr, uid, line, context=context) pu = 0.0 import pdb; pdb.set_trace(); if not account_id: raise osv.except_osv(_('Error!'), _('There is no Fiscal Position defined or Income category account defined for default properties of Product categories.')) res = { 'name': line.name, 'sequence': line.sequence, 'origin': line.order_id.name, 'account_id': line.product_id.property_account_income.id, #'account_id': acc, 'price_unit': pu, 'quantity': uosqty, 'discount': line.discount, 'uos_id': uos_id, 'product_id': line.product_id.id or False, 'account_analytic_id': line.order_id.project_id and line.order_id.project_id.id or False, } return res

Mariusz Mizgier

Well, surely there is an error in invoice_vals definition - because the code is not clear to read in such message (best would be py file), i can see anyways that you reference 'journal_id': order.journal_id, whereas you should go for order.journal_id.id, as well as 'currency_id': order.currency_id, where it should be order.currency_id.id - both are many2one relations so you need ids of these (that's why error was about browse_record - you wanted to create an object with value of browse_record,id instead of id - that is how is order.journal_id seen in Python). Feel free to ask any further questions, hopefully I will be able to help you. If you need more simple way to create invoice, refer to https://github.com/odoo/odoo/blob/saas-5/addons/account_analytic_analysis/account_analytic_analysis.py lines 665-733.

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à
Importing Invoice Lines ignores field 'Invoice lines / External ID'
import Invoice_line
Avatar
Avatar
1
gen 22
2695
i have this code for 12 but i want to use odoo 13 Risolto
tax_id Invoice_line Odoo13
Avatar
Avatar
Avatar
2
ago 20
3176
[V8] Product description in invoice Risolto
v8 Invoice_line V8
Avatar
1
mag 16
4543
Auto-completion of invoice lines problem Risolto
Invoice_line auto-complete billable Invoicing
Avatar
Avatar
Avatar
Avatar
3
lug 23
4524
How to write multiple orderlines with XML-RPC to remote database? Risolto
xmlrpc erppeek Invoice_line odoo8
Avatar
1
feb 23
11207
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