Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

How to generate new draft invoice ( invoice_line ) from new generate module?

Subscribe

Get notified when there's activity on this post

This question has been flagged
Invoice_line
2 Replies
9290 Views
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
Discard
Avatar
Mariusz Mizgier
Best Answer

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
Discard
Avatar
abdul aziz yaakup
Author Best Answer

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
Discard
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
Author

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.

Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
Importing Invoice Lines ignores field 'Invoice lines / External ID'
import Invoice_line
Avatar
Avatar
1
जन॰ 22
2690
i have this code for 12 but i want to use odoo 13 Solved
tax_id Invoice_line Odoo13
Avatar
Avatar
Avatar
2
अग॰ 20
3170
[V8] Product description in invoice Solved
v8 Invoice_line V8
Avatar
1
मई 16
4541
Auto-completion of invoice lines problem Solved
Invoice_line auto-complete billable Invoicing
Avatar
Avatar
Avatar
Avatar
3
जुल॰ 23
4519
How to write multiple orderlines with XML-RPC to remote database? Solved
xmlrpc erppeek Invoice_line odoo8
Avatar
1
फ़र॰ 23
11203
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

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