Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Print manually a report [TypeError: print_report() takes at most 7 arguments (11 given)]

Subscribe

Get notified when there's activity on this post

This question has been flagged
manualqweb-report
3 Replies
5101 Views
Avatar
William Mb

Hi everyone, 

Pls I try manually print a report this is the method action of a button that I use.

def clear_record_data(self):
    module_name = 'cookbook.recipe'    
    orm_button = self.env[module_name]         
    cr = self._cr     
    context = self._context     
    uid = self._uid     
    button_ids = orm_button.search([])     
    buttons = orm_button.browse(button_ids)     
    return orm_button.print_report(cr, uid, button_ids, module_name, buttons, context)

 

When the print_report method is call, I have this message


Traceback (most recent call last):

File "D:/odoo-8.0\openerp\http.py", line 544, in _handle_exception

return super(JsonRequest, self)._handle_exception(exception)

File "D:/odoo-8.0\openerp\http.py", line 581, in dispatch

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

File "D:/odoo-8.0\openerp\http.py", line 317, in _call_function

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

File "D:/odoo-8.0\openerp\service\model.py", line 118, in wrapper

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

File "D:/odoo-8.0\openerp\http.py", line 314, in checked_call

return self.endpoint(*a, **kw)

File "D:/odoo-8.0\openerp\http.py", line 810, in __call__

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

File "D:/odoo-8.0\openerp\http.py", line 410, in response_wrap

response = f(*args, **kw)

File "D:\odoo-8.0\addons\web\controllers\main.py", line 948, in call_button

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

File "D:\odoo-8.0\addons\web\controllers\main.py", line 936, in _call_kw

return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)

File "D:/odoo-8.0\openerp\api.py", line 268, in wrapper

return old_api(self, *args, **kwargs)

File "D:/odoo-8.0\openerp\api.py", line 399, in old_api

result = method(recs, *args, **kwargs)

File "D:\odoo-8.0\customs_addons\cookbook\models\button.py", line 38, in clear_record_data

return orm_button.print_report(cr, uid, button_ids, module_name, buttons, context)

File "D:/odoo-8.0\openerp\api.py", line 266, in wrapper

return new_api(self, *args, **kwargs)

File "D:/odoo-8.0\openerp\api.py", line 592, in new_api

result = method(self._model, cr, uid, self.ids, *args, **old_kwargs)

TypeError: print_report() takes at most 7 arguments (11 given)


1
Avatar
Discard
Jérémy Kersten (jke)

you are mixin old and new api...

try smthg like: return orm_button.print_report(module_name, buttons) ?

Avatar
William Mb
Author Best Answer

The python file

# -*- coding: utf-8 -*-
from openerp.osv import orm, fields
class ManualReport(orm.TransientModel):
    _name = 'cookbook.manualreport'
    _columns = {
        'name' : fields.char('Nom de la recette'),
        'category_id' : fields.many2one('cookbook.recipe.category', 'Categorie'),
        'difficulty' : fields.char('Niveau de difficulte'),
        'ingredients' : fields.char('Ingredient inclu'),
    }
    def recipe_report(self, cr, uid, ids, context=None):
        recipe_obj = self.pool.get('cookbook.recipe')
        cur_obj = self.browse(cr, uid, ids, context=context)
        filtre = []
        if cur_obj.name :
            filtre.append(('name', 'ilike', cur_obj.name))
        if cur_obj.category_id :
            filtre.append(('category_id', '=', cur_obj.category_id.name))
        if cur_obj.difficulty :
            filtre.append(('difficulty', 'ilike', cur_obj.difficulty))
        if cur_obj.ingredients :
            filtre.append(('ingredients', 'ilike', cur_obj.ingredients))
        recipe_ids = recipe_obj.search(cr, uid, filtre, context=context)
        if recipe_ids :
            datas = {
                'ids' : recipe_ids,
                'model' : self._name,
                'form' : self.read(cr, uid, ids, context=context)[0],
                'context' : context
        }
        return {
            'type' : 'ir.actions.report.xml',
            'report_name' : 'cookbook.report_recipe',
            'datas' : datas,
        }


The xml file view

<openerp>    
    <data>
        <record id="report_action" model="ir.actions.act_window">
            <field name="name">Buttons</field>
            <field name="res_model">cookbook.manualreport</field>
            <field name="type">ir.actions.act_window</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="target">new</field>
        </record>
        <menuitem id="report_elt_menu" name="Print" parent="cookbook_main_menu"
            action="report_action"/>
        <record id="report_view_form" model="ir.ui.view">
            <field name="name">cookbook.manualreport.form</field>
            <field name="model">cookbook.manualreport</field>
            <field name="arch" type="xml">
                <form string="Recipe Report">
                    <group string="Search elements">
                        <field name="name"/>
                        <field name="category_id" options="{'no_create':True}"/>
                        <field name="difficulty" options="{'no_create':True}"/>
                        <field name="ingredients"/>
                    </group>
                    <footer>
                        <button string="Report" name="recipe_report" type="object" class="oe_highlight"/>
                        or
                        <button string="Cancel" class="oe_link" special="cancel"/>
                    </footer>
                </form>
            </field>
        </record>
    </data>
</openerp>


0
Avatar
Discard
Avatar
reda rouichi
Best Answer

try this

i assume you are using the new api :)

def clear_record_data(self):
    orm_button = self.env['cookbook.recipe']
    button_ids = orm_button.search([])
   return button_ids.print_report()
0
Avatar
Discard
William Mb
Author

The issue don't change. The message error don't change

reda rouichi

can you show me the code of print_report() method.

William Mb
Author

def print_report(self, cr, uid, ids, name, data, context=None):

"""

Render the report ``name`` for the given IDs. The report must be defined

for this model, not another.

"""

report = self.pool['ir.actions.report.xml']._lookup_report(cr, name)

assert self._name == report.table

return report.create(cr, uid, ids, data, context)

William Mb
Author

It is the print_report() method of the models.py file in the openerp module

reda rouichi

try this

@api.multi

def clear_record_data(self):

orm_button = self.env['cookbook.recipe']

button_ids = orm_button.search([])

return button_ids.print_report('cookbook.report_recipe',{})

William Mb
Author

Traceback (most recent call last):

File "D:/odoo-8.0\openerp\http.py", line 544, in _handle_exception

return super(JsonRequest, self)._handle_exception(exception)

File "D:/odoo-8.0\openerp\http.py", line 581, in dispatch

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

File "D:/odoo-8.0\openerp\http.py", line 317, in _call_function

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

File "D:/odoo-8.0\openerp\service\model.py", line 118, in wrapper

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

File "D:/odoo-8.0\openerp\http.py", line 314, in checked_call

return self.endpoint(*a, **kw)

File "D:/odoo-8.0\openerp\http.py", line 810, in __call__

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

File "D:/odoo-8.0\openerp\http.py", line 410, in response_wrap

response = f(*args, **kw)

File "D:\odoo-8.0\addons\web\controllers\main.py", line 948, in call_button

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

File "D:\odoo-8.0\addons\web\controllers\main.py", line 936, in _call_kw

return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)

File "D:/odoo-8.0\openerp\api.py", line 268, in wrapper

return old_api(self, *args, **kwargs)

File "D:/odoo-8.0\openerp\api.py", line 399, in old_api

result = method(recs, *args, **kwargs)

File "D:\odoo-8.0\customs_addons\cookbook\models\button.py", line 38, in clear_record_data

return button_ids.print_report(report_name,{})

File "D:/odoo-8.0\openerp\api.py", line 266, in wrapper

return new_api(self, *args, **kwargs)

File "D:/odoo-8.0\openerp\api.py", line 592, in new_api

result = method(self._model, cr, uid, self.ids, *args, **old_kwargs)

File "D:/odoo-8.0\openerp\models.py", line 5050, in print_report

assert self._name == report.table

AttributeError: 'unicode' object has no attribute 'table'

William Mb
Author

When I do this :

@api.multi

def clear_record_data(self):

module_name = 'cookbook.recipe' # 'button.demo'

report_name = 'cookbook.report_recipe'

orm_button = self.env[module_name]

openerp.report.interface.report_int._reports['report.' + report_name] = report_custom('report.' + report_name)

openerp.report.interface.report_int._reports['report.' + report_name].table = module_name

button_ids = orm_button.search([])

buttons = orm_button.browse(button_ids)

return button_ids.print_report(report_name,{})

I have this

Traceback (most recent call last):

File "D:/odoo-8.0\openerp\http.py", line 544, in _handle_exception

return super(JsonRequest, self)._handle_exception(exception)

File "D:/odoo-8.0\openerp\http.py", line 581, in dispatch

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

File "D:/odoo-8.0\openerp\http.py", line 317, in _call_function

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

File "D:/odoo-8.0\openerp\service\model.py", line 118, in wrapper

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

File "D:/odoo-8.0\openerp\http.py", line 314, in checked_call

return self.endpoint(*a, **kw)

File "D:/odoo-8.0\openerp\http.py", line 810, in __call__

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

File "D:/odoo-8.0\openerp\http.py", line 410, in response_wrap

response = f(*args, **kw)

File "D:\odoo-8.0\addons\web\controllers\main.py", line 948, in call_button

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

File "D:\odoo-8.0\addons\web\controllers\main.py", line 936, in _call_kw

return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)

File "D:/odoo-8.0\openerp\api.py", line 268, in wrapper

return old_api(self, *args, **kwargs)

File "D:/odoo-8.0\openerp\api.py", line 399, in old_api

result = method(recs, *args, **kwargs)

File "D:\odoo-8.0\customs_addons\cookbook\models\button.py", line 38, in clear_record_data

return button_ids.print_report(report_name,{})

File "D:/odoo-8.0\openerp\api.py", line 266, in wrapper

return new_api(self, *args, **kwargs)

File "D:/odoo-8.0\openerp\api.py", line 592, in new_api

result = method(self._model, cr, uid, self.ids, *args, **old_kwargs)

File "D:/odoo-8.0\openerp\models.py", line 5051, in print_report

return report.create(cr, uid, ids, data, context)

File "D:/odoo-8.0\openerp\report\custom.py", line 130, in create

report = self.pool['ir.report.custom'].browse(cr, uid, [datas['report_id']])[0]

File "D:/odoo-8.0\openerp\modules\registry.py", line 102, in __getitem__

return self.models[model_name]

KeyError: 'ir.report.custom'

William Mb
Author

Thks for your help.

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
How to create a report with a custom chart and use the chart in the QWEB report?
qweb-report
Avatar
0
Jan 24
2384
Curious to know how the same variable show different values under the same loop in Qweb.
qweb-report
Avatar
0
Jan 24
2050
Error al imprimir un Qweb (espacio en blanco al principio de la hoja)
qweb-report
Avatar
0
Feb 22
3039
Where can you find the odoo manual in Spanish?
manual
Avatar
Avatar
1
Jan 20
4082
[v8] How to create qweb pdf report correctly using a custom module
qweb-report
Avatar
Avatar
2
Sep 16
11258
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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