Skip to Content
Odoo Меню
  • Увійти
  • Спробуйте це безкоштовно
  • Додатки
    Фінанси
    • Бухоблік
    • Виставлення рахунку
    • Витрати
    • Електронні таблиці (BI)
    • Документи
    • Підпис
    Продажі
    • CRM
    • Продажі
    • POS Магазин
    • POS Ресторан
    • Підписки
    • Оренда
    Веб-сайти
    • Конструктор веб-сайту
    • Електронна комерція
    • Блог
    • Форум
    • Живий чат
    • Електронне навчання
    Ланцюг поставок
    • Склад
    • Виробництво
    • PLM
    • Купівлі
    • Технічне обслуговування
    • Якість
    Кадри
    • Співробітники
    • Рекрутинг
    • Відпустки
    • Оцінювання
    • Рекомендації
    • Автотранспорт
    Маркетинг
    • Маркетинг соцмереж
    • Email-маркетинг
    • SMS-маркетинг
    • Події
    • Автом. маркетингу
    • Опитування
    Послуги
    • Проект
    • Табелі
    • Виїзне обслуговування
    • Служба підтримки
    • Планування
    • Призначення
    Продуктивність
    • Обговорення
    • Схвалення
    • IoT
    • IP-телефонія
    • База знань
    • WhatsApp
    Сторонні модулі Odoo Studio Платформа Odoo Cloud
  • Сфери
    Роздрібна торгівля
    • Книжковий магазин
    • Магазин одягу
    • Магазин меблів
    • Продуктовий магазин
    • Магазин будівельних матеріалів
    • Магазин іграшок
    Food & Hospitality
    • Бар та паб
    • Ресторан
    • Фастфуд
    • Guest House
    • Дистриб'ютор напоїв
    • Hotel
    Нерухомість
    • Real Estate Agency
    • Архітектурна фірма
    • Будівництво
    • Управління нерухомістю
    • Садівництво
    • Асоціація власників нерухомості
    Консалтинг
    • Бухгалтерська компанія
    • Партнер Odoo
    • Агенція маркетингу
    • Юридична фірма
    • Придбання Талантів
    • Аудит та сертифікація
    Виробництво
    • Textile
    • Metal
    • Меблі
    • Їжа
    • Brewery
    • Корпоративні подарунки
    Здоров'я & Фітнес
    • Спортивний клуб
    • Оптика
    • Фітнес-центр
    • Практики здоров'я
    • Аптека
    • Салон краси
    Trades
    • Ремонтник
    • IT-обладнання та Підтримка
    • Системи сонячної енергії
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Інші
    • Nonprofit Organization
    • Екологічна агенція
    • Оренда білбордів
    • Фотографія
    • Лізинг велосипедів
    • Реселлер програмного забезпечення
    Browse all Industries
  • Спільнота
    Навчання
    • Навчальний посібник
    • Документація
    • Сертифікації
    • Тренування
    • Блог
    • Подкаст
    Сприяйте Освіті
    • Програма навчання
    • Бізнес гра Scale Up!
    • Відвідайте 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:

  • CRM
  • e-Commerce
  • Бухоблік
  • Склад
  • PoS
  • Проект
  • MRP
All apps
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
All Posts Люди Значки
Мітки (View all)
odoo accounting v14 pos v15
Про цей форум
Допомога

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

Підписатися

Отримуйте сповіщення про активність щодо цієї публікації

Це запитання позначене
Invoice_line
2 Відповіді
9295 Переглядів
Аватар
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
Аватар
Відмінити
Аватар
Mariusz Mizgier
Найкраща відповідь

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
Аватар
Відмінити
Аватар
abdul aziz yaakup
Автор Найкраща відповідь

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
Аватар
Відмінити
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
Автор

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!

Реєстрація
Related Posts Відповіді Переглядів Дія
Importing Invoice Lines ignores field 'Invoice lines / External ID'
import Invoice_line
Аватар
Аватар
1
січ. 22
2690
i have this code for 12 but i want to use odoo 13 Вирішено
tax_id Invoice_line Odoo13
Аватар
Аватар
Аватар
2
серп. 20
3171
[V8] Product description in invoice Вирішено
v8 Invoice_line V8
Аватар
1
трав. 16
4541
Auto-completion of invoice lines problem Вирішено
Invoice_line auto-complete billable Invoicing
Аватар
Аватар
Аватар
Аватар
3
лип. 23
4519
How to write multiple orderlines with XML-RPC to remote database? Вирішено
xmlrpc erppeek Invoice_line odoo8
Аватар
1
лют. 23
11206
Спільнота
  • Навчальний посібник
  • Документація
  • Форум
Open Source
  • Завантаження
  • Github
  • Runbot
  • Переклади
Послуги
  • Хостинг Odoo.sh
  • Підтримка
  • Оновлення
  • Кастомні доробки
  • Навчання
  • Знайдіть бухгалтера
  • Знайдіть партнера
  • Стати партнером
Про нас
  • Наша компанія
  • Торгові активи
  • Зв'яжіться з нами
  • Вакансії
  • Події
  • Подкаст
  • Блог
  • Клієнти
  • Юридичні документи • Конфіденційність
  • Безпека
الْعَرَبيّة 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 - це набір програм для роботи з відкритим кодом, які охоплюють всі ваші потреби компанії: CRM, електронна комерція, бухгалтерський облік, склад, точка продажу, управління проектами тощо.

Унікальна пропозиція 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