Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

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

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

Qweb report errors with attribute error

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
errorqweb
4 Trả lời
8816 Lượt xem
Ảnh đại diện
Ajit P

Odoo 12

Custom Book Report of QWeb type

While running a simple Book Report of Qweb pdf report type, I face a problem.

 

Goal: To run a book report that allows the books to be shown in pdf output for a given Author and Title.  When the report is run, a wizard pops up where there are Author and Title search fields.  After that the Get Report button is clicked. The report output is expected instead the following error occurs.

The report doesn't launch, instead errors with a message below: 

"AttributeError: type object 'x_book.report.wizard' has no attribute 'get_report'.

Error Message :: Odoo Server Error
Traceback (most recent call last): File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 654, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 312, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "C:\Program Files (x86)\Odoo 12.0\server\odoo\tools\pycompat.py", line 87, in reraise

    raise value

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 696, in dispatch

    result = self._call_function(**self.params)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 344, in _call_function

    return checked_call(self.db, *args, **kwargs)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\service\model.py", line 97, in wrapper

    return f(dbname, *args, **kwargs)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 337, in checked_call

    result = self.endpoint(*a, **kw)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 939, in __call__

    return self.method(*args, **kw)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\http.py", line 517, in response_wrap

    response = f(*args, **kw)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\addons\web\controllers\main.py", line 966, in call_button

    action = self._call_kw(model, method, args, {})

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\addons\web\controllers\main.py", line 954, in _call_kw

    return call_kw(request.env[model], method, args, kwargs)

  File "C:\Program Files (x86)\Odoo 12.0\server\odoo\api.py", line 742, in call_kw

    method = getattr(type(model), name)

AttributeError: type object 'x_book.report.wizard' has no attribute 'get_report'


File-1: book/wizards/book_report_wizard.py
from odoo import models, fields, api
class BookReportWizard(models.TransientModel):
    _name = 'report.book.book_report'
    x_book_title = fields.Char(string="Book Title", required=True)
    x_book_author_name = fields.Char(string="Author Name", required=True)
    @api.multi
    def get_report(self):
        """Call when button 'Get Report' clicked.
        """
        datas = {
            'ids': self.ids,
            'model': self._name,
            'form': {
                'x_book_title': self.x_book_title,
                'x_book_author_name': self.x_book_author_name
            }
        }
        # use `module_name.report_id` as reference.
        # `report_action()` will call `get_report_values()` and pass `data` automatically.
        return self.env.ref('book.book_report').report_action(self, data=datas)
class BookReport(models.AbstractModel):
    """Abstract Model for report template.
    for `_name` model, please use `report.` as prefix then add `module_name.report_name`.
    """
    _name = 'x_book.book_report_view'
    @api.model
    def get_report_values(self, docids, data=None):
        x_book_title = data['form']['x_book_title']
        x_book_author_name = data['form']['x_book_author_name']
        docs = []
        books = self.env['book.x_book'].search([
            ('x_title', '=', x_book_title),
            ('x_author_name', '=' , x_book_author_name)
            ], order='x_title asc')
        for book in books:
            docs.append({
                'x_book_title': book.x_title,
                'x_book_author_name': book.x_author_name
            })
        return {
            'doc_ids': data['ids'],
            'doc_model': data['model'],
            'x_book_title': x_book_title,
            'x_book_author_name': x_book_author_name,
            'docs': docs
        }

File-2: book/wizards/book_report_wizard.xml
<?xml version="1.0"?>
-<odoo>
-<record id="book_report_wizard" model="ir.ui.view">
<field name="name">Book Report</field>
<field name="model">x_book.report.wizard</field>
<field name="type">form</field>
-<field name="arch" type="xml">
-<form string="Book Report">
-<group>
-<group>
<field name="x_book_title"/>
</group>
-<group>
<field name="x_book_author_name"/>
</group>
</group>
-<footer>
<button name="get_report" type="object" string="Get Report" class="oe_highlight"/>
<button string="Cancel" special="cancel"/>
</footer>
</form>
</field>
</record>
<act_window id="action_book_report_wizard" name="Book Report" target="new" view_mode="form" res_model="x_book.report.wizard"/>
<menuitem id="menu_book_report_wizard" parent="book.menu_1" action="action_book_report_wizard"/>
</odoo>

File-3: book/wizards/__init__.py
from . import book_report_wizard

File-4: book/reports/book_report.xml
<?xml version="1.0"?>
-<odoo>
-<record id="paperformat_book_report" model="report.paperformat">
<field name="name">paperformat.book.report</field>
<field name="default" eval="True"/>
<field name="format">A4</field>
<field name="page_width">0</field>
<field name="page_width">0</field>
<field name="orientation">Portrait</field>
<field name="margin_top">30</field>
<field name="margin_right">5</field>
<field name="margin_bottom">10</field>
<field name="margin_left">5</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">20</field>
<field name="dpi">90</field>
</record>
<report id="book_report" model="report.book.book_report" name="book.book_report_view" menu="False" paperformat="paperformat_book_report" report_type="qweb-pdf" string="Book Report"/>
-<template id="book_report_view">
-<div style="border-bottom: 2px solid black" class="header">
<h3 class="text-center">Book Report</h3>
-<h4 class="text-center">
<strong>Title</strong>
: 
<t t-esc="x_book_title"/>
<strong>Author Name</strong>
: 
<t t-esc="x_book_author_name"/>
</h4>
</div>
-<div class="article">
-<table style="width: 100%" class="table table-condensed table-bordered">
-<thead>
<th style="width: 50%" class="text-center">Title</th>
<th style="width: 50%" class="text-center">Author Name</th>
</thead>
-<tbody>
-<t t-as="doc" t-foreach="docs">
-<tr>
-<td>
<span t-esc="doc['x_book_title']"/>
</td>
-<td class="text-center">
<span t-esc="doc['x_book_author_name']"/>
</td>
</tr>
</t>
</tbody>
</table>
</div>
-<div class="footer">
-<div style="border-top: 1px solid black;" class="row text-center">
-<div class="col-xs-3 col-xs-offset-9 text-right">
-<ul style="margin-top:10px;" class="list-inline">
<li>Page:</li>
-<li>
<span class="page"/>
</li>
<li>/</li>
-<li>
<span class="topage"/>
</li>
</ul>
</div>
</div>
</div>
</template>
</odoo>

File-5: book/models/book.py
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class book(models.Model):
    _name = 'x_book'
    x_title = fields.Char(String='Title', required=True)
    x_author_name = fields.Many2One('res.partner', String='Author Name', required=True)
    x_isbn = fields.Char(String='ISBN', required=True)
    x_publisher_name = fields.Char(String='Publisher Name', required=True)
    x_publication_year = fields.Char(String='Publication Year', required=True)
    x_price = fields.Float(String='Book Price', digits=dp.get_precision('Product Price'))
    @api.multi
    def get_report(self):
        pass

File-6: book/models/book_report.py

from odoo import models, fields, api
class BookReportWizard(models.TransientModel):
    _name = 'x_book.report.wizard'
    x_book_title = fields.Char(string="Book Title", required=True)
    x_book_author_name = fields.Date(string="Author Name", required=True)
    @api.multi
    def get_report(self):
        pass

File-7: book/models/__init__.py

# -*- coding: utf-8 -*-
from . import models
from . import book

File-8: book/models/models.py
# -*- coding: utf-8 -*-
from odoo import models, fields, api

File-9: book/views/book_view.xml
<odoo>
  <data>
    <!-- explicit list view definition -->
    
    <record model="ir.ui.view" id="book.list">
      <field name="name">book.list</field>
      <field name="model">x_book</field>
      <field name="arch" type="xml">
        <tree>
   <field name="x_title"/>
                <field name="x_author_name"/>
                <field name="x_isbn"/>
                <field name="x_publisher_name"/>
                <field name="x_publication_year"/>
                <field name="x_price"/>
          </tree>
      </field>
    </record>
    <!-- explicit form view definition -->
    <record model="ir.ui.view" id="view_book_form">
            <field name="name">book.form</field>
            <field name="model">x_book</field>             
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Book Details" version="12.0">
                 <header> ... Add Book Details... 
                 </header>
                    <sheet string="Books">
<group string="Book Details" colspan="4" col="4">
   <field name="x_title"/>
                <field name="x_author_name"/>
                <field name="x_isbn"/>
                <field name="x_publisher_name"/>
                <field name="x_publication_year"/>
                <field name="x_price"/>
</group>
                 </sheet>
                </form>
            </field>
    </record>
    
    <!-- actions opening views on models -->
    
    <record model="ir.actions.act_window" id="book_action_window">
      <field name="name">Book Window</field>
      <field name="res_model">x_book</field>
      <field name="view_mode">tree,form</field>
    </record>
    <act_window id="action_book_report_wizard"
                name="Book Report"
                res_model="x_book.report.wizard"
                view_mode="form"
                target="new"/>
    <!-- Top menu item -->
    
    <menuitem name="My Library" id="book.menu_root" sequence="30"/>
    
    <!-- menu categories -->
    <menuitem name="My Books" id="book.menu_1" parent="book.menu_root" action="book_action_window" sequence="10"/>
    <menuitem name="Book Report" 
              id="menu_book_report_wizard"
              parent="book.menu_1" action="action_book_report_wizard"
              sequence="15"/>
    <menuitem name="My Toys" id="book.menu_2" parent="book.menu_root" action="book_action_window" sequence="20"/>
  </data>
</odoo>

File-10: book/__manifest__.py
# -*- coding: utf-8 -*-
{
    'name': "book",
    'summary': """
        Books in a library""",
    'description': """
        Title and Author Name of Books in a library
    """,
    'author': "Infosure Services, Bangalore",
    'website': "http://infosure.in",
    # Categories can be used to filter modules in modules listing
    # Check https://github.com/odoo/odoo/blob/12.0/odoo/addons/base/data/ir_module_category_data.xml
    # for the full list
    'category': 'Sales',
    'version': '12.0.1',
    'images': ['images/INFOSURE_LOGO_MEDIUM.jpg'],
    'application': 'True',
    'installable': 'True',
    # any module necessary for this one to work correctly
    'depends': ['base'],
    # always loaded
    'data': [
    #   'security/ir.model.access.csv',
        'views/book_view.xml',
        'wizards/book_report_wizard.xml',
        'reports/book_report.xml',
    ],
    # only loaded in demonstration mode
    'demo': [
        'demo/demo.xml',
    ],
}

File-11: book/__init__.py
# -*- coding: utf-8 -*-
from . import controllers
from . import models
from . import wizards
0
Ảnh đại diện
Huỷ bỏ
Mitul Shingala

you have import the book_report.py file into __init__.py file

OdooBot
Here is an architecture diagram of my module: Book. 

This could help understand the files and layout of objects.
Could this be shown in the forum, hoping for a someone who can debug the error. 

BOOK-REPORT-QWEB.jpg


On Thursday, 24 January, 2019, 6:35:39 PM IST, Yenthe Van Ginneken <yenthespam@gmail.com> wrote:


View Forum Post Odoo S.A.

A new question Qweb report errors with attribute error on Help has been posted. Click here to access the question :

See question


Sent by Odoo S.A. using Odoo.

Ảnh đại diện
Ajit P
Tác giả Câu trả lời hay nhất

Thank you folks Mitul and Caret IT for your help. I will try and then update this ticket. 

Tried this still same error. 

Could anyone confirm, Are all the naming conventions correct?

0
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Caret IT Solutions Pvt. Ltd.
Câu trả lời hay nhất

Hi,

It looks like you have changed the name of file  so change it from book to book_report

File-7: book/models/__init__.py

# -*- coding: utf-8 -*-
from . import models
from . import book_report

and 
also change method name from get_report_values to _get_report_values
0
Ảnh đại diện
Huỷ bỏ
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Bài viết liên quan Trả lời Lượt xem Hoạt động
Qweb Report Header Error
error qweb header
Ảnh đại diện
Ảnh đại diện
1
thg 7 16
4385
?"Your country might be blocked by our hosting provider" error when I create new website
error
Ảnh đại diện
0
thg 11 25
592
Payment Page Return Error with Razorpay on Mobile Devices
error
Ảnh đại diện
0
thg 9 25
1258
Odoo 18: Display image from char field containing url in qweb form
qweb
Ảnh đại diện
Ảnh đại diện
1
thg 7 25
3123
PDF Export Option for QWeb Reports in odoo 17.0
qweb
Ảnh đại diện
Ảnh đại diện
1
thg 5 25
4103
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة 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 là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

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